aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/aio.h
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
committerLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
commit3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch)
treeab8a881a14478598a0c8bda0d26c62cdccfffd6d /include/linux/aio.h
parent378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff)
parent9115a6c787596e687df03010d97fccc5e0762506 (diff)
Pull release into acpica branch
Diffstat (limited to 'include/linux/aio.h')
-rw-r--r--include/linux/aio.h59
1 files changed, 53 insertions, 6 deletions
diff --git a/include/linux/aio.h b/include/linux/aio.h
index a4d5af907f90..49fd37629ee4 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -24,7 +24,12 @@ struct kioctx;
24#define KIOCB_SYNC_KEY (~0U) 24#define KIOCB_SYNC_KEY (~0U)
25 25
26/* ki_flags bits */ 26/* ki_flags bits */
27#define KIF_LOCKED 0 27/*
28 * This may be used for cancel/retry serialization in the future, but
29 * for now it's unused and we probably don't want modules to even
30 * think they can use it.
31 */
32/* #define KIF_LOCKED 0 */
28#define KIF_KICKED 1 33#define KIF_KICKED 1
29#define KIF_CANCELLED 2 34#define KIF_CANCELLED 2
30 35
@@ -43,6 +48,40 @@ struct kioctx;
43#define kiocbIsKicked(iocb) test_bit(KIF_KICKED, &(iocb)->ki_flags) 48#define kiocbIsKicked(iocb) test_bit(KIF_KICKED, &(iocb)->ki_flags)
44#define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags) 49#define kiocbIsCancelled(iocb) test_bit(KIF_CANCELLED, &(iocb)->ki_flags)
45 50
51/* is there a better place to document function pointer methods? */
52/**
53 * ki_retry - iocb forward progress callback
54 * @kiocb: The kiocb struct to advance by performing an operation.
55 *
56 * This callback is called when the AIO core wants a given AIO operation
57 * to make forward progress. The kiocb argument describes the operation
58 * that is to be performed. As the operation proceeds, perhaps partially,
59 * ki_retry is expected to update the kiocb with progress made. Typically
60 * ki_retry is set in the AIO core and it itself calls file_operations
61 * helpers.
62 *
63 * ki_retry's return value determines when the AIO operation is completed
64 * and an event is generated in the AIO event ring. Except the special
65 * return values described below, the value that is returned from ki_retry
66 * is transferred directly into the completion ring as the operation's
67 * resulting status. Once this has happened ki_retry *MUST NOT* reference
68 * the kiocb pointer again.
69 *
70 * If ki_retry returns -EIOCBQUEUED it has made a promise that aio_complete()
71 * will be called on the kiocb pointer in the future. The AIO core will
72 * not ask the method again -- ki_retry must ensure forward progress.
73 * aio_complete() must be called once and only once in the future, multiple
74 * calls may result in undefined behaviour.
75 *
76 * If ki_retry returns -EIOCBRETRY it has made a promise that kick_iocb()
77 * will be called on the kiocb pointer in the future. This may happen
78 * through generic helpers that associate kiocb->ki_wait with a wait
79 * queue head that ki_retry uses via current->io_wait. It can also happen
80 * with custom tracking and manual calls to kick_iocb(), though that is
81 * discouraged. In either case, kick_iocb() must be called once and only
82 * once. ki_retry must ensure forward progress, the AIO core will wait
83 * indefinitely for kick_iocb() to be called.
84 */
46struct kiocb { 85struct kiocb {
47 struct list_head ki_run_list; 86 struct list_head ki_run_list;
48 long ki_flags; 87 long ki_flags;
@@ -85,7 +124,7 @@ struct kiocb {
85 (x)->ki_users = 1; \ 124 (x)->ki_users = 1; \
86 (x)->ki_key = KIOCB_SYNC_KEY; \ 125 (x)->ki_key = KIOCB_SYNC_KEY; \
87 (x)->ki_filp = (filp); \ 126 (x)->ki_filp = (filp); \
88 (x)->ki_ctx = &tsk->active_mm->default_kioctx; \ 127 (x)->ki_ctx = NULL; \
89 (x)->ki_cancel = NULL; \ 128 (x)->ki_cancel = NULL; \
90 (x)->ki_dtor = NULL; \ 129 (x)->ki_dtor = NULL; \
91 (x)->ki_obj.tsk = tsk; \ 130 (x)->ki_obj.tsk = tsk; \
@@ -144,6 +183,7 @@ struct kioctx {
144 struct list_head active_reqs; /* used for cancellation */ 183 struct list_head active_reqs; /* used for cancellation */
145 struct list_head run_list; /* used for kicked reqs */ 184 struct list_head run_list; /* used for kicked reqs */
146 185
186 /* sys_io_setup currently limits this to an unsigned int */
147 unsigned max_reqs; 187 unsigned max_reqs;
148 188
149 struct aio_ring_info ring_info; 189 struct aio_ring_info ring_info;
@@ -170,8 +210,15 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id);
170int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, 210int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
171 struct iocb *iocb)); 211 struct iocb *iocb));
172 212
173#define get_ioctx(kioctx) do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0) 213#define get_ioctx(kioctx) do { \
174#define put_ioctx(kioctx) do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0) 214 BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0)); \
215 atomic_inc(&(kioctx)->users); \
216} while (0)
217#define put_ioctx(kioctx) do { \
218 BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0)); \
219 if (unlikely(atomic_dec_and_test(&(kioctx)->users))) \
220 __put_ioctx(kioctx); \
221} while (0)
175 222
176#define in_aio() !is_sync_wait(current->io_wait) 223#define in_aio() !is_sync_wait(current->io_wait)
177/* may be used for debugging */ 224/* may be used for debugging */
@@ -195,7 +242,7 @@ static inline struct kiocb *list_kiocb(struct list_head *h)
195} 242}
196 243
197/* for sysctl: */ 244/* for sysctl: */
198extern atomic_t aio_nr; 245extern unsigned long aio_nr;
199extern unsigned aio_max_nr; 246extern unsigned long aio_max_nr;
200 247
201#endif /* __LINUX__AIO_H */ 248#endif /* __LINUX__AIO_H */