Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 233700
b: refs/heads/master
c: 7137c6b
h: refs/heads/master
v: v3
  • Loading branch information
Jan Kara authored and Linus Torvalds committed Feb 25, 2011
1 parent a4fbc1f commit 2294ad9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3bd9a5d734c7cc7533b27abf451416c7f50095a7
refs/heads/master: 7137c6bd455234bcb7560fd829e6ee49cae5fed6
17 changes: 17 additions & 0 deletions trunk/fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,23 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
goto out_put_req;

spin_lock_irq(&ctx->ctx_lock);
/*
* We could have raced with io_destroy() and are currently holding a
* reference to ctx which should be destroyed. We cannot submit IO
* since ctx gets freed as soon as io_submit() puts its reference. The
* check here is reliable: io_destroy() sets ctx->dead before waiting
* for outstanding IO and the barrier between these two is realized by
* unlock of mm->ioctx_lock and lock of ctx->ctx_lock. Analogously we
* increment ctx->reqs_active before checking for ctx->dead and the
* barrier is realized by unlock and lock of ctx->ctx_lock. Thus if we
* don't see ctx->dead set here, io_destroy() waits for our IO to
* finish.
*/
if (ctx->dead) {
spin_unlock_irq(&ctx->ctx_lock);
ret = -EINVAL;
goto out_put_req;
}
aio_run_iocb(req);
if (!list_empty(&ctx->run_list)) {
/* drain the run list */
Expand Down

0 comments on commit 2294ad9

Please sign in to comment.