blob: 8cb345256f35038a707583b288430358042332b0 [file] [log] [blame]
Jens Axboe771b53d02019-10-22 10:25:58 -06001#ifndef INTERNAL_IO_WQ_H
2#define INTERNAL_IO_WQ_H
3
4struct io_wq;
5
6enum {
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,
Jens Axboefcb323c2019-10-24 12:39:47 -060011 IO_WQ_WORK_NEEDS_FILES = 16,
Jens Axboec5def4a2019-11-07 11:41:16 -070012 IO_WQ_WORK_UNBOUND = 32,
Jens Axboe771b53d02019-10-22 10:25:58 -060013
14 IO_WQ_HASH_SHIFT = 24, /* upper 8 bits are used for hash key */
15};
16
17enum 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
23struct io_wq_work {
24 struct list_head list;
25 void (*func)(struct io_wq_work **);
26 unsigned flags;
Jens Axboefcb323c2019-10-24 12:39:47 -060027 struct files_struct *files;
Jens Axboe771b53d02019-10-22 10:25:58 -060028};
29
30#define INIT_IO_WORK(work, _func) \
31 do { \
32 (work)->func = _func; \
33 (work)->flags = 0; \
Jens Axboefcb323c2019-10-24 12:39:47 -060034 (work)->files = NULL; \
Jens Axboe771b53d02019-10-22 10:25:58 -060035 } while (0) \
36
Jens Axboec5def4a2019-11-07 11:41:16 -070037struct io_wq *io_wq_create(unsigned bounded, struct mm_struct *mm,
38 struct user_struct *user);
Jens Axboe771b53d02019-10-22 10:25:58 -060039void io_wq_destroy(struct io_wq *wq);
40
41void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work);
42void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val);
43void io_wq_flush(struct io_wq *wq);
44
45void io_wq_cancel_all(struct io_wq *wq);
46enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork);
47
Jens Axboe62755e32019-10-28 21:49:21 -060048typedef bool (work_cancel_fn)(struct io_wq_work *, void *);
49
50enum io_wq_cancel io_wq_cancel_cb(struct io_wq *wq, work_cancel_fn *cancel,
51 void *data);
52
Jens Axboe771b53d02019-10-22 10:25:58 -060053#if defined(CONFIG_IO_WQ)
54extern void io_wq_worker_sleeping(struct task_struct *);
55extern void io_wq_worker_running(struct task_struct *);
56#else
57static inline void io_wq_worker_sleeping(struct task_struct *tsk)
58{
59}
60static inline void io_wq_worker_running(struct task_struct *tsk)
61{
62}
63#endif
64
65#endif