Skip to content

Commit e18bcb3

Browse files
neilbrownchucklever
authored andcommitted
NFSD: only call fh_unlock() once in nfsd_link()
On non-error paths, nfsd_link() calls fh_unlock() twice. This is safe because fh_unlock() records that the unlock has been done and doesn't repeat it. However it makes the code a little confusing and interferes with changes that are planned for directory locking. So rearrange the code to ensure fh_unlock() is called exactly once if fh_lock() was called. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: NeilBrown <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent b677c0c commit e18bcb3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

fs/nfsd/vfs.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,9 +1541,10 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
15411541
dirp = d_inode(ddir);
15421542

15431543
dnew = lookup_one_len(name, ddir, len);
1544-
host_err = PTR_ERR(dnew);
1545-
if (IS_ERR(dnew))
1546-
goto out_nfserr;
1544+
if (IS_ERR(dnew)) {
1545+
err = nfserrno(PTR_ERR(dnew));
1546+
goto out_unlock;
1547+
}
15471548

15481549
dold = tfhp->fh_dentry;
15491550

@@ -1562,17 +1563,17 @@ nfsd_link(struct svc_rqst *rqstp, struct svc_fh *ffhp,
15621563
else
15631564
err = nfserrno(host_err);
15641565
}
1565-
out_dput:
15661566
dput(dnew);
1567-
out_unlock:
1568-
fh_unlock(ffhp);
1567+
out_drop_write:
15691568
fh_drop_write(tfhp);
15701569
out:
15711570
return err;
15721571

1573-
out_nfserr:
1574-
err = nfserrno(host_err);
1575-
goto out_unlock;
1572+
out_dput:
1573+
dput(dnew);
1574+
out_unlock:
1575+
fh_unlock(ffhp);
1576+
goto out_drop_write;
15761577
}
15771578

15781579
static void

0 commit comments

Comments
 (0)