mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
nfsd: minor nfsd_setattr cleanup
commit 758e99fefe 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>
This commit is contained in:
committed by
popcornmix
parent
b70098f9db
commit
65ff45b33c
@@ -377,7 +377,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
__be32 err;
|
__be32 err;
|
||||||
int host_err;
|
int host_err;
|
||||||
bool get_write_count;
|
bool get_write_count;
|
||||||
int size_change = 0;
|
bool size_change = (iap->ia_valid & ATTR_SIZE);
|
||||||
|
|
||||||
if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
|
if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE))
|
||||||
accmode |= NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE;
|
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,
|
|||||||
/* Get inode */
|
/* Get inode */
|
||||||
err = fh_verify(rqstp, fhp, ftype, accmode);
|
err = fh_verify(rqstp, fhp, ftype, accmode);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
return err;
|
||||||
if (get_write_count) {
|
if (get_write_count) {
|
||||||
host_err = fh_want_write(fhp);
|
host_err = fh_want_write(fhp);
|
||||||
if (host_err)
|
if (host_err)
|
||||||
return nfserrno(host_err);
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dentry = fhp->fh_dentry;
|
dentry = fhp->fh_dentry;
|
||||||
@@ -405,19 +405,21 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
iap->ia_valid &= ~ATTR_MODE;
|
iap->ia_valid &= ~ATTR_MODE;
|
||||||
|
|
||||||
if (!iap->ia_valid)
|
if (!iap->ia_valid)
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
nfsd_sanitize_attrs(inode, iap);
|
nfsd_sanitize_attrs(inode, iap);
|
||||||
|
|
||||||
|
if (check_guard && guardtime != inode->i_ctime.tv_sec)
|
||||||
|
return nfserr_notsync;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The size case is special, it changes the file in addition to the
|
* The size case is special, it changes the file in addition to the
|
||||||
* attributes.
|
* attributes.
|
||||||
*/
|
*/
|
||||||
if (iap->ia_valid & ATTR_SIZE) {
|
if (size_change) {
|
||||||
err = nfsd_get_write_access(rqstp, fhp, iap);
|
err = nfsd_get_write_access(rqstp, fhp, iap);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
return err;
|
||||||
size_change = 1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RFC5661, Section 18.30.4:
|
* RFC5661, Section 18.30.4:
|
||||||
@@ -432,23 +434,16 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp, struct iattr *iap,
|
|||||||
|
|
||||||
iap->ia_valid |= ATTR_CTIME;
|
iap->ia_valid |= ATTR_CTIME;
|
||||||
|
|
||||||
if (check_guard && guardtime != inode->i_ctime.tv_sec) {
|
|
||||||
err = nfserr_notsync;
|
|
||||||
goto out_put_write_access;
|
|
||||||
}
|
|
||||||
|
|
||||||
fh_lock(fhp);
|
fh_lock(fhp);
|
||||||
host_err = notify_change(dentry, iap, NULL);
|
host_err = notify_change(dentry, iap, NULL);
|
||||||
fh_unlock(fhp);
|
fh_unlock(fhp);
|
||||||
err = nfserrno(host_err);
|
|
||||||
|
|
||||||
out_put_write_access:
|
|
||||||
if (size_change)
|
if (size_change)
|
||||||
put_write_access(inode);
|
put_write_access(inode);
|
||||||
if (!err)
|
|
||||||
err = nfserrno(commit_metadata(fhp));
|
|
||||||
out:
|
out:
|
||||||
return err;
|
if (!host_err)
|
||||||
|
host_err = commit_metadata(fhp);
|
||||||
|
return nfserrno(host_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_NFSD_V4)
|
#if defined(CONFIG_NFSD_V4)
|
||||||
|
|||||||
Reference in New Issue
Block a user