65 lines
1.7 KiB
Diff
65 lines
1.7 KiB
Diff
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: Submitted http://sourceforge.net/p/unfs3/bugs/5/
|
|
|
|
---
|
|
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);
|
|
}
|
|
}
|
|
|