Commit | Line | Data |
---|---|---|
771b53d0 JA |
1 | #ifndef INTERNAL_IO_WQ_H |
2 | #define INTERNAL_IO_WQ_H | |
3 | ||
4 | struct io_wq; | |
5 | ||
6 | enum { | |
7 | IO_WQ_WORK_CANCEL = 1, | |
8 | IO_WQ_WORK_HAS_MM = 2, | |
9 | IO_WQ_WORK_HASHED = 4, | |
10 | IO_WQ_WORK_NEEDS_USER = 8, | |
fcb323cc | 11 | IO_WQ_WORK_NEEDS_FILES = 16, |
c5def4ab | 12 | IO_WQ_WORK_UNBOUND = 32, |
771b53d0 JA |
13 | |
14 | IO_WQ_HASH_SHIFT = 24, /* upper 8 bits are used for hash key */ | |
15 | }; | |
16 | ||
17 | enum io_wq_cancel { | |
18 | IO_WQ_CANCEL_OK, /* cancelled before started */ | |
19 | IO_WQ_CANCEL_RUNNING, /* found, running, and attempted cancelled */ | |
20 | IO_WQ_CANCEL_NOTFOUND, /* work not found */ | |
21 | }; | |
22 | ||
23 | struct io_wq_work { | |
24 | struct list_head list; | |
25 | void (*func)(struct io_wq_work **); | |
26 | unsigned flags; | |
fcb323cc | 27 | struct files_struct *files; |
771b53d0 JA |
28 | }; |
29 | ||
30 | #define INIT_IO_WORK(work, _func) \ | |
31 | do { \ | |
32 | (work)->func = _func; \ | |
33 | (work)->flags = 0; \ | |
fcb323cc | 34 | (work)->files = NULL; \ |
771b53d0 JA |
35 | } while (0) \ |
36 | ||
c5def4ab JA |
37 | struct io_wq *io_wq_create(unsigned bounded, struct mm_struct *mm, |
38 | struct user_struct *user); | |
771b53d0 JA |
39 | void io_wq_destroy(struct io_wq *wq); |
40 | ||
41 | void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work); | |
42 | void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val); | |
43 | void io_wq_flush(struct io_wq *wq); | |
44 | ||
45 | void io_wq_cancel_all(struct io_wq *wq); | |
46 | enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork); | |
47 | ||
62755e35 JA |
48 | typedef bool (work_cancel_fn)(struct io_wq_work *, void *); |
49 | ||
50 | enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel, | |
51 | void *data); | |
52 | ||
771b53d0 JA |
53 | #if defined(CONFIG_IO_WQ) |
54 | extern void io_wq_worker_sleeping(struct task_struct *); | |
55 | extern void io_wq_worker_running(struct task_struct *); | |
56 | #else | |
57 | static inline void io_wq_worker_sleeping(struct task_struct *tsk) | |
58 | { | |
59 | } | |
60 | static inline void io_wq_worker_running(struct task_struct *tsk) | |
61 | { | |
62 | } | |
63 | #endif | |
64 | ||
960e432d JA |
65 | static inline bool io_wq_current_is_worker(void) |
66 | { | |
67 | return in_task() && (current->flags & PF_IO_WORKER); | |
68 | } | |
771b53d0 | 69 | #endif |