]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
NFSD: always drop directory lock in nfsd_unlink()
authorNeilBrown <neilb@suse.de>
Tue, 26 Jul 2022 06:45:30 +0000 (16:45 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Apr 2024 14:19:14 +0000 (16:19 +0200)
[ Upstream commit b677c0c63a135a916493c064906582e9f3ed4802 ]

Some error paths in nfsd_unlink() allow it to exit without unlocking the
directory.  This is not a problem in practice as the directory will be
locked with an fh_put(), but it is untidy and potentially confusing.

This allows us to remove all the fh_unlock() calls that are immediately
after nfsd_unlink() calls.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs3proc.c
fs/nfsd/nfs4proc.c
fs/nfsd/vfs.c

index c7c2c7db30f54a4d62ccac40e2cd405a372f0818..fbdc109fbd06736213b4c7ea17ab22faaa23ef09 100644 (file)
@@ -490,7 +490,6 @@ nfsd3_proc_remove(struct svc_rqst *rqstp)
        fh_copy(&resp->fh, &argp->fh);
        resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR,
                                   argp->name, argp->len);
-       fh_unlock(&resp->fh);
        return rpc_success;
 }
 
@@ -511,7 +510,6 @@ nfsd3_proc_rmdir(struct svc_rqst *rqstp)
        fh_copy(&resp->fh, &argp->fh);
        resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR,
                                   argp->name, argp->len);
-       fh_unlock(&resp->fh);
        return rpc_success;
 }
 
index fb2487ceac46ec9c9e541b062e21a7a42278130b..26cd2479e30cf16b84eb5e031665fdb1c507135a 100644 (file)
@@ -1002,10 +1002,8 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                return nfserr_grace;
        status = nfsd_unlink(rqstp, &cstate->current_fh, 0,
                             remove->rm_name, remove->rm_namelen);
-       if (!status) {
-               fh_unlock(&cstate->current_fh);
+       if (!status)
                set_change_info(&remove->rm_cinfo, &cstate->current_fh);
-       }
        return status;
 }
 
index 90bd6968fbf685e646298d6387b3c06e19e3ac7f..4b1304fe718fd5996817aebcef63e4114513e784 100644 (file)
@@ -1754,12 +1754,12 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
        rdentry = lookup_one_len(fname, dentry, flen);
        host_err = PTR_ERR(rdentry);
        if (IS_ERR(rdentry))
-               goto out_drop_write;
+               goto out_unlock;
 
        if (d_really_is_negative(rdentry)) {
                dput(rdentry);
                host_err = -ENOENT;
-               goto out_drop_write;
+               goto out_unlock;
        }
        rinode = d_inode(rdentry);
        ihold(rinode);
@@ -1797,6 +1797,9 @@ out_nfserr:
        }
 out:
        return err;
+out_unlock:
+       fh_unlock(fhp);
+       goto out_drop_write;
 }
 
 /*