Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __LINUX__AIO_H |
| 2 | #define __LINUX__AIO_H |
| 3 | |
| 4 | #include <linux/list.h> |
| 5 | #include <linux/workqueue.h> |
| 6 | #include <linux/aio_abi.h> |
Badari Pulavarty | 027445c | 2006-09-30 23:28:46 -0700 | [diff] [blame] | 7 | #include <linux/uio.h> |
Jens Axboe | abf137d | 2008-12-09 08:11:22 +0100 | [diff] [blame] | 8 | #include <linux/rcupdate.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 10 | #include <linux/atomic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | struct kioctx; |
Kent Overstreet | 0460fef | 2013-05-07 16:18:49 -0700 | [diff] [blame] | 13 | struct kiocb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Kent Overstreet | 8a66089 | 2013-05-07 16:19:10 -0700 | [diff] [blame] | 15 | #define KIOCB_KEY 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
Kent Overstreet | bec68faa | 2013-05-13 14:45:08 -0700 | [diff] [blame] | 17 | typedef int (kiocb_cancel_fn)(struct kiocb *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Christoph Hellwig | 04b2fa9 | 2015-02-02 14:49:06 +0100 | [diff] [blame^] | 19 | #define IOCB_EVENTFD (1 << 0) |
| 20 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | struct kiocb { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | struct file *ki_filp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | loff_t ki_pos; |
Christoph Hellwig | 04b2fa9 | 2015-02-02 14:49:06 +0100 | [diff] [blame^] | 24 | void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); |
| 25 | void *private; |
| 26 | int ki_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | }; |
| 28 | |
Andrew Morton | f7e1bec | 2012-07-30 14:42:56 -0700 | [diff] [blame] | 29 | static inline bool is_sync_kiocb(struct kiocb *kiocb) |
| 30 | { |
Christoph Hellwig | 04b2fa9 | 2015-02-02 14:49:06 +0100 | [diff] [blame^] | 31 | return kiocb->ki_complete == NULL; |
Andrew Morton | f7e1bec | 2012-07-30 14:42:56 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) |
| 35 | { |
| 36 | *kiocb = (struct kiocb) { |
Andrew Morton | f7e1bec | 2012-07-30 14:42:56 -0700 | [diff] [blame] | 37 | .ki_filp = filp, |
Andrew Morton | f7e1bec | 2012-07-30 14:42:56 -0700 | [diff] [blame] | 38 | }; |
| 39 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | /* prototypes */ |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 42 | #ifdef CONFIG_AIO |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | struct mm_struct; |
Harvey Harrison | b3c9752 | 2008-02-13 15:03:15 -0800 | [diff] [blame] | 44 | extern void exit_aio(struct mm_struct *mm); |
Jeff Moyer | 9d85cba7 | 2010-05-26 14:44:26 -0700 | [diff] [blame] | 45 | extern long do_io_submit(aio_context_t ctx_id, long nr, |
| 46 | struct iocb __user *__user *iocbpp, bool compat); |
Kent Overstreet | 0460fef | 2013-05-07 16:18:49 -0700 | [diff] [blame] | 47 | void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel); |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 48 | #else |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 49 | struct mm_struct; |
| 50 | static inline void exit_aio(struct mm_struct *mm) { } |
Jeff Moyer | 9d85cba7 | 2010-05-26 14:44:26 -0700 | [diff] [blame] | 51 | static inline long do_io_submit(aio_context_t ctx_id, long nr, |
| 52 | struct iocb __user * __user *iocbpp, |
| 53 | bool compat) { return 0; } |
Kent Overstreet | 0460fef | 2013-05-07 16:18:49 -0700 | [diff] [blame] | 54 | static inline void kiocb_set_cancel_fn(struct kiocb *req, |
| 55 | kiocb_cancel_fn *cancel) { } |
Thomas Petazzoni | ebf3f09 | 2008-10-15 22:05:12 -0700 | [diff] [blame] | 56 | #endif /* CONFIG_AIO */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | /* for sysctl: */ |
Zach Brown | d55b5fd | 2005-11-07 00:59:31 -0800 | [diff] [blame] | 59 | extern unsigned long aio_nr; |
| 60 | extern unsigned long aio_max_nr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | #endif /* __LINUX__AIO_H */ |