linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "J. Bruce Fields" <bfields@redhat.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>,
	David Howells <dhowells@redhat.com>,
	Tyler Hicks <tyhicks@canonical.com>,
	Dustin Kirkland <dustin.kirkland@gazzang.com>
Subject: Re: [PATCH 12/12] locks: break delegations on any attribute modification
Date: Wed, 10 Jul 2013 15:33:30 -0400	[thread overview]
Message-ID: <20130710193330.GA24548@pad.fieldses.org> (raw)
In-Reply-To: <20130709212625.7fdfc6e1@corrin.poochiereds.net>

On Tue, Jul 09, 2013 at 09:26:25PM -0400, Jeff Layton wrote:
> On Tue, 9 Jul 2013 17:19:12 -0400
> "J. Bruce Fields" <bfields@redhat.com> wrote:
> 
> > On Tue, Jul 09, 2013 at 04:51:01PM -0400, J. Bruce Fields wrote:
> > > On Tue, Jul 09, 2013 at 09:30:47AM -0400, Jeff Layton wrote:
> > > > On Wed,  3 Jul 2013 16:12:36 -0400
> > > > "J. Bruce Fields" <bfields@redhat.com> wrote:
> > > > 
> > > > > From: "J. Bruce Fields" <bfields@redhat.com>
> > > > > 
> > > > > NFSv4 uses leases to guarantee that clients can cache metadata as well
> > > > > as data.
> > > > > 
> > ...
> > > > Isn't it possible we'll need to break a delegation on truncate()?
> > > 
> > > In the truncate case, the caller called break_lease, and in the
> > > ftruncate case it's called with a write open, and the open already broke
> > > any leases or delegations.
> > > 
> > > Might need a comment--could I get away with just this?:
> > > 
> > >  	mutex_lock(&dentry->d_inode->i_mutex);
> > > +	/* NULL is safe: any delegations have already been broken: */
> > >  	ret = notify_change(dentry, &newattrs, NULL);
> > >  	mutex_unlock(&dentry->d_inode->i_mutex);
> > >  	return ret;
> > > 
> > > I also added something to the notify_change kerneldoc: "passing NULL is
> > > fine for callers holding the file open for write, as there can be no
> > > conflicting delegation in that case."
> > 
> > Another question is whether it's really worth dropping locks and
> > retrying in this case.
> > 
> > We could instead do the following.
> > 
> > --b.
> > 
> > commit 40a4fd613034cd3f242ec11e5ecd44f9a83ab39d
> > Author: J. Bruce Fields <bfields@redhat.com>
> > Date:   Tue Sep 20 17:19:26 2011 -0400
> > 
> >     locks: break delegations on any attribute modification
> >     
> >     NFSv4 uses leases to guarantee that clients can cache metadata as well
> >     as data.
> >     
> >     Note unlike link, unlink, and rename, we don't bother dropping locks and
> >     retrying.  In the other cases we're holding a directory mutex, hence
> >     blocking operations (even lookups) on the same directory.  In this case
> >     we're holding only the i_mutex on this file, so the impact of an
> >     unresponsive client is limited to this file.
> >     
> >     Signed-off-by: J. Bruce Fields <bfields@redhat.com>
> > 
> > diff --git a/fs/attr.c b/fs/attr.c
> > index 1449adb..a2c1d04 100644
> > --- a/fs/attr.c
> > +++ b/fs/attr.c
> > @@ -243,6 +243,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
> >  	error = security_inode_setattr(dentry, attr);
> >  	if (error)
> >  		return error;
> > +	error = break_deleg_wait(inode);
> > +	if (error)
> > +		return error;
> >  
> >  	if (inode->i_op->setattr)
> >  		error = inode->i_op->setattr(dentry, attr);
> 
> 
> I guess the question is whether there are operations that require the
> i_mutex but that don't require the delegation recall to have finished.

Also if there's any risk that something on the delegation-return path
might take the i_mutex then we'd risk blocking the client's attempt to
return until the delegation timed out and got revoked.

In fact a CLAIM_DELEG_CUR open needs a lookup so probably runs into
exactly that problem.  OK, back to the more complicated solution.

