4 #include <linux/list.h>
5 #include <linux/workqueue.h>
6 #include <linux/aio_abi.h>
8 #include <linux/rcupdate.h>
10 #include <linux/atomic.h>
18 * We use ki_cancel == KIOCB_CANCELLED to indicate that a kiocb has been either
19 * cancelled or completed (this makes a certain amount of sense because
20 * successful cancellation - io_cancel() - does deliver the completion to
23 * And since most things don't implement kiocb cancellation and we'd really like
24 * kiocb completion to be lockless when possible, we use ki_cancel to
25 * synchronize cancellation and completion - we only set it to KIOCB_CANCELLED
26 * with xchg() or cmpxchg(), see batch_complete_aio() and kiocb_cancel().
28 #define KIOCB_CANCELLED ((void *) (~0ULL))
30 typedef int (kiocb_cancel_fn)(struct kiocb *);
34 struct kioctx *ki_ctx; /* NULL for sync ops */
35 kiocb_cancel_fn *ki_cancel;
42 __u64 ki_user_data; /* user's data for completion */
45 struct list_head ki_list; /* the aio core uses this
49 * If the aio_resfd field of the userspace iocb is not zero,
50 * this is the underlying eventfd context to deliver events to.
52 struct eventfd_ctx *ki_eventfd;
55 static inline bool is_sync_kiocb(struct kiocb *kiocb)
57 return kiocb->ki_ctx == NULL;
60 static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
62 *kiocb = (struct kiocb) {
70 extern void aio_complete(struct kiocb *iocb, long res, long res2);
72 extern void exit_aio(struct mm_struct *mm);
73 extern long do_io_submit(aio_context_t ctx_id, long nr,
74 struct iocb __user *__user *iocbpp, bool compat);
75 void kiocb_set_cancel_fn(struct kiocb *req, kiocb_cancel_fn *cancel);
77 static inline void aio_complete(struct kiocb *iocb, long res, long res2) { }
79 static inline void exit_aio(struct mm_struct *mm) { }
80 static inline long do_io_submit(aio_context_t ctx_id, long nr,
81 struct iocb __user * __user *iocbpp,
82 bool compat) { return 0; }
83 static inline void kiocb_set_cancel_fn(struct kiocb *req,
84 kiocb_cancel_fn *cancel) { }
85 #endif /* CONFIG_AIO */
87 static inline struct kiocb *list_kiocb(struct list_head *h)
89 return list_entry(h, struct kiocb, ki_list);
93 extern unsigned long aio_nr;
94 extern unsigned long aio_max_nr;
96 #endif /* __LINUX__AIO_H */