diff options
author | Christoph Hellwig <hch@infradead.org> | 2013-11-18 08:07:47 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2013-11-18 12:06:48 -0500 |
commit | 987da4791052fa298b7cfcde4dea9f6f2bbc786b (patch) | |
tree | 8a469919f3990db2f496db44cb6a3d36d32569c4 /fs | |
parent | 818e5a22e907fbae75e9c1fd78233baec9fa64b6 (diff) |
nfsd: make sure to balance get/put_write_access
Use a straight goto error label style in nfsd_setattr to make sure
we always do the put_write_access call after we got it earlier.
Note that the we have been failing to do that in the case
nfsd_break_lease() returns an error, a bug introduced into 2.6.38 with
6a76bebefe15d9a08864f824d7f8d5beaf37c997 "nfsd4: break lease on nfsd
setattr".
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/vfs.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index c3f57cf14a63..7eea63cada1d 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -444,27 +444,28 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap, | |||
444 | 444 | ||
445 | iap->ia_valid |= ATTR_CTIME; | 445 | iap->ia_valid |= ATTR_CTIME; |
446 | 446 | ||
447 | err = nfserr_notsync; | 447 | if (check_guard && guardtime != inode->i_ctime.tv_sec) { |
448 | if (!check_guard || guardtime == inode->i_ctime.tv_sec) { | 448 | err = nfserr_notsync; |
449 | host_err = nfsd_break_lease(inode); | 449 | goto out_put_write_access; |
450 | if (host_err) | ||
451 | goto out_nfserr; | ||
452 | fh_lock(fhp); | ||
453 | |||
454 | host_err = notify_change(dentry, iap, NULL); | ||
455 | err = nfserrno(host_err); | ||
456 | fh_unlock(fhp); | ||
457 | } | 450 | } |
451 | |||
452 | host_err = nfsd_break_lease(inode); | ||
453 | if (host_err) | ||
454 | goto out_put_write_access_nfserror; | ||
455 | |||
456 | fh_lock(fhp); | ||
457 | host_err = notify_change(dentry, iap, NULL); | ||
458 | fh_unlock(fhp); | ||
459 | |||
460 | out_put_write_access_nfserror: | ||
461 | err = nfserrno(host_err); | ||
462 | out_put_write_access: | ||
458 | if (size_change) | 463 | if (size_change) |
459 | put_write_access(inode); | 464 | put_write_access(inode); |
460 | if (!err) | 465 | if (!err) |
461 | commit_metadata(fhp); | 466 | commit_metadata(fhp); |
462 | out: | 467 | out: |
463 | return err; | 468 | return err; |
464 | |||
465 | out_nfserr: | ||
466 | err = nfserrno(host_err); | ||
467 | goto out; | ||
468 | } | 469 | } |
469 | 470 | ||
470 | #if defined(CONFIG_NFSD_V2_ACL) || \ | 471 | #if defined(CONFIG_NFSD_V2_ACL) || \ |