diff options
-rw-r--r-- | fs/aio.c | 7 | ||||
-rw-r--r-- | include/linux/aio.h | 9 |
2 files changed, 9 insertions, 7 deletions
@@ -1159,7 +1159,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, | |||
1159 | } | 1159 | } |
1160 | } | 1160 | } |
1161 | 1161 | ||
1162 | ret = put_user(req->ki_key, &user_iocb->aio_key); | 1162 | ret = put_user(KIOCB_KEY, &user_iocb->aio_key); |
1163 | if (unlikely(ret)) { | 1163 | if (unlikely(ret)) { |
1164 | pr_debug("EFAULT: aio_key\n"); | 1164 | pr_debug("EFAULT: aio_key\n"); |
1165 | goto out_put_req; | 1165 | goto out_put_req; |
@@ -1281,10 +1281,13 @@ static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb, | |||
1281 | 1281 | ||
1282 | assert_spin_locked(&ctx->ctx_lock); | 1282 | assert_spin_locked(&ctx->ctx_lock); |
1283 | 1283 | ||
1284 | if (key != KIOCB_KEY) | ||
1285 | return NULL; | ||
1286 | |||
1284 | /* TODO: use a hash or array, this sucks. */ | 1287 | /* TODO: use a hash or array, this sucks. */ |
1285 | list_for_each(pos, &ctx->active_reqs) { | 1288 | list_for_each(pos, &ctx->active_reqs) { |
1286 | struct kiocb *kiocb = list_kiocb(pos); | 1289 | struct kiocb *kiocb = list_kiocb(pos); |
1287 | if (kiocb->ki_obj.user == iocb && kiocb->ki_key == key) | 1290 | if (kiocb->ki_obj.user == iocb) |
1288 | return kiocb; | 1291 | return kiocb; |
1289 | } | 1292 | } |
1290 | return NULL; | 1293 | return NULL; |
diff --git a/include/linux/aio.h b/include/linux/aio.h index f0a8481af99b..7308836dd045 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h | |||
@@ -12,7 +12,7 @@ | |||
12 | struct kioctx; | 12 | struct kioctx; |
13 | struct kiocb; | 13 | struct kiocb; |
14 | 14 | ||
15 | #define KIOCB_SYNC_KEY (~0U) | 15 | #define KIOCB_KEY 0 |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * We use ki_cancel == KIOCB_CANCELLED to indicate that a kiocb has been either | 18 | * We use ki_cancel == KIOCB_CANCELLED to indicate that a kiocb has been either |
@@ -56,10 +56,9 @@ typedef int (kiocb_cancel_fn)(struct kiocb *, struct io_event *); | |||
56 | */ | 56 | */ |
57 | struct kiocb { | 57 | struct kiocb { |
58 | atomic_t ki_users; | 58 | atomic_t ki_users; |
59 | unsigned ki_key; /* id of this request */ | ||
60 | 59 | ||
61 | struct file *ki_filp; | 60 | struct file *ki_filp; |
62 | struct kioctx *ki_ctx; /* may be NULL for sync ops */ | 61 | struct kioctx *ki_ctx; /* NULL for sync ops */ |
63 | kiocb_cancel_fn *ki_cancel; | 62 | kiocb_cancel_fn *ki_cancel; |
64 | ssize_t (*ki_retry)(struct kiocb *); | 63 | ssize_t (*ki_retry)(struct kiocb *); |
65 | void (*ki_dtor)(struct kiocb *); | 64 | void (*ki_dtor)(struct kiocb *); |
@@ -95,14 +94,14 @@ struct kiocb { | |||
95 | 94 | ||
96 | static inline bool is_sync_kiocb(struct kiocb *kiocb) | 95 | static inline bool is_sync_kiocb(struct kiocb *kiocb) |
97 | { | 96 | { |
98 | return kiocb->ki_key == KIOCB_SYNC_KEY; | 97 | return kiocb->ki_ctx == NULL; |
99 | } | 98 | } |
100 | 99 | ||
101 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) | 100 | static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) |
102 | { | 101 | { |
103 | *kiocb = (struct kiocb) { | 102 | *kiocb = (struct kiocb) { |
104 | .ki_users = ATOMIC_INIT(1), | 103 | .ki_users = ATOMIC_INIT(1), |
105 | .ki_key = KIOCB_SYNC_KEY, | 104 | .ki_ctx = NULL, |
106 | .ki_filp = filp, | 105 | .ki_filp = filp, |
107 | .ki_obj.tsk = current, | 106 | .ki_obj.tsk = current, |
108 | }; | 107 | }; |