Jens Axboe | 771b53d0 | 2019-10-22 10:25:58 -0600 | [diff] [blame] | 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, |
Jens Axboe | fcb323c | 2019-10-24 12:39:47 -0600 | [diff] [blame^] | 11 | IO_WQ_WORK_NEEDS_FILES = 16, |
Jens Axboe | 771b53d0 | 2019-10-22 10:25:58 -0600 | [diff] [blame] | 12 | |
| 13 | IO_WQ_HASH_SHIFT = 24, /* upper 8 bits are used for hash key */ |
| 14 | }; |
| 15 | |
| 16 | enum io_wq_cancel { |
| 17 | IO_WQ_CANCEL_OK, /* cancelled before started */ |
| 18 | IO_WQ_CANCEL_RUNNING, /* found, running, and attempted cancelled */ |
| 19 | IO_WQ_CANCEL_NOTFOUND, /* work not found */ |
| 20 | }; |
| 21 | |
| 22 | struct io_wq_work { |
| 23 | struct list_head list; |
| 24 | void (*func)(struct io_wq_work **); |
| 25 | unsigned flags; |
Jens Axboe | fcb323c | 2019-10-24 12:39:47 -0600 | [diff] [blame^] | 26 | struct files_struct *files; |
Jens Axboe | 771b53d0 | 2019-10-22 10:25:58 -0600 | [diff] [blame] | 27 | }; |
| 28 | |
| 29 | #define INIT_IO_WORK(work, _func) \ |
| 30 | do { \ |
| 31 | (work)->func = _func; \ |
| 32 | (work)->flags = 0; \ |
Jens Axboe | fcb323c | 2019-10-24 12:39:47 -0600 | [diff] [blame^] | 33 | (work)->files = NULL; \ |
Jens Axboe | 771b53d0 | 2019-10-22 10:25:58 -0600 | [diff] [blame] | 34 | } while (0) \ |
| 35 | |
| 36 | struct io_wq *io_wq_create(unsigned concurrency, struct mm_struct *mm); |
| 37 | void io_wq_destroy(struct io_wq *wq); |
| 38 | |
| 39 | void io_wq_enqueue(struct io_wq *wq, struct io_wq_work *work); |
| 40 | void io_wq_enqueue_hashed(struct io_wq *wq, struct io_wq_work *work, void *val); |
| 41 | void io_wq_flush(struct io_wq *wq); |
| 42 | |
| 43 | void io_wq_cancel_all(struct io_wq *wq); |
| 44 | enum io_wq_cancel io_wq_cancel_work(struct io_wq *wq, struct io_wq_work *cwork); |
| 45 | |
| 46 | #if defined(CONFIG_IO_WQ) |
| 47 | extern void io_wq_worker_sleeping(struct task_struct *); |
| 48 | extern void io_wq_worker_running(struct task_struct *); |
| 49 | #else |
| 50 | static inline void io_wq_worker_sleeping(struct task_struct *tsk) |
| 51 | { |
| 52 | } |
| 53 | static inline void io_wq_worker_running(struct task_struct *tsk) |
| 54 | { |
| 55 | } |
| 56 | #endif |
| 57 | |
| 58 | #endif |