Files
scoutfs/kmod/src/per_task.h
Zach Brown cfa563a4a4 scoutfs: expand the per_task API
This adds some minor functionality to the per_task API for use by the
upcoming offline waiting work.

Add scoutfs_per_task_add_excl() so that a caller can tell if their task
was already put on a per-task list by their caller.

Make scoutfs_per_task_del() return a bool to indicate if the entry was
found on a list and was in fact deleted, or not.

Add scoutfs_per_task_init_entry() for initializing entries that aren't
declared on the stack.

Signed-off-by: Zach Brown <zab@versity.com>
2019-05-21 11:33:26 -07:00

32 lines
889 B
C

#ifndef _SCOUTFS_PER_TASK_H_
#define _SCOUTFS_PER_TASK_H_
struct scoutfs_per_task {
spinlock_t lock;
struct list_head list;
};
struct scoutfs_per_task_entry {
struct list_head head;
struct task_struct *task;
void *ptr;
};
#define SCOUTFS_DECLARE_PER_TASK_ENTRY(name) \
struct scoutfs_per_task_entry name = { \
.head = LIST_HEAD_INIT((name).head), \
}
void *scoutfs_per_task_get(struct scoutfs_per_task *pt);
void scoutfs_per_task_add(struct scoutfs_per_task *pt,
struct scoutfs_per_task_entry *ent, void *ptr);
bool scoutfs_per_task_add_excl(struct scoutfs_per_task *pt,
struct scoutfs_per_task_entry *ent, void *ptr);
bool scoutfs_per_task_del(struct scoutfs_per_task *pt,
struct scoutfs_per_task_entry *ent);
void scoutfs_per_task_init(struct scoutfs_per_task *pt);
void scoutfs_per_task_init_entry(struct scoutfs_per_task_entry *ent);
#endif