From: Christoph Hellwig <hch@lst.de>
To: "J. Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH] nfsd: don't get write access twіce in nfsd_setattr
Date: Tue, 7 Feb 2017 10:12:44 +0100 [thread overview]
Message-ID: <20170207091244.GA14911@lst.de> (raw)
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);
next reply other threads:[~2017-02-07 9:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 9:12 Christoph Hellwig [this message]
2017-02-08 21:45 ` [PATCH] nfsd: don't get write access twіce in nfsd_setattr 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
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=20170207091244.GA14911@lst.de \
--to=hch@lst.de \
--cc=bfields@fieldses.org \
--cc=linux-nfs@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).