Return-Path: Received: from mail-bn3nam01on0135.outbound.protection.outlook.com ([104.47.33.135]:19456 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932191AbeARU7i (ORCPT ); Thu, 18 Jan 2018 15:59:38 -0500 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Christoph Hellwig , "J . Bruce Fields" , Sasha Levin Subject: [added to the 4.1 stable tree] nfsd: minor nfsd_setattr cleanup Date: Thu, 18 Jan 2018 20:59:30 +0000 Message-ID: <20180118205908.3220-13-alexander.levin@microsoft.com> References: <20180118205908.3220-1-alexander.levin@microsoft.com> In-Reply-To: <20180118205908.3220-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Christoph Hellwig This patch has been added to the stable tree. If you have any objections, please let us know. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D [ Upstream commit 758e99fefe1d9230111296956335cd35995c0eaf ] Simplify exit paths, size_change use. Signed-off-by: Christoph Hellwig Cc: stable@kernel.org Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- fs/nfsd/vfs.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 92de3747ea8b..11899f851129 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -369,7 +369,7 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp= , struct iattr *iap, __be32 err; int host_err; bool get_write_count; - int size_change =3D 0; + bool size_change =3D (iap->ia_valid & ATTR_SIZE); =20 if (iap->ia_valid & (ATTR_ATIME | ATTR_MTIME | ATTR_SIZE)) accmode |=3D NFSD_MAY_WRITE|NFSD_MAY_OWNER_OVERRIDE; @@ -382,11 +382,11 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *f= hp, struct iattr *iap, /* Get inode */ err =3D fh_verify(rqstp, fhp, ftype, accmode); if (err) - goto out; + return err; if (get_write_count) { host_err =3D fh_want_write(fhp); if (host_err) - return nfserrno(host_err); + goto out; } =20 dentry =3D fhp->fh_dentry; @@ -397,19 +397,21 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *f= hp, struct iattr *iap, iap->ia_valid &=3D ~ATTR_MODE; =20 if (!iap->ia_valid) - goto out; + return 0; =20 nfsd_sanitize_attrs(inode, iap); =20 + if (check_guard && guardtime !=3D inode->i_ctime.tv_sec) + return nfserr_notsync; + /* * The size case is special, it changes the file in addition to the * attributes. */ - if (iap->ia_valid & ATTR_SIZE) { + if (size_change) { err =3D nfsd_get_write_access(rqstp, fhp, iap); if (err) - goto out; - size_change =3D 1; + return err; =20 /* * RFC5661, Section 18.30.4: @@ -424,23 +426,16 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *f= hp, struct iattr *iap, =20 iap->ia_valid |=3D ATTR_CTIME; =20 - if (check_guard && guardtime !=3D inode->i_ctime.tv_sec) { - err =3D nfserr_notsync; - goto out_put_write_access; - } - fh_lock(fhp); host_err =3D notify_change(dentry, iap, NULL); fh_unlock(fhp); - err =3D nfserrno(host_err); =20 -out_put_write_access: if (size_change) put_write_access(inode); - if (!err) - err =3D nfserrno(commit_metadata(fhp)); out: - return err; + if (!host_err) + host_err =3D commit_metadata(fhp); + return nfserrno(host_err); } =20 #if defined(CONFIG_NFSD_V4) --=20 2.11.0