diff options
author | Jens Axboe <axboe@kernel.dk> | 2020-05-22 19:18:23 +0300 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-06-22 05:44:26 +0300 |
commit | d1932dc3dc268f8dd5201c64971324d06ba977cc (patch) | |
tree | bee2f7f23dd7bdf3132f89d993ac2b1b051fced1 /include/linux/pagemap.h | |
parent | 8730f12b7962b21ea9ad2756abce1e205d22db84 (diff) | |
download | linux-d1932dc3dc268f8dd5201c64971324d06ba977cc.tar.xz |
mm: add kiocb_wait_page_queue_init() helper
Checks if the file supports it, and initializes the values that we need.
Caller passes in 'data' pointer, if any, and the callback function to
be used.
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/pagemap.h')
-rw-r--r-- | include/linux/pagemap.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index e053e1d9a4d7..7386bc67cc5a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -533,6 +533,27 @@ static inline int wake_page_match(struct wait_page_queue *wait_page, return 1; } +static inline int kiocb_wait_page_queue_init(struct kiocb *kiocb, + struct wait_page_queue *wait, + wait_queue_func_t func, + void *data) +{ + /* Can't support async wakeup with polled IO */ + if (kiocb->ki_flags & IOCB_HIPRI) + return -EINVAL; + if (kiocb->ki_filp->f_mode & FMODE_BUF_RASYNC) { + wait->wait.func = func; + wait->wait.private = data; + wait->wait.flags = 0; + INIT_LIST_HEAD(&wait->wait.entry); + kiocb->ki_flags |= IOCB_WAITQ; + kiocb->ki_waitq = wait; + return 0; + } + + return -EOPNOTSUPP; +} + extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_async(struct page *page, struct wait_page_queue *wait); |