mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel McNeil <daniel@osdl.org>
To: Suparna Bhattacharya <suparna@in.ibm.com>
Cc: Andrew Morton <akpm@osdl.org>,
	"linux-aio@kvack.org" <linux-aio@kvack.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: PATCH 2.6.0-test6-mm2] aio ref count during retry
Date: 03 Oct 2003 14:19:06 -0700	[thread overview]
Message-ID: <1065215946.1862.164.camel@ibm-c.pdx.osdl.net> (raw)
In-Reply-To: <20031001084639.GA4188@in.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 1314 bytes --]

On Wed, 2003-10-01 at 01:46, Suparna Bhattacharya wrote:
> 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

Andrew and Suparna,


Here is the patch for AIO retry to hold an extra ref count.
The patch is small, but I wanted to make sure it was safe.
I spent time looking over the retry code and this patch looks
ok to me.  It is potentially calling put_ioctx() while holding
ctx->ctx_lock, I do not think that will cause any problems.
This should never be the last reference on the ioctx anyway,
since the loop is checking list_empty(&ctx->run_list).  The
first ref is taken in sys_io_setup() and last removed in
io_destroy(). It also looks like holding ctx->ctx_lock prevents
any races between any retries and an io_destroy() which would
try to cancel all iocbs.

I've tested this on my 2-proc by coping a raw partitions and
copying ext3 files using using AIO and O_DIRECT, O_SYNC, and both.

Thoughts?

Daniel

[-- Attachment #2: 2.6.0-test6-mm2.aio_retry_ref_count.patch --]
[-- Type: text/plain, Size: 704 bytes --]

--- linux-2.6.0-test6-mm2/fs/aio.c	2003-10-03 10:45:39.000000000 -0700
+++ linux-2.6.0-test6-mm2.aio/fs/aio.c	2003-10-03 11:26:26.894495149 -0700
@@ -771,12 +771,20 @@ static void __aio_run_iocbs(struct kioct
 	struct kiocb *iocb;
 	ssize_t ret;
 	int count = 0;
+	int need_putctx;
 
 	while (!list_empty(&ctx->run_list)) {
 		iocb = list_entry(ctx->run_list.next, struct kiocb,
 			ki_run_list);
 		list_del(&iocb->ki_run_list);
+		/*
+		 * Hold an extra reference while retrying i/o.
+		 */
+		iocb->ki_users++;	/* grab extra reference */
 		ret = aio_run_iocb(iocb);
+		need_putctx = __aio_put_req(ctx, iocb);  /* drop extra ref */
+		if (need_putctx)
+			put_ioctx(ctx);
 		count++;
 	}
 	aio_run++;

  parent reply	other threads:[~2003-10-03 21:19 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
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               ` Daniel McNeil [this message]
2003-10-03 21:40                 ` PATCH 2.6.0-test6-mm2] aio ref count during retry 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=1065215946.1862.164.camel@ibm-c.pdx.osdl.net \
    --to=daniel@osdl.org \
    --cc=akpm@osdl.org \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suparna@in.ibm.com \
    /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

all inboxes | Powered by JetHome®