summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/unfs3/unfs3/rename_fh_cache.patch
blob: 37de8c3ca21af5e15a908c12eae3a52fbb3a3376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From: Jason Wessel <jason.wessel@windriver.com>
Date: Sat, 23 Feb 2013 08:49:08 -0600
Subject: [PATCH] fh_cache: fix statle nfs handle on rename problem

The following test case fails with modern linunx kernels which cache
the renamed inode.

  % mkdir a;mkdir b;mv b a/;ls -l a
  ls: a/b: Stale NFS file handle

The issue is that nfserver was not updating the fh_cache with the new
location of the inode, when it moves directories.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>

Upstream-Status: Pending

---
 fh_cache.c |   12 ++++++++++++
 fh_cache.h |    1 +
 nfs.c      |    2 ++
 3 files changed, 15 insertions(+)

--- a/fh_cache.c
+++ b/fh_cache.c
@@ -199,6 +199,18 @@ static char *fh_cache_lookup(uint32 dev,
 }
 
 /*
+ * update a fh inode cache for an operation like rename
+ */
+void fh_cache_update(nfs_fh3 fh, char *path)
+{
+    unfs3_fh_t *obj = (void *) fh.data.data_val;
+    backend_statstruct buf;
+
+    if (backend_lstat(path, &buf) != -1) {
+	fh_cache_add(obj->dev, buf.st_ino, path);
+    }
+}
+/*
  * resolve a filename into a path
  * cache-using wrapper for fh_decomp_raw
  */
--- a/fh_cache.h
+++ b/fh_cache.h
@@ -19,5 +19,6 @@ unfs3_fh_t fh_comp(const char *path, str
 unfs3_fh_t *fh_comp_ptr(const char *path, struct svc_req *rqstp, int need_dir);
 
 char *fh_cache_add(uint32 dev, uint64 ino, const char *path);
+void fh_cache_update(nfs_fh3 fh, char *path);
 
 #endif
--- a/nfs.c
+++ b/nfs.c
@@ -876,6 +876,8 @@ RENAME3res *nfsproc3_rename_3_svc(RENAME
 	    res = backend_rename(from_obj, to_obj);
 	    if (res == -1)
 		result.status = rename_err();
+	    /* Update the fh_cache with moved inode value */
+	    fh_cache_update(argp->to.dir, to_obj);
 	}
     }
 
OpenPOWER on IntegriCloud