linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfsd: don't get write access twіce in nfsd_setattr
@ 2017-02-07  9:12 Christoph Hellwig
  2017-02-08 21:45 ` J. Bruce Fields
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2017-02-07  9:12 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-nfs

Turns out doing mnt_want_write twice for the same process makes
lockdep unhappy, so move the fh_want_write down to after calling
vfs_truncate in nfsd_setattr.  No changes to error handling required
as the want write state is automatically cleaned up by the caller
based on a flag in the svc_fh.

Fixes: 41f53350 ("nfsd: special case truncates some more")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Dave Jones <davej@codemonkey.org.uk>

diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index ca13236dbb1f..a974368026a1 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -359,11 +359,6 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 	err = fh_verify(rqstp, fhp, ftype, accmode);
 	if (err)
 		return err;
-	if (get_write_count) {
-		host_err = fh_want_write(fhp);
-		if (host_err)
-			goto out_host_err;
-	}
 
 	dentry = fhp->fh_dentry;
 	inode = d_inode(dentry);
@@ -416,6 +411,12 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
 
 	iap->ia_valid |= ATTR_CTIME;
 
+	if (get_write_count) {
+		host_err = fh_want_write(fhp);
+		if (host_err)
+			goto out_host_err;
+	}
+
 	fh_lock(fhp);
 	host_err = notify_change(dentry, iap, NULL);
 	fh_unlock(fhp);

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
  2017-02-07  9:12 [PATCH] nfsd: don't get write access twіce in nfsd_setattr Christoph Hellwig
@ 2017-02-08 21:45 ` J. Bruce Fields
  2017-02-08 21:50   ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: J. Bruce Fields @ 2017-02-08 21:45 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-nfs

On Tue, Feb 07, 2017 at 10:12:44AM +0100, Christoph Hellwig wrote:
> Turns out doing mnt_want_write twice for the same process makes
> lockdep unhappy, so move the fh_want_write down to after calling
> vfs_truncate in nfsd_setattr.  No changes to error handling required
> as the want write state is automatically cleaned up by the caller
> based on a flag in the svc_fh.
> 
> Fixes: 41f53350 ("nfsd: special case truncates some more")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reported-by: Dave Jones <davej@codemonkey.org.uk>

Thanks, I'll see if I can squeeze this into 4.10.--b.

> 
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index ca13236dbb1f..a974368026a1 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -359,11 +359,6 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
>  	err = fh_verify(rqstp, fhp, ftype, accmode);
>  	if (err)
>  		return err;
> -	if (get_write_count) {
> -		host_err = fh_want_write(fhp);
> -		if (host_err)
> -			goto out_host_err;
> -	}
>  
>  	dentry = fhp->fh_dentry;
>  	inode = d_inode(dentry);
> @@ -416,6 +411,12 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
>  
>  	iap->ia_valid |= ATTR_CTIME;
>  
> +	if (get_write_count) {
> +		host_err = fh_want_write(fhp);
> +		if (host_err)
> +			goto out_host_err;
> +	}
> +
>  	fh_lock(fhp);
>  	host_err = notify_change(dentry, iap, NULL);
>  	fh_unlock(fhp);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
  2017-02-08 21:45 ` J. Bruce Fields
@ 2017-02-08 21:50   ` Christoph Hellwig
  2017-02-08 21:51     ` J. Bruce Fields
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2017-02-08 21:50 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Christoph Hellwig, linux-nfs

On Wed, Feb 08, 2017 at 04:45:38PM -0500, J. Bruce Fields wrote:
> On Tue, Feb 07, 2017 at 10:12:44AM +0100, Christoph Hellwig wrote:
> > Turns out doing mnt_want_write twice for the same process makes
> > lockdep unhappy, so move the fh_want_write down to after calling
> > vfs_truncate in nfsd_setattr.  No changes to error handling required
> > as the want write state is automatically cleaned up by the caller
> > based on a flag in the svc_fh.
> > 
> > Fixes: 41f53350 ("nfsd: special case truncates some more")
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > Reported-by: Dave Jones <davej@codemonkey.org.uk>
> 
> Thanks, I'll see if I can squeeze this into 4.10.--b.

FYI, Chuck just reported another issue, let's wait for that for now.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
  2017-02-08 21:50   ` Christoph Hellwig
