Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298359
b: refs/heads/master
c: 06af121
h: refs/heads/master
i:
  298357: 9edf2a1
  298355: 238d390
  298351: 48addcf
v: v3
  • Loading branch information
Al Viro committed Mar 31, 2012
1 parent b909380 commit 713046a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a1c2aa1e86a25e7cace2ded47ec52754206a5733
refs/heads/master: 06af121eab543e5554f7a29538f171a382aaf855
22 changes: 7 additions & 15 deletions trunk/fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,18 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
return ERR_PTR(err);
}

/* aio_cancel_all
/* kill_ctx
* Cancels all outstanding aio requests on an aio context. Used
* when the processes owning a context have all exited to encourage
* the rapid destruction of the kioctx.
*/
static void aio_cancel_all(struct kioctx *ctx)
static void kill_ctx(struct kioctx *ctx)
{
int (*cancel)(struct kiocb *, struct io_event *);
struct task_struct *tsk = current;
DECLARE_WAITQUEUE(wait, tsk);
struct io_event res;

spin_lock_irq(&ctx->ctx_lock);
ctx->dead = 1;
while (!list_empty(&ctx->active_reqs)) {
Expand All @@ -329,15 +332,7 @@ static void aio_cancel_all(struct kioctx *ctx)
spin_lock_irq(&ctx->ctx_lock);
}
}
spin_unlock_irq(&ctx->ctx_lock);
}

static void wait_for_all_aios(struct kioctx *ctx)
{
struct task_struct *tsk = current;
DECLARE_WAITQUEUE(wait, tsk);

spin_lock_irq(&ctx->ctx_lock);
if (!ctx->reqs_active)
goto out;

Expand Down Expand Up @@ -387,9 +382,7 @@ void exit_aio(struct mm_struct *mm)
ctx = hlist_entry(mm->ioctx_list.first, struct kioctx, list);
hlist_del_rcu(&ctx->list);

aio_cancel_all(ctx);

wait_for_all_aios(ctx);
kill_ctx(ctx);

if (1 != atomic_read(&ctx->users))
printk(KERN_DEBUG
Expand Down Expand Up @@ -1269,8 +1262,7 @@ static void io_destroy(struct kioctx *ioctx)
if (likely(!was_dead))
put_ioctx(ioctx); /* twice for the list */

aio_cancel_all(ioctx);
wait_for_all_aios(ioctx);
kill_ctx(ioctx);

/*
* Wake up any waiters. The setting of ctx->dead must be seen
Expand Down

0 comments on commit 713046a

Please sign in to comment.