aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-02-20 17:04:42 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-12 00:41:50 -0500
commit9bdd39c146fc4f7da1ceb91ac1ebe80e7f1a8d41 (patch)
treef8f9d7903d9e684ec3c17519253031d9e3f0111e /fs
parent5af94e637fd8b2b89ea49bfd112b37137fbecb0e (diff)
nfsd: minor nfsd_setattr cleanup
commit 758e99fefe1d9230111296956335cd35995c0eaf upstream. Simplify exit paths, size_change use. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/vfs.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 8ca642fe9b21..186f426a3699 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -377,7 +377,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
377 __be32 err; 377 __be32 err;
378 int host_err; 378 int host_err;
379 bool get_write_count; 379 bool get_write_count;
380 int size_change = 0; 380 bool size_change = (iap->ia_valid & ATTR_SIZE);
381 381
382 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE)) 382 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
383 accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE; 383 accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
@@ -390,11 +390,11 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
390 /* Get inode */ 390 /* Get inode */
391 err = fh_verify(rqstp, fhp, ftype, accmode); 391 err = fh_verify(rqstp, fhp, ftype, accmode);
392 if (err) 392 if (err)
393 goto out; 393 return err;
394 if (get_write_count) { 394 if (get_write_count) {
395 host_err = fh_want_write(fhp); 395 host_err = fh_want_write(fhp);
396 if (host_err) 396 if (host_err)
397 return nfserrno(host_err); 397 goto out;
398 } 398 }
399 399
400 dentry = fhp->fh_dentry; 400 dentry = fhp->fh_dentry;
@@ -405,19 +405,21 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
405 iap->ia_valid &= ~ATTR_MODE; 405 iap->ia_valid &= ~ATTR_MODE;
406 406
407 if (!iap->ia_valid) 407 if (!iap->ia_valid)
408 goto out; 408 return 0;
409 409
410 nfsd_sanitize_attrs(inode, iap); 410 nfsd_sanitize_attrs(inode, iap);
411 411
412 if (check_guard && guardtime != inode->i_ctime.tv_sec)
413 return nfserr_notsync;
414
412 /* 415 /*
413 * The size case is special, it changes the file in addition to the 416 * The size case is special, it changes the file in addition to the
414 * attributes. 417 * attributes.
415 */ 418 */
416 if (iap->ia_valid & ATTR_SIZE) { 419 if (size_change) {
417 err = nfsd_get_write_access(rqstp, fhp, iap); 420 err = nfsd_get_write_access(rqstp, fhp, iap);
418 if (err) 421 if (err)
419 goto out; 422 return err;
420 size_change = 1;
421 423
422 /* 424 /*
423 * RFC5661, Section 18.30.4: 425 * RFC5661, Section 18.30.4:
@@ -432,23 +434,16 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
432 434
433 iap->ia_valid |= ATTR_CTIME; 435 iap->ia_valid |= ATTR_CTIME;
434 436
435 if (check_guard && guardtime != inode->i_ctime.tv_sec) {
436 err = nfserr_notsync;
437 goto out_put_write_access;
438 }
439
440 fh_lock(fhp); 437 fh_lock(fhp);
441 host_err = notify_change(dentry, iap, NULL); 438 host_err = notify_change(dentry, iap, NULL);
442 fh_unlock(fhp); 439 fh_unlock(fhp);
443 err = nfserrno(host_err);
444 440
445out_put_write_access:
446 if (size_change) 441 if (size_change)
447 put_write_access(inode); 442 put_write_access(inode);
448 if (!err)
449 err = nfserrno(commit_metadata(fhp));
450out: 443out:
451 return err; 444 if (!host_err)
445 host_err = commit_metadata(fhp);
446 return nfserrno(host_err);
452} 447}
453 448
454#if defined(CONFIG_NFSD_V4) 449#if defined(CONFIG_NFSD_V4)