aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/cache_lib.c
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2011-11-25 09:12:56 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 18:20:26 -0500
commit5c1cacb175185ed925d7dc13ac7e0653e7a633cd (patch)
treea80d79c379bddbd7b75968de1f1825d0e7e36917 /fs/nfs/cache_lib.c
parent9222b955065dbb047b8db9eb2431979bff3ce700 (diff)
NFS: handle NFS caches dentries by network namespace aware routines
This patch makes NFS caches PipeFS dentries allocated and destroyed in network namespace context by PipeFS network namespace aware routines. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/cache_lib.c')
-rw-r--r--fs/nfs/cache_lib.c44
1 files changed, 35 insertions, 9 deletions
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index 9d79a2eaab27..5dd017bbb7a2 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -13,6 +13,7 @@
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/sunrpc/cache.h> 14#include <linux/sunrpc/cache.h>
15#include <linux/sunrpc/rpc_pipe_fs.h> 15#include <linux/sunrpc/rpc_pipe_fs.h>
16#include <net/net_namespace.h>
16 17
17#include "cache_lib.h" 18#include "cache_lib.h"
18 19
@@ -111,20 +112,34 @@ int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq)
111 return 0; 112 return 0;
112} 113}
113 114
114int nfs_cache_register(struct cache_detail *cd) 115static int nfs_cache_register_sb(struct super_block *sb, struct cache_detail *cd)
116{
117 int ret;
118 struct dentry *dir;
119
120 dir = rpc_d_lookup_sb(sb, "cache");
121 BUG_ON(dir == NULL);
122 ret = sunrpc_cache_register_pipefs(dir, cd->name, 0600, cd);
123 dput(dir);
124 return ret;
125}
126
127int nfs_cache_register_net(struct net *net, struct cache_detail *cd)
115{ 128{
116 struct vfsmount *mnt; 129 struct vfsmount *mnt;
117 struct path path; 130 struct super_block *pipefs_sb;
118 int ret; 131 int ret;
119 132
120 mnt = rpc_get_mount(); 133 mnt = rpc_get_mount();
121 if (IS_ERR(mnt)) 134 if (IS_ERR(mnt))
122 return PTR_ERR(mnt); 135 return PTR_ERR(mnt);
123 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path); 136 pipefs_sb = rpc_get_sb_net(net);
124 if (ret) 137 if (!pipefs_sb) {
138 ret = -ENOENT;
125 goto err; 139 goto err;
126 ret = sunrpc_cache_register_pipefs(path.dentry, cd->name, 0600, cd); 140 }
127 path_put(&path); 141 ret = nfs_cache_register_sb(pipefs_sb, cd);
142 rpc_put_sb_net(net);
128 if (!ret) 143 if (!ret)
129 return ret; 144 return ret;
130err: 145err:
@@ -132,10 +147,21 @@ err:
132 return ret; 147 return ret;
133} 148}
134 149
135void nfs_cache_unregister(struct cache_detail *cd) 150static void nfs_cache_unregister_sb(struct super_block *sb, struct cache_detail *cd)
136{ 151{
137 sunrpc_cache_unregister_pipefs(cd); 152 if (cd->u.pipefs.dir)
138 sunrpc_destroy_cache_detail(cd); 153 sunrpc_cache_unregister_pipefs(cd);
154}
155
156void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd)
157{
158 struct super_block *pipefs_sb;
159
160 pipefs_sb = rpc_get_sb_net(net);
161 if (pipefs_sb) {
162 nfs_cache_unregister_sb(pipefs_sb, cd);
163 rpc_put_sb_net(net);
164 }
139 rpc_put_mount(); 165 rpc_put_mount();
140} 166}
141 167