nfsd: don't get write access twіce in nfsd_setattr
Subsystems (2)
PATCH 1/1 nfsd: don't get write access twіce in nfsd_setattr
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.
fs/nfsd/vfs.c +6 -5
@@ -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);
Quoted 7 lines · J. Bruce Fields
Quoted 6 lines · Christoph Hellwig
Turns out doing
mnt_want_writetwice for the same process makes lockdep unhappy, so move thefh_want_writedown to after callingvfs_truncateinnfsd_setattr. No changes to error handling required as the want write state is automatically cleaned up by the caller based on a flag in thesvc_fh.
Quoted 5 lines
Quoted 3 lines
Fixes 41f53350 ("nfsd: special case truncates some more")Signed-off-by Christoph Hellwig <[email protected]>Reported-by Dave Jones <[email protected]>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.
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · J. Bruce Fields
Quoted 6 lines · Christoph Hellwig
Turns out doing
mnt_want_writetwice for the same process makes lockdep unhappy, so move thefh_want_writedown to after callingvfs_truncateinnfsd_setattr. No changes to error handling required as the want write state is automatically cleaned up by the caller based on a flag in thesvc_fh.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes 41f53350 ("nfsd: special case truncates some more")Signed-off-by Christoph Hellwig <[email protected]>Reported-by Dave Jones <[email protected]>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.
Quoted 9 lines · Christoph Hellwig
Turns out doing
mnt_want_writetwice for the same process makes lockdep unhappy, so move thefh_want_writedown to after callingvfs_truncateinnfsd_setattr. No changes to error handling required as the want write state is automatically cleaned up by the caller based on a flag in thesvc_fh.Fixes 41f53350 ("nfsd: special case truncates some more")Signed-off-by Christoph Hellwig <[email protected]>Reported-by Dave Jones <[email protected]>
Thanks, I'll see if I can squeeze this into 4.10.--b.
Quoted 30 lines
fs/nfsd/vfs.c +6
-5@@ -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);
Quoted 1 line · J. Bruce Fields
Quoted 1 line
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.
Quoted 9 lines · J. Bruce Fields
Quoted 6 lines · Christoph Hellwig
Quoted 1 line · J. Bruce Fields
Quoted 1 line
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.
Quoted 4 lines
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.
Quoted 6 lines · Christoph Hellwig
Quoted 1 line · J. Bruce Fields
Quoted 1 line
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.