linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] dio: track and serialise unaligned direct IO
Date: Tue, 9 Nov 2010 09:55:48 +1100	[thread overview]
Message-ID: <20101108225548.GR2715@dastard> (raw)
In-Reply-To: <x4962w7al7m.fsf@segfault.boston.devel.redhat.com>

On Mon, Nov 08, 2010 at 10:28:29AM -0500, Jeff Moyer wrote:
> Dave Chinner <david@fromorbit.com> writes:
> 
> > +struct dio_zero_block {
> > +	struct list_head dio_list;	/* list of io in progress */
> > +	sector_t	zero_block;	/* block being zeroed */
> > +	struct dio	*dio;		/* owner dio */
> > +	wait_queue_head_t wq;		/* New IO block here */
>                       New IOs block here, or new IO blocks here?
> 
> > +/*
> > + * Add a filesystem block to the list of blocks we are tracking.
> > + */
> > +static void
> > +dio_start_zero_block(struct dio *dio, sector_t zero_block)
> > +{
> > +	struct dio_zero_block *zb;
> > +
> > +	zb = kmalloc(sizeof(*zb), GFP_NOIO);
> > +	if (!zb)
> > +		return;
> > +	INIT_LIST_HEAD(&zb->dio_list);
> > +	init_waitqueue_head(&zb->wq);
> > +	zb->zero_block = zero_block;
> > +	zb->dio = dio;
> > +	atomic_set(&zb->ref, 1);
> > +
> > +	spin_lock(&dio_zero_block_lock);
> > +	list_add(&zb->dio_list, &dio_zero_block_list);
> > +	spin_unlock(&dio_zero_block_lock);
> 
> What protects from two processes getting here at the same time, and
> hence adding the same block to the list?  i_mutex?

The wait in dio_zero_block() called before this function is called is
supposed to serialise them, but now that you point it out, it's not
an atomic wait-and-add so ther eis a small window where two IOs
could pass through here. Easy enoug to fix by combining the search
and inѕert - I'll restructure it along those lines.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2010-11-08 22:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-08  7:40 [REPOST, PATCH 0/3] dio: serialise unaligned direct IO Dave Chinner
2010-11-08  7:40 ` [PATCH 1/3] dio: track and " Dave Chinner
2010-11-08 15:28   ` Jeff Moyer
2010-11-08 22:55     ` Dave Chinner [this message]
2010-11-08  7:40 ` [PATCH 2/3] dio: scale unaligned IO tracking via multiple lists Dave Chinner
2010-11-08 15:36   ` Jeff Moyer
2010-11-08 23:12     ` Dave Chinner
2010-11-09 21:04       ` Jeff Moyer
2010-11-09 23:06         ` Dave Chinner
2010-11-11 15:32           ` Jeff Moyer
2010-11-08  7:40 ` [PATCH 3/3] dio: add a mempool for the unaligned block structures Dave Chinner
2010-11-08 15:40   ` Jeff Moyer
  -- strict thread matches above, loose matches on Subject: below --
2010-08-03  7:23 [PATCH 0/3] dio: serialise unaligned direct IO V3 Dave Chinner
2010-08-03  7:23 ` [PATCH 1/3] dio: track and serialise unaligned direct IO Dave Chinner

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=20101108225548.GR2715@dastard \
    --to=david@fromorbit.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).