aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
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
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')
-rw-r--r--fs/nfs/cache_lib.c44
-rw-r--r--fs/nfs/cache_lib.h4
-rw-r--r--fs/nfs/dns_resolve.c4
3 files changed, 39 insertions, 13 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
diff --git a/fs/nfs/cache_lib.h b/fs/nfs/cache_lib.h
index 815dd6651c9f..e0a6cc4b01b9 100644
--- a/fs/nfs/cache_lib.h
+++ b/fs/nfs/cache_lib.h
@@ -25,5 +25,5 @@ extern int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq);
25 25
26extern void nfs_cache_init(struct cache_detail *cd); 26extern void nfs_cache_init(struct cache_detail *cd);
27extern void nfs_cache_destroy(struct cache_detail *cd); 27extern void nfs_cache_destroy(struct cache_detail *cd);
28extern int nfs_cache_register(struct cache_detail *cd); 28extern int nfs_cache_register_net(struct net *net, struct cache_detail *cd);
29extern void nfs_cache_unregister(struct cache_detail *cd); 29extern void nfs_cache_unregister_net(struct net *net, struct cache_detail *cd);
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 619dea6b5ccf..3cbf4b88f827 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -364,7 +364,7 @@ int nfs_dns_resolver_init(void)
364 int err; 364 int err;
365 365
366 nfs_cache_init(&nfs_dns_resolve); 366 nfs_cache_init(&nfs_dns_resolve);
367 err = nfs_cache_register(&nfs_dns_resolve); 367 err = nfs_cache_register_net(&init_net, &nfs_dns_resolve);
368 if (err) { 368 if (err) {
369 nfs_cache_destroy(&nfs_dns_resolve); 369 nfs_cache_destroy(&nfs_dns_resolve);
370 return err; 370 return err;
@@ -374,7 +374,7 @@ int nfs_dns_resolver_init(void)
374 374
375void nfs_dns_resolver_destroy(void) 375void nfs_dns_resolver_destroy(void)
376{ 376{
377 nfs_cache_unregister(&nfs_dns_resolve); 377 nfs_cache_unregister_net(&init_net, &nfs_dns_resolve);
378 nfs_cache_destroy(&nfs_dns_resolve); 378 nfs_cache_destroy(&nfs_dns_resolve);
379} 379}
380 380