public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Zheng Da <zhengda1936@gmail.com>, xfs@oss.sgi.com
Subject: Re: concurrent direct IO write in xfs
Date: Tue, 14 Feb 2012 10:07:31 +1100	[thread overview]
Message-ID: <20120213230731.GB14132@dastard> (raw)
In-Reply-To: <20120213174806.GA7630@infradead.org>

On Mon, Feb 13, 2012 at 12:48:06PM -0500, Christoph Hellwig wrote:
> On Thu, Feb 09, 2012 at 05:09:20PM +1100, Dave Chinner wrote:
> >  	if (create) {
> > -		lockmode = XFS_ILOCK_EXCL;
> > +		/*
> > +		 * For direct IO, we lock in shared mode so that write
> > +		 * operations that don't require allocation can occur
> > +		 * concurrently. The ilock has to be dropped over the allocation
> > +		 * transaction reservation, so the only thing the ilock is
> > +		 * providing here is modification exclusion. i.e. there is no
> > +		 * need to hold the lock exclusive.
> > +		 *
> > +		 * For buffered IO, if we need to do delayed allocation then
> > +		 * hold the ilock exclusive so that the lookup and delalloc
> > +		 * reservation is atomic.
> > +		 */
> > +		if (direct)
> > +			lockmode = XFS_ILOCK_SHARED;
> > +		else
> > +			lockmode = XFS_ILOCK_EXCL;
> >  		xfs_ilock(ip, lockmode);
> >  	} else {
> >  		lockmode = xfs_ilock_map_shared(ip);
> 
> We'll actually need to use xfs_ilock_map_shared for the the direct
> create case too, to make sure we have the exclusive lock when we first
> read the extent list in.

Good point.

> Also xfs_qm_dqattach_locked really wants the inode locked exclusively,
> which your current code doesn't handle.

I didn't consider quotas. Looking at the code, it seems that it
wants an exclusive lock purely for ensuring there are no races
attaching the dquots to the inode. The xfs_dqget() code can actually
drop and regain the ilock, so I can't see that it is for any other
specific purpose.

I think that we could probably attach the dquot after dropping the
shared lock but before starting the transaction via a call to
xfs_qm_dqattach() which handles the locking internally. It does mean
an extra lock traversal for the quota case, but it still allows the
initial mapping to be done with a shared lock....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

      reply	other threads:[~2012-02-13 23:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-16  0:01 concurrent direct IO write in xfs Zheng Da
2012-01-16 17:48 ` Christoph Hellwig
2012-01-16 19:44   ` Zheng Da
2012-01-16 23:25 ` Dave Chinner
2012-01-17 19:19   ` Zheng Da
2012-01-20  8:53     ` Linda Walsh
2012-01-20 15:07       ` Zheng Da
2012-01-23  5:11     ` Dave Chinner
2012-01-23 19:34       ` Zheng Da
2012-01-23 20:51         ` Zheng Da
2012-01-24  0:34           ` Stan Hoeppner
2012-01-24  1:40             ` Zheng Da
2012-01-24  3:54           ` Dave Chinner
2012-01-25 21:20             ` Zheng Da
2012-01-25 22:25               ` Dave Chinner
2012-02-09  6:09             ` Dave Chinner
2012-02-09  6:44               ` Zheng Da
2012-02-13 17:48               ` Christoph Hellwig
2012-02-13 23:07                 ` Dave Chinner [this message]

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=20120213230731.GB14132@dastard \
    --to=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=xfs@oss.sgi.com \
    --cc=zhengda1936@gmail.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