aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-04-11 07:13:28 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-04-12 09:11:46 -0400
commite5f06f720eff24e32f1cc08ec03bcc8c4b2d2934 (patch)
tree9afeda20ea7ea07f6c1bbcc9dc5979c98cc62def /fs
parentb3853e0ea1f2ef58f7e7c03e47819e2ae3766dea (diff)
nfsd: make expkey cache allocated per network namespace context
This patch also changes svcauth_unix_purge() function: added network namespace as a parameter and thus loop over all networks was replaced by only one call for ip map cache purge. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfsd/export.c28
-rw-r--r--fs/nfsd/netns.h1
-rw-r--r--fs/nfsd/nfsctl.c3
3 files changed, 20 insertions, 12 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 84d020fc0e3..dcb52b88451 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -40,7 +40,6 @@ typedef struct svc_export svc_export;
40#define EXPKEY_HASHBITS 8 40#define EXPKEY_HASHBITS 8
41#define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS) 41#define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS)
42#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1) 42#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)
43static struct cache_head *expkey_table[EXPKEY_HASHMAX];
44 43
45static void expkey_put(struct kref *ref) 44static void expkey_put(struct kref *ref)
46{ 45{
@@ -241,10 +240,9 @@ static struct cache_head *expkey_alloc(void)
241 return NULL; 240 return NULL;
242} 241}
243 242
244static struct cache_detail svc_expkey_cache = { 243static struct cache_detail svc_expkey_cache_template = {
245 .owner = THIS_MODULE, 244 .owner = THIS_MODULE,
246 .hash_size = EXPKEY_HASHMAX, 245 .hash_size = EXPKEY_HASHMAX,
247 .hash_table = expkey_table,
248 .name = "nfsd.fh", 246 .name = "nfsd.fh",
249 .cache_put = expkey_put, 247 .cache_put = expkey_put,
250 .cache_upcall = expkey_upcall, 248 .cache_upcall = expkey_upcall,
@@ -883,12 +881,13 @@ static struct svc_export *exp_find(struct cache_detail *cd,
883 u32 *fsidv, struct cache_req *reqp) 881 u32 *fsidv, struct cache_req *reqp)
884{ 882{
885 struct svc_export *exp; 883 struct svc_export *exp;
886 struct svc_expkey *ek = exp_find_key(&svc_expkey_cache, clp, fsid_type, fsidv, reqp); 884 struct nfsd_net *nn = net_generic(cd->net, nfsd_net_id);
885 struct svc_expkey *ek = exp_find_key(nn->svc_expkey_cache, clp, fsid_type, fsidv, reqp);
887 if (IS_ERR(ek)) 886 if (IS_ERR(ek))
888 return ERR_CAST(ek); 887 return ERR_CAST(ek);
889 888
890 exp = exp_get_by_name(cd, clp, &ek->ek_path, reqp); 889 exp = exp_get_by_name(cd, clp, &ek->ek_path, reqp);
891 cache_put(&ek->h, &svc_expkey_cache); 890 cache_put(&ek->h, nn->svc_expkey_cache);
892 891
893 if (IS_ERR(exp)) 892 if (IS_ERR(exp))
894 return ERR_CAST(exp); 893 return ERR_CAST(exp);
@@ -1232,7 +1231,6 @@ const struct seq_operations nfs_exports_op = {
1232 .show = e_show, 1231 .show = e_show,
1233}; 1232};
1234 1233
1235
1236/* 1234/*
1237 * Initialize the exports module. 1235 * Initialize the exports module.
1238 */ 1236 */
@@ -1251,11 +1249,18 @@ nfsd_export_init(struct net *net)
1251 if (rv) 1249 if (rv)
1252 goto destroy_export_cache; 1250 goto destroy_export_cache;
1253 1251
1254 rv = cache_register_net(&svc_expkey_cache, net); 1252 nn->svc_expkey_cache = cache_create_net(&svc_expkey_cache_template, net);
1255 if (rv) 1253 if (IS_ERR(nn->svc_expkey_cache)) {
1254 rv = PTR_ERR(nn->svc_expkey_cache);
1256 goto unregister_export_cache; 1255 goto unregister_export_cache;
1256 }
1257 rv = cache_register_net(nn->svc_expkey_cache, net);
1258 if (rv)
1259 goto destroy_expkey_cache;
1257 return 0; 1260 return 0;
1258 1261
1262destroy_expkey_cache:
1263 cache_destroy_net(nn->svc_expkey_cache, net);
1259unregister_export_cache: 1264unregister_export_cache:
1260 cache_unregister_net(nn->svc_export_cache, net); 1265 cache_unregister_net(nn->svc_export_cache, net);
1261destroy_export_cache: 1266destroy_export_cache:
@@ -1271,7 +1276,7 @@ nfsd_export_flush(struct net *net)
1271{ 1276{
1272 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 1277 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1273 1278
1274 cache_purge(&svc_expkey_cache); 1279 cache_purge(nn->svc_expkey_cache);
1275 cache_purge(nn->svc_export_cache); 1280 cache_purge(nn->svc_export_cache);
1276} 1281}
1277 1282
@@ -1285,10 +1290,11 @@ nfsd_export_shutdown(struct net *net)
1285 1290
1286 dprintk("nfsd: shutting down export module (net: %p).\n", net); 1291 dprintk("nfsd: shutting down export module (net: %p).\n", net);
1287 1292
1288 cache_unregister_net(&svc_expkey_cache, net); 1293 cache_unregister_net(nn->svc_expkey_cache, net);
1289 cache_unregister_net(nn->svc_export_cache, net); 1294 cache_unregister_net(nn->svc_export_cache, net);
1295 cache_destroy_net(nn->svc_expkey_cache, net);
1290 cache_destroy_net(nn->svc_export_cache, net); 1296 cache_destroy_net(nn->svc_export_cache, net);
1291 svcauth_unix_purge(); 1297 svcauth_unix_purge(net);
1292 1298
1293 dprintk("nfsd: export shutdown complete (net: %p).\n", net); 1299 dprintk("nfsd: export shutdown complete (net: %p).\n", net);
1294} 1300}
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h
index c1c6242942a..9794c6c7d13 100644
--- a/fs/nfsd/netns.h
+++ b/fs/nfsd/netns.h
@@ -29,6 +29,7 @@ struct cld_net;
29struct nfsd_net { 29struct nfsd_net {
30 struct cld_net *cld_net; 30 struct cld_net *cld_net;
31 31
32 struct cache_detail *svc_expkey_cache;
32 struct cache_detail *svc_export_cache; 33 struct cache_detail *svc_export_cache;
33}; 34};
34 35
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index ddb9f878737..b1441774081 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -129,13 +129,14 @@ static int exports_open(struct inode *inode, struct file *file)
129{ 129{
130 int err; 130 int err;
131 struct seq_file *seq; 131 struct seq_file *seq;
132 struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
132 133
133 err = seq_open(file, &nfs_exports_op); 134 err = seq_open(file, &nfs_exports_op);
134 if (err) 135 if (err)
135 return err; 136 return err;
136 137
137 seq = file->private_data; 138 seq = file->private_data;
138 seq->private = &svc_export_cache; 139 seq->private = nn->svc_export_cache;
139 return 0; 140 return 0;
140} 141}
141 142