Skip to content

Commit 8a66089

Browse files
Kent Overstreettorvalds
authored andcommitted
aio: kill ki_key
ki_key wasn't actually used for anything previously - it was always 0. Drop it to trim struct kiocb a bit. Signed-off-by: Kent Overstreet <koverstreet@google.com> Cc: Zach Brown <zab@redhat.com> Cc: Felipe Balbi <balbi@ti.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Rusty Russell <rusty@rustcorp.com.au> Cc: Jens Axboe <axboe@kernel.dk> Cc: Asai Thambi S P <asamymuthupa@micron.com> Cc: Selvan Mani <smani@micron.com> Cc: Sam Bradshaw <sbradshaw@micron.com> Cc: Jeff Moyer <jmoyer@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Benjamin LaHaise <bcrl@kvack.org> Reviewed-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 4e23bca commit 8a66089

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎fs/aio.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
11591159
}
11601160
}
11611161

1162-
ret = put_user(req->ki_key, &user_iocb->aio_key);
1162+
ret = put_user(KIOCB_KEY, &user_iocb->aio_key);
11631163
if (unlikely(ret)) {
11641164
pr_debug("EFAULT: aio_key\n");
11651165
goto out_put_req;
@@ -1281,10 +1281,13 @@ static struct kiocb *lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb,
12811281

12821282
assert_spin_locked(&ctx->ctx_lock);
12831283

1284+
if (key != KIOCB_KEY)
1285+
return NULL;
1286+
12841287
/* TODO: use a hash or array, this sucks. */
12851288
list_for_each(pos, &ctx->active_reqs) {
12861289
struct kiocb *kiocb = list_kiocb(pos);
1287-
if (kiocb->ki_obj.user == iocb && kiocb->ki_key == key)
1290+
if (kiocb->ki_obj.user == iocb)
12881291
return kiocb;
12891292
}
12901293
return NULL;

‎include/linux/aio.h‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
struct kioctx;
1313
struct kiocb;
1414

15-
#define KIOCB_SYNC_KEY (~0U)
15+
#define KIOCB_KEY 0
1616

1717
/*
1818
* 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 *);
5656
*/
5757
struct kiocb {
5858
atomic_t ki_users;
59-
unsigned ki_key; /* id of this request */
6059

6160
struct file *ki_filp;
62-
struct kioctx *ki_ctx; /* may be NULL for sync ops */
61+
struct kioctx *ki_ctx; /* NULL for sync ops */
6362
kiocb_cancel_fn *ki_cancel;
6463
ssize_t (*ki_retry)(struct kiocb *);
6564
void (*ki_dtor)(struct kiocb *);
@@ -95,14 +94,14 @@ struct kiocb {
9594

9695
static inline bool is_sync_kiocb(struct kiocb *kiocb)
9796
{
98-
return kiocb->ki_key == KIOCB_SYNC_KEY;
97+
return kiocb->ki_ctx == NULL;
9998
}
10099

101100
static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
102101
{
103102
*kiocb = (struct kiocb) {
104103
.ki_users = ATOMIC_INIT(1),
105-
.ki_key = KIOCB_SYNC_KEY,
104+
.ki_ctx = NULL,
106105
.ki_filp = filp,
107106
.ki_obj.tsk = current,
108107
};

0 commit comments

Comments
 (0)