diff options
Diffstat (limited to 'include/linux/aio.h')
-rw-r--r-- | include/linux/aio.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/include/linux/aio.h b/include/linux/aio.h index 403d71dcb7c8..00c8efa95cc3 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h | |||
@@ -94,26 +94,27 @@ struct kiocb { | |||
94 | ssize_t (*ki_retry)(struct kiocb *); | 94 | ssize_t (*ki_retry)(struct kiocb *); |
95 | void (*ki_dtor)(struct kiocb *); | 95 | void (*ki_dtor)(struct kiocb *); |
96 | 96 | ||
97 | struct list_head ki_list; /* the aio core uses this | ||
98 | * for cancellation */ | ||
99 | |||
100 | union { | 97 | union { |
101 | void __user *user; | 98 | void __user *user; |
102 | struct task_struct *tsk; | 99 | struct task_struct *tsk; |
103 | } ki_obj; | 100 | } ki_obj; |
101 | |||
104 | __u64 ki_user_data; /* user's data for completion */ | 102 | __u64 ki_user_data; /* user's data for completion */ |
103 | wait_queue_t ki_wait; | ||
105 | loff_t ki_pos; | 104 | loff_t ki_pos; |
105 | |||
106 | void *private; | ||
106 | /* State that we remember to be able to restart/retry */ | 107 | /* State that we remember to be able to restart/retry */ |
107 | unsigned short ki_opcode; | 108 | unsigned short ki_opcode; |
108 | size_t ki_nbytes; /* copy of iocb->aio_nbytes */ | 109 | size_t ki_nbytes; /* copy of iocb->aio_nbytes */ |
109 | char __user *ki_buf; /* remaining iocb->aio_buf */ | 110 | char __user *ki_buf; /* remaining iocb->aio_buf */ |
110 | size_t ki_left; /* remaining bytes */ | 111 | size_t ki_left; /* remaining bytes */ |
111 | wait_queue_t ki_wait; | ||
112 | long ki_retried; /* just for testing */ | 112 | long ki_retried; /* just for testing */ |
113 | long ki_kicked; /* just for testing */ | 113 | long ki_kicked; /* just for testing */ |
114 | long ki_queued; /* just for testing */ | 114 | long ki_queued; /* just for testing */ |
115 | 115 | ||
116 | void *private; | 116 | struct list_head ki_list; /* the aio core uses this |
117 | * for cancellation */ | ||
117 | }; | 118 | }; |
118 | 119 | ||
119 | #define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) | 120 | #define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY) |
@@ -124,8 +125,9 @@ struct kiocb { | |||
124 | (x)->ki_users = 1; \ | 125 | (x)->ki_users = 1; \ |
125 | (x)->ki_key = KIOCB_SYNC_KEY; \ | 126 | (x)->ki_key = KIOCB_SYNC_KEY; \ |
126 | (x)->ki_filp = (filp); \ | 127 | (x)->ki_filp = (filp); \ |
127 | (x)->ki_ctx = &tsk->active_mm->default_kioctx; \ | 128 | (x)->ki_ctx = NULL; \ |
128 | (x)->ki_cancel = NULL; \ | 129 | (x)->ki_cancel = NULL; \ |
130 | (x)->ki_retry = NULL; \ | ||
129 | (x)->ki_dtor = NULL; \ | 131 | (x)->ki_dtor = NULL; \ |
130 | (x)->ki_obj.tsk = tsk; \ | 132 | (x)->ki_obj.tsk = tsk; \ |
131 | (x)->ki_user_data = 0; \ | 133 | (x)->ki_user_data = 0; \ |
@@ -210,8 +212,15 @@ struct kioctx *lookup_ioctx(unsigned long ctx_id); | |||
210 | int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, | 212 | int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, |
211 | struct iocb *iocb)); | 213 | struct iocb *iocb)); |
212 | 214 | ||
213 | #define get_ioctx(kioctx) do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0) | 215 | #define get_ioctx(kioctx) do { \ |
214 | #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) | 216 | BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0)); \ |
217 | atomic_inc(&(kioctx)->users); \ | ||
218 | } while (0) | ||
219 | #define put_ioctx(kioctx) do { \ | ||
220 | BUG_ON(unlikely(atomic_read(&(kioctx)->users) <= 0)); \ | ||
221 | if (unlikely(atomic_dec_and_test(&(kioctx)->users))) \ | ||
222 | __put_ioctx(kioctx); \ | ||
223 | } while (0) | ||
215 | 224 | ||
216 | #define in_aio() !is_sync_wait(current->io_wait) | 225 | #define in_aio() !is_sync_wait(current->io_wait) |
217 | /* may be used for debugging */ | 226 | /* may be used for debugging */ |