1 #ifndef INTERNAL_IO_WQ_H
2 #define INTERNAL_IO_WQ_H
10 IO_WQ_WORK_NEEDS_USER = 8,
11 IO_WQ_WORK_NEEDS_FILES = 16,
12 IO_WQ_WORK_UNBOUND = 32,
13 IO_WQ_WORK_INTERNAL = 64,
15 IO_WQ_HASH_SHIFT = 24, /* upper 8 bits are used for hash key */
19 IO_WQ_CANCEL_OK, /* cancelled before started */
20 IO_WQ_CANCEL_RUNNING, /* found, running, and attempted cancelled */
21 IO_WQ_CANCEL_NOTFOUND, /* work not found */
25 struct list_head list;
26 void (*func)(struct io_wq_work **);
28 struct files_struct *files;
31 #define INIT_IO_WORK(work, _func) \
33 (work)->func = _func; \
35 (work)->files = NULL; \
38 typedef void (get_work_fn)(struct io_wq_work *);
39 typedef void (put_work_fn)(struct io_wq_work *);
41 struct io_wq *io_wq_create(unsigned bounded, struct mm_struct *mm,
42 struct user_struct *user,
43 get_work_fn *get_work, put_work_fn *put_work);
44 void io_wq_destroy(struct io_wq *wq);
46 void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
47 void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val);
48 void io_wq_flush(struct io_wq *wq);
50 void io_wq_cancel_all(struct io_wq *wq);
51 enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork);
53 typedef bool (work_cancel_fn)(struct io_wq_work *, void *);
55 enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel,
58 #if defined(CONFIG_IO_WQ)
59 extern void io_wq_worker_sleeping(struct task_struct *);
60 extern void io_wq_worker_running(struct task_struct *);
62 static inline void io_wq_worker_sleeping(struct task_struct *tsk)
65 static inline void io_wq_worker_running(struct task_struct *tsk)
70 static inline bool io_wq_current_is_worker(void)
72 return in_task() && (current->flags & PF_IO_WORKER);