blob: 5c40b61285ac2db2224386b4fb73fa5562899e3c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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 Pulavarty027445c2006-09-30 23:28:46 -07007#include <linux/uio.h>
Jens Axboeabf137d2008-12-09 08:11:22 +01008#include <linux/rcupdate.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Arun Sharma600634972011-07-26 16:09:06 -070010#include <linux/atomic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Linus Torvalds1da177e2005-04-16 15:20:36 -070012struct kioctx;
Kent Overstreet0460fef2013-05-07 16:18:49 -070013struct kiocb;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Kent Overstreet8a660892013-05-07 16:19:10 -070015#define KIOCB_KEY 0
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Kent Overstreetbec68faa2013-05-13 14:45:08 -070017typedef int (kiocb_cancel_fn)(struct kiocb *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Christoph Hellwig04b2fa92015-02-02 14:49:06 +010019#define IOCB_EVENTFD (1 << 0)
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021struct kiocb {
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 struct file *ki_filp;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 loff_t ki_pos;
Christoph Hellwig04b2fa92015-02-02 14:49:06 +010024 void (*ki_complete)(struct kiocb *iocb, long ret, long ret2);
25 void *private;
26 int ki_flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027};
28
Andrew Mortonf7e1bec2012-07-30 14:42:56 -070029static inline bool is_sync_kiocb(struct kiocb *kiocb)
30{
Christoph Hellwig04b2fa92015-02-02 14:49:06 +010031 return kiocb->ki_complete == NULL;
Andrew Mortonf7e1bec2012-07-30 14:42:56 -070032}
33
34static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
35{
36 *kiocb = (struct kiocb) {
Andrew Mortonf7e1bec2012-07-30 14:42:56 -070037 .ki_filp = filp,
Andrew Mortonf7e1bec2012-07-30 14:42:56 -070038 };
39}
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Linus Torvalds1da177e2005-04-16 15:20:36 -070041/* prototypes */
Thomas Petazzoniebf3f092008-10-15 22:05:12 -070042#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -070043struct mm_struct;
Harvey Harrisonb3c97522008-02-13 15:03:15 -080044extern void exit_aio(struct mm_struct *mm);
Jeff Moyer9d85cba72010-05-26 14:44:26 -070045extern long do_io_submit(aio_context_t ctx_id, long nr,
46 struct iocb __user *__user *iocbpp, bool compat);
Kent Overstreet0460fef2013-05-07 16:18:49 -070047void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel);
Thomas Petazzoniebf3f092008-10-15 22:05:12 -070048#else
Thomas Petazzoniebf3f092008-10-15 22:05:12 -070049struct mm_struct;
50static inline void exit_aio(struct mm_struct *mm) { }
Jeff Moyer9d85cba72010-05-26 14:44:26 -070051static inline long do_io_submit(aio_context_t ctx_id, long nr,
52 struct iocb __user * __user *iocbpp,
53 bool compat) { return 0; }
Kent Overstreet0460fef2013-05-07 16:18:49 -070054static inline void kiocb_set_cancel_fn(struct kiocb *req,
55 kiocb_cancel_fn *cancel) { }
Thomas Petazzoniebf3f092008-10-15 22:05:12 -070056#endif /* CONFIG_AIO */
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058/* for sysctl: */
Zach Brownd55b5fd2005-11-07 00:59:31 -080059extern unsigned long aio_nr;
60extern unsigned long aio_max_nr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62#endif /* __LINUX__AIO_H */