@ 2017-02-08 21:51     ` J. Bruce Fields
  2017-02-09 13:25       ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: J. Bruce Fields @ 2017-02-08 21:51 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-nfs

On Wed, Feb 08, 2017 at 10:50:38PM +0100, Christoph Hellwig wrote:
> On Wed, Feb 08, 2017 at 04:45:38PM -0500, J. Bruce Fields wrote:
> > On Tue, Feb 07, 2017 at 10:12:44AM +0100, Christoph Hellwig wrote:
> > > Turns out doing mnt_want_write twice for the same process makes
> > > lockdep unhappy, so move the fh_want_write down to after calling
> > > vfs_truncate in nfsd_setattr.  No changes to error handling required
> > > as the want write state is automatically cleaned up by the caller
> > > based on a flag in the svc_fh.
> > > 
> > > Fixes: 41f53350 ("nfsd: special case truncates some more")
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > > Reported-by: Dave Jones <davej@codemonkey.org.uk>
> > 
> > Thanks, I'll see if I can squeeze this into 4.10.--b.
> 
> FYI, Chuck just reported another issue, let's wait for that for now.

OK.--b.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
  2017-02-08 21:51     ` J. Bruce Fields
@ 2017-02-09 13:25       ` Christoph Hellwig
  2017-02-09 15:43         ` J. Bruce Fields
  0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2017-02-09 13:25 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: linux-nfs

On Wed, Feb 08, 2017 at 04:51:01PM -0500, J. Bruce Fields wrote:
> > FYI, Chuck just reported another issue, let's wait for that for now.

I can't really reproduce the issue Chuck reported.  So let's get this
fixup in for now, especially as Linus replied to the thread it was
reported in and asked for it.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
  2017-02-09 13:25       ` Christoph Hellwig
@ 2017-02-09 15:43         ` J. Bruce Fields
  2017-02-09 15:46           ` Christoph Hellwig
  0 siblings, 1 reply; 7+ messages in thread
From: J. Bruce Fields @ 2017-02-09 15:43 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-nfs

On Thu, Feb 09, 2017 at 02:25:16PM +0100, Christoph Hellwig wrote:
> On Wed, Feb 08, 2017 at 04:51:01PM -0500, J. Bruce Fields wrote:
> > > FYI, Chuck just reported another issue, let's wait for that for now.
> 
> I can't really reproduce the issue Chuck reported.  So let's get this
> fixup in for now, especially as Linus replied to the thread it was
> reported in and asked for it.

I can't find that reply--am I missing a thread?

OK, so for 4.10 I have:

	nfsd: don't get write access twice in nfsd_setattr
	nfsd: restore owner override for truncate

--b.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
  2017-02-09 15:43         ` J. Bruce Fields
@ 2017-02-09 15:46           ` Christoph Hellwig
  0 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2017-02-09 15:46 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Christoph Hellwig, linux-nfs

On Thu, Feb 09, 2017 at 10:43:07AM -0500, J. Bruce Fields wrote:
> On Thu, Feb 09, 2017 at 02:25:16PM +0100, Christoph Hellwig wrote:
> > On Wed, Feb 08, 2017 at 04:51:01PM -0500, J. Bruce Fields wrote:
> > > > FYI, Chuck just reported another issue, let's wait for that for now.
> > 
> > I can't really reproduce the issue Chuck reported.  So let's get this
> > fixup in for now, especially as Linus replied to the thread it was
> > reported in and asked for it.
> 
> I can't find that reply--am I missing a thread?

Dave reported it in reply to Linus' 4.10-rc7 announcement.
Looks like neither you nor linux-nfs were Cc'ed on that.

> OK, so for 4.10 I have:
> 
> 	nfsd: don't get write access twice in nfsd_setattr
> 	nfsd: restore owner override for truncate

Yepp.  Sorry for the mess.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-02-09 15:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-07  9:12 [PATCH] nfsd: don't get write access twіce in nfsd_setattr Christoph Hellwig
2017-02-08 21:45 ` J. Bruce Fields
2017-02-08 21:50   ` Christoph Hellwig
2017-02-08 21:51     ` J. Bruce Fields
2017-02-09 13:25       ` Christoph Hellwig
2017-02-09 15:43         ` J. Bruce Fields
2017-02-09 15:46           ` Christoph Hellwig

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).