Skip to content

Commit b677c0c

Browse files
neilbrownchucklever
authored andcommitted
NFSD: always drop directory lock in nfsd_unlink()
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 <[email protected]> Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 927bfc5 commit b677c0c

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

fs/nfsd/nfs3proc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ nfsd3_proc_remove(struct svc_rqst *rqstp)
490490
fh_copy(&resp->fh, &argp->fh);
491491
resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR,
492492
argp->name, argp->len);
493-
fh_unlock(&resp->fh);
494493
return rpc_success;
495494
}
496495

@@ -511,7 +510,6 @@ nfsd3_proc_rmdir(struct svc_rqst *rqstp)
511510
fh_copy(&resp->fh, &argp->fh);
512511
resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR,
513512
argp->name, argp->len);
514-
fh_unlock(&resp->fh);
515513
return rpc_success;
516514
}
517515

fs/nfsd/nfs4proc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,8 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
10021002
return nfserr_grace;
10031003
status = nfsd_unlink(rqstp, &cstate->current_fh, 0,
10041004
remove->rm_name, remove->rm_namelen);
1005-
if (!status) {
1006-
fh_unlock(&cstate->current_fh);
1005+
if (!status)
10071006
set_change_info(&remove->rm_cinfo, &cstate->current_fh);
1008-
}
10091007
return status;
10101008
}
10111009

fs/nfsd/vfs.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,12 +1753,12 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
17531753
rdentry = lookup_one_len(fname, dentry, flen);
17541754
host_err = PTR_ERR(rdentry);
17551755
if (IS_ERR(rdentry))
1756-
goto out_drop_write;
1756+
goto out_unlock;
17571757

17581758
if (d_really_is_negative(rdentry)) {
17591759
dput(rdentry);
17601760
host_err = -ENOENT;
1761-
goto out_drop_write;
1761+
goto out_unlock;
17621762
}
17631763
rinode = d_inode(rdentry);
17641764
ihold(rinode);
@@ -1796,6 +1796,9 @@ nfsd_unlink(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
17961796
}
17971797
out:
17981798
return err;
1799+
out_unlock:
1800+
fh_unlock(fhp);
1801+
goto out_drop_write;
17991802
}
18001803

18011804
/*

0 commit comments

Comments
 (0)