xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-devtools/unfs3/unfs3/rename_fh_cache.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From: Jason Wessel <jason.wessel@windriver.com>
2Date: Sat, 23 Feb 2013 08:49:08 -0600
3Subject: [PATCH] fh_cache: fix statle nfs handle on rename problem
4
5The following test case fails with modern linunx kernels which cache
6the renamed inode.
7
8  % mkdir a;mkdir b;mv b a/;ls -l a
9  ls: a/b: Stale NFS file handle
10
11The issue is that nfserver was not updating the fh_cache with the new
12location of the inode, when it moves directories.
13
14Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
15
16Upstream-Status: Submitted http://sourceforge.net/p/unfs3/bugs/5/
17
18---
19 fh_cache.c |   12 ++++++++++++
20 fh_cache.h |    1 +
21 nfs.c      |    2 ++
22 3 files changed, 15 insertions(+)
23
24--- a/fh_cache.c
25+++ b/fh_cache.c
26@@ -199,6 +199,18 @@ static char *fh_cache_lookup(uint32 dev,
27 }
28
29 /*
30+ * update a fh inode cache for an operation like rename
31+ */
32+void fh_cache_update(nfs_fh3 fh, char *path)
33+{
34+    unfs3_fh_t *obj = (void *) fh.data.data_val;
35+    backend_statstruct buf;
36+
37+    if (backend_lstat(path, &buf) != -1) {
38+	fh_cache_add(obj->dev, buf.st_ino, path);
39+    }
40+}
41+/*
42  * resolve a filename into a path
43  * cache-using wrapper for fh_decomp_raw
44  */
45--- a/fh_cache.h
46+++ b/fh_cache.h
47@@ -19,5 +19,6 @@ unfs3_fh_t fh_comp(const char *path, str
48 unfs3_fh_t *fh_comp_ptr(const char *path, struct svc_req *rqstp, int need_dir);
49
50 char *fh_cache_add(uint32 dev, uint64 ino, const char *path);
51+void fh_cache_update(nfs_fh3 fh, char *path);
52
53 #endif
54--- a/nfs.c
55+++ b/nfs.c
56@@ -876,6 +876,8 @@ RENAME3res *nfsproc3_rename_3_svc(RENAME
57 	    res = backend_rename(from_obj, to_obj);
58 	    if (res == -1)
59 		result.status = rename_err();
60+	    /* Update the fh_cache with moved inode value */
61+	    fh_cache_update(argp->to.dir, to_obj);
62 	}
63     }
64
65