--b.

  reply	other threads:[~2013-07-10 19:33 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-03 20:12 [PATCH 00/12] Implement NFSv4 delegations, take 8 J. Bruce Fields
2013-07-03 20:12 ` [PATCH 01/12] vfs: pull ext4's double-i_mutex-locking into common code J. Bruce Fields
2013-07-09 10:49   ` Jeff Layton
2013-07-09 15:48     ` Theodore Ts'o
2013-07-09 22:04   ` Dave Chinner
2013-07-10  0:21     ` J. Bruce Fields
2013-07-10  2:09       ` Dave Chinner
2013-07-10  2:40         ` J. Bruce Fields
2013-07-10  3:38           ` Dave Chinner
2013-07-10 21:26             ` J. Bruce Fields
2013-07-11 14:04               ` Jeff Layton
2013-07-12 22:07                 ` J. Bruce Fields
2013-07-03 20:12 ` [PATCH 02/12] vfs: don't use PARENT/CHILD lock classes for non-directories J. Bruce Fields
2013-07-09 10:50   ` Jeff Layton
2013-07-03 20:12 ` [PATCH 03/12] vfs: rename I_MUTEX_QUOTA now that it's not used for quotas J. Bruce Fields
2013-07-09 10:54   ` Jeff Layton
2013-07-09 14:26     ` J. Bruce Fields
2013-07-09 14:31       ` Jeff Layton
2013-07-03 20:12 ` [PATCH 04/12] vfs: take i_mutex on renamed file J. Bruce Fields
2013-07-09 10:59   ` Jeff Layton
2013-07-03 20:12 ` [PATCH 05/12] locks: introduce new FL_DELEG lock flag J. Bruce Fields
2013-07-09 11:00   ` Jeff Layton
2013-07-03 20:12 ` [PATCH 06/12] locks: implement delegations J. Bruce Fields
2013-07-09 12:23   ` Jeff Layton
2013-07-09 14:41     ` J. Bruce Fields
2013-07-03 20:12 ` [PATCH 07/12] namei: minor vfs_unlink cleanup J. Bruce Fields
2013-07-09 12:50   ` Jeff Layton
2013-07-03 20:12 ` [PATCH 08/12] locks: break delegations on unlink J. Bruce Fields
2013-07-09 13:05   ` Jeff Layton
2013-07-09 13:07     ` Jeff Layton
2013-07-09 15:58     ` J. Bruce Fields
2013-07-09 16:02       ` Jeff Layton
2013-07-09 19:29     ` J. Bruce Fields
2013-07-03 20:12 ` [PATCH 09/12] locks: helper functions for delegation breaking J. Bruce Fields
2013-07-09 13:09   ` Jeff Layton
2013-07-09 19:31     ` J. Bruce Fields
2013-07-09 19:37       ` Jeff Layton
2013-07-09 13:23   ` Jeff Layton
2013-07-09 19:38     ` J. Bruce Fields
2013-07-09 20:28       ` Jeff Layton
2013-07-03 20:12 ` [PATCH 10/12] locks: break delegations on rename J. Bruce Fields
2013-07-09 13:14   ` Jeff Layton
2013-07-03 20:12 ` [PATCH 11/12] locks: break delegations on link J. Bruce Fields
2013-07-09 13:16   ` Jeff Layton
2013-07-09 20:41     ` J. Bruce Fields
2013-07-03 20:12 ` [PATCH 12/12] locks: break delegations on any attribute modification J. Bruce Fields
2013-07-09 13:30   ` Jeff Layton
2013-07-09 20:51     ` J. Bruce Fields
2013-07-09 21:19       ` J. Bruce Fields
2013-07-10  1:26         ` Jeff Layton
2013-07-10 19:33           ` J. Bruce Fields [this message]
2013-07-09 23:57       ` Jeff Layton
  -- strict thread matches above, loose matches on Subject: below --
2013-09-05 16:30 [PATCH 00/12] Implement NFSv4 delegations, take 10 J. Bruce Fields
2013-09-05 16:30 ` [PATCH 12/12] locks: break delegations on any attribute modification J. Bruce Fields
2013-04-17  1:46 [PATCH 00/12] Implement NFSv4 delegations, take 7 J. Bruce Fields
2013-04-17  1:46 ` [PATCH 12/12] locks: break delegations on any attribute modification J. Bruce Fields
2013-02-03 16:31 [PATCH 00/12] Implement NFSv4 delegations, take 6 J. Bruce Fields
2013-02-03 16:31 ` [PATCH 12/12] locks: break delegations on any attribute modification J. Bruce Fields
2012-10-16 22:01 [PATCH 00/12] Implement NFSv4 delegations, take 5 J. Bruce Fields
2012-10-16 22:01 ` [PATCH 12/12] locks: break delegations on any attribute modification J. Bruce Fields

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=20130710193330.GA24548@pad.fieldses.org \
    --to=bfields@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=dustin.kirkland@gazzang.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=tyhicks@canonical.com \
    --cc=viro@zeniv.linux.org.uk \
    /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).