Skip to content

Commit

Permalink
aio: fold lookup_kiocb() into its sole caller
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Mar 18, 2019
1 parent b53119f commit 833f415
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -2002,24 +2002,6 @@ COMPAT_SYSCALL_DEFINE3(io_submit, compat_aio_context_t, ctx_id,
}
#endif

/* lookup_kiocb
* Finds a given iocb for cancellation.
*/
static struct aio_kiocb *
lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb)
{
struct aio_kiocb *kiocb;

assert_spin_locked(&ctx->ctx_lock);

/* TODO: use a hash or array, this sucks. */
list_for_each_entry(kiocb, &ctx->active_reqs, ki_list) {
if (kiocb->ki_user_iocb == iocb)
return kiocb;
}
return NULL;
}

/* sys_io_cancel:
* Attempts to cancel an iocb previously passed to io_submit. If
* the operation is successfully cancelled, the resulting event is
Expand Down Expand Up @@ -2048,10 +2030,13 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb,
return -EINVAL;

spin_lock_irq(&ctx->ctx_lock);
kiocb = lookup_kiocb(ctx, iocb);
if (kiocb) {
ret = kiocb->ki_cancel(&kiocb->rw);
list_del_init(&kiocb->ki_list);
/* TODO: use a hash or array, this sucks. */
list_for_each_entry(kiocb, &ctx->active_reqs, ki_list) {
if (kiocb->ki_user_iocb == iocb) {
ret = kiocb->ki_cancel(&kiocb->rw);
list_del_init(&kiocb->ki_list);
break;
}
}
spin_unlock_irq(&ctx->ctx_lock);

Expand Down

0 comments on commit 833f415

Please sign in to comment.