From ec70903a88df1e5655523ffdffaacbeeee5c27e8 Mon Sep 17 00:00:00 2001 From: Ken Chen Date: Sat, 3 Feb 2007 01:13:45 -0800 Subject: [PATCH] --- yaml --- r: 46055 b: refs/heads/master c: dee11c2364f51cac53df17d742a0c69097e29a4e h: refs/heads/master i: 46053: 3b5f1c1fcd2ff4dd7d686d90718062a2eeeeace5 46051: 6557c504ad8e940995fc9e71ca77cdab2e936abb 46047: cde1a46a5e9c92b2921cdf77a4f3e69088f8fdf5 v: v3 --- [refs] | 2 +- trunk/fs/aio.c | 20 +++++++++----------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/[refs] b/[refs] index 9520d46cf032..d8d4b84feb91 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3e8219806c33b64a00b0013f96f735451f30c64c +refs/heads/master: dee11c2364f51cac53df17d742a0c69097e29a4e diff --git a/trunk/fs/aio.c b/trunk/fs/aio.c index ee20fc4240e0..55991e4132a7 100644 --- a/trunk/fs/aio.c +++ b/trunk/fs/aio.c @@ -298,17 +298,23 @@ 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) - return; + goto out; add_wait_queue(&ctx->wait, &wait); set_task_state(tsk, TASK_UNINTERRUPTIBLE); while (ctx->reqs_active) { + spin_unlock_irq(&ctx->ctx_lock); schedule(); set_task_state(tsk, TASK_UNINTERRUPTIBLE); + spin_lock_irq(&ctx->ctx_lock); } __set_task_state(tsk, TASK_RUNNING); remove_wait_queue(&ctx->wait, &wait); + +out: + spin_unlock_irq(&ctx->ctx_lock); } /* wait_on_sync_kiocb: @@ -424,7 +430,6 @@ static struct kiocb fastcall *__aio_get_req(struct kioctx *ctx) ring = kmap_atomic(ctx->ring_info.ring_pages[0], KM_USER0); if (ctx->reqs_active < aio_ring_avail(&ctx->ring_info, ring)) { list_add(&req->ki_list, &ctx->active_reqs); - get_ioctx(ctx); ctx->reqs_active++; okay = 1; } @@ -536,8 +541,6 @@ int fastcall aio_put_req(struct kiocb *req) spin_lock_irq(&ctx->ctx_lock); ret = __aio_put_req(ctx, req); spin_unlock_irq(&ctx->ctx_lock); - if (ret) - put_ioctx(ctx); return ret; } @@ -779,8 +782,7 @@ static int __aio_run_iocbs(struct kioctx *ctx) */ iocb->ki_users++; /* grab extra reference */ aio_run_iocb(iocb); - if (__aio_put_req(ctx, iocb)) /* drop extra ref */ - put_ioctx(ctx); + __aio_put_req(ctx, iocb); } if (!list_empty(&ctx->run_list)) return 1; @@ -997,14 +999,10 @@ int fastcall aio_complete(struct kiocb *iocb, long res, long res2) /* everything turned out well, dispose of the aiocb. */ ret = __aio_put_req(ctx, iocb); - spin_unlock_irqrestore(&ctx->ctx_lock, flags); - if (waitqueue_active(&ctx->wait)) wake_up(&ctx->wait); - if (ret) - put_ioctx(ctx); - + spin_unlock_irqrestore(&ctx->ctx_lock, flags); return ret; }