Skip to contentSkip to conversation

nfsd: break lease on unlink due to rename

PATCH New J. Bruce Fields 1 participant 1 message Feb 9, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: break lease on unlink due to rename

When I added code to break leases on nfsd rename, I overlooked the case where the rename unlinks a preexisting file at the target path.

It was an important oversight, and the fix is pretty minor, but there's no regression here, so I'm a bit on the fence whether to put this off to 2.6.39 or try to slip it into 2.6.38.

--b.

commit 090f03c2183cf0ad8596c0a8c30a3976a47cdea8

Author: J. Bruce Fields <[email protected]>
Date:   Sun Feb 6 16:46:30 2011 -0500

nfsd: break lease on unlink due to rename

4795bb37effb7b8fe77e2d2034545d062d3788a8 "nfsd: break lease on unlink, link, and rename", only broke the lease on the file that was being renamed, and didn't handle the case where the target path refers to an already-existing file that will be unlinked by a rename--in that case the target file should have any leases broken as well.

fs/nfsd/vfs.c +7 -0
index 4218531..d7aa65c 100644
@@ -1744,6 +1744,13 @@ nfsd_rename(struct svc_rqst *rqstp, struct svc_fh *ffhp, char *fname, int flen,
 	host_err = nfsd_break_lease(odentry->d_inode);
 	if (host_err)
 		goto out_drop_write;
+	if (ndentry->d_inode) {
+		host_err = nfsd_break_lease(ndentry->d_inode);
+		if (host_err)
+			goto out_drop_write;
+	}
+	if (host_err)
+		goto out_drop_write;
 	host_err = vfs_rename(fdir, odentry, tdir, ndentry);
 	if (!host_err) {
 		host_err = commit_metadata(tfhp);