From: Suparna Bhattacharya <suparna@in.ibm.com>
To: Daniel McNeil <daniel@osdl.org>
Cc: Andrew Morton <akpm@osdl.org>,
"linux-aio@kvack.org" <linux-aio@kvack.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2.6.0-test6-mm1] aio ref count in io_submit_one
Date: Wed, 1 Oct 2003 14:16:39 +0530 [thread overview]
Message-ID: <20031001084639.GA4188@in.ibm.com> (raw)
In-Reply-To: <1064964169.1922.16.camel@ibm-c.pdx.osdl.net>
On Tue, Sep 30, 2003 at 04:22:49PM -0700, Daniel McNeil wrote:
> Andrew and Suparna,
>
> Here is a patch to hold an extra reference count on the AIO request iocb
> while it is being submitted and then drop it ref before returning.
> This prevents the race I was seeing with AIO O_DIRECT tests on ext3
> where the aio_complete() was freeing the iocb while it was still
> be referenced by the AIO submit code path. I've run this on my
> 2-proc box with CONFIG_DEBUG_PAGEALLOC on and I no longer hit
> the oops. The other option is to change the AIO code to never
> reference the iocb after it has been submitted, but that seems more
> error prone. This patch is a very small change. I am surprised we have
> not seen this race before.
>
> Thoughts?
>
> Daniel
>
>
> --- linux-2.6.0-test6-mm1/fs/aio.c 2003-09-30 14:47:51.000000000 -0700
> +++ linux-2.6.0-test6-mm1.aio/fs/aio.c 2003-09-30 16:03:08.702783397 -0700
> @@ -1490,7 +1490,14 @@ int io_submit_one(struct kioctx *ctx, st
> goto out_put_req;
>
> spin_lock_irq(&ctx->ctx_lock);
> + /*
> + * Hold an extra reference while submitting the i/o.
> + * This prevents races between the aio code path referencing the
> + * req (after submitting it) and aio_complete() freeing the req.
> + */
> + req->ki_users++; /* grab extra reference */
> ret = aio_run_iocb(req);
> + (void)__aio_put_req(ctx, req); /* drop the extra reference */
I haven't looked very closely, but am just wondering why you ignore
the return value of __aio_put_req here - are you sure there is no
potential memory leakage (could be missing a put_ioctx) as a result ?
> spin_unlock_irq(&ctx->ctx_lock);
>
> if (-EIOCBRETRY == ret)
Although this isn't a problem with retry-based AIO (where we always
call aio_complete() from the calling routine, so should never see
the iocb going away underneath us), if we do add the ref count
increment, we should probably try to do it for both the initial
submission and subsequent retries --- just in case we have code
(in future) that uses a combination of retries and aio completion
from interrupt context.
Regards
Suparna
--
Suparna Bhattacharya (suparna@in.ibm.com)
Linux Technology Center
IBM Software Labs, India
next prev parent reply other threads:[~2003-10-01 8:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-26 17:06 slab corruption on AIO 2.6.0-test5-mm4 Daniel McNeil
2003-09-26 23:59 ` Daniel McNeil
2003-09-29 4:09 ` Suparna Bhattacharya
[not found] ` <20030929131057.GA4630@in.ibm.com>
[not found] ` <1064876358.23108.41.camel@ibm-c.pdx.osdl.net>
[not found] ` <20030930040020.GA3435@in.ibm.com>
2003-09-30 23:22 ` [PATCH 2.6.0-test6-mm1] aio ref count in io_submit_one Daniel McNeil
2003-10-01 8:46 ` Suparna Bhattacharya [this message]
2003-10-01 20:51 ` [PATCH 2.6.0-test6-mm1] aio ref count in io_submit_one updated Daniel McNeil
2003-10-03 21:19 ` PATCH 2.6.0-test6-mm2] aio ref count during retry Daniel McNeil
2003-10-03 21:40 ` Andrew Morton
2003-10-03 22:00 ` Daniel McNeil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031001084639.GA4188@in.ibm.com \
--to=suparna@in.ibm.com \
--cc=akpm@osdl.org \
--cc=daniel@osdl.org \
--cc=linux-aio@kvack.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox