Skip to content

Commit e5f06f7

Browse files
Stanislav KinsburskyJ. Bruce Fields
authored andcommitted
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>
1 parent b3853e0 commit e5f06f7

6 files changed

Lines changed: 25 additions & 24 deletions

File tree

‎fs/nfsd/export.c‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ typedef struct svc_export svc_export;
4040
#define EXPKEY_HASHBITS 8
4141
#define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS)
4242
#define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)
43-
static struct cache_head *expkey_table[EXPKEY_HASHMAX];
4443

4544
static void expkey_put(struct kref *ref)
4645
{
@@ -241,10 +240,9 @@ static struct cache_head *expkey_alloc(void)
241240
return NULL;
242241
}
243242

244-
static struct cache_detail svc_expkey_cache = {
243+
static struct cache_detail svc_expkey_cache_template = {
245244
.owner = THIS_MODULE,
246245
.hash_size = EXPKEY_HASHMAX,
247-
.hash_table = expkey_table,
248246
.name = "nfsd.fh",
249247
.cache_put = expkey_put,
250248
.cache_upcall = expkey_upcall,
@@ -883,12 +881,13 @@ static struct svc_export *exp_find(struct cache_detail *cd,
883881
u32 *fsidv, struct cache_req *reqp)
884882
{
885883
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);
887886
if (IS_ERR(ek))
888887
return ERR_CAST(ek);
889888

890889
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);
892891

893892
if (IS_ERR(exp))
894893
return ERR_CAST(exp);
@@ -1232,7 +1231,6 @@ const struct seq_operations nfs_exports_op = {
12321231
.show = e_show,
12331232
};
12341233

1235-
12361234
/*
12371235
* Initialize the exports module.
12381236
*/
@@ -1251,11 +1249,18 @@ nfsd_export_init(struct net *net)
12511249
if (rv)
12521250
goto destroy_export_cache;
12531251

1254-
rv = cache_register_net(&svc_expkey_cache, net);
1255-
if (rv)
1252+
nn->svc_expkey_cache = cache_create_net(&svc_expkey_cache_template, net);
1253+
if (IS_ERR(nn->svc_expkey_cache)) {
1254+
rv = PTR_ERR(nn->svc_expkey_cache);
12561255
goto unregister_export_cache;
1256+
}
1257+
rv = cache_register_net(nn->svc_expkey_cache, net);
1258+
if (rv)
1259+
goto destroy_expkey_cache;
12571260
return 0;
12581261

1262+
destroy_expkey_cache:
1263+
cache_destroy_net(nn->svc_expkey_cache, net);
12591264
unregister_export_cache:
12601265
cache_unregister_net(nn->svc_export_cache, net);
12611266
destroy_export_cache:
@@ -1271,7 +1276,7 @@ nfsd_export_flush(struct net *net)
12711276
{
12721277
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
12731278

1274-
cache_purge(&svc_expkey_cache);
1279+
cache_purge(nn->svc_expkey_cache);
12751280
cache_purge(nn->svc_export_cache);
12761281
}
12771282

@@ -1285,10 +1290,11 @@ nfsd_export_shutdown(struct net *net)
12851290

12861291
dprintk("nfsd: shutting down export module (net: %p).\n", net);
12871292

1288-
cache_unregister_net(&svc_expkey_cache, net);
1293+
cache_unregister_net(nn->svc_expkey_cache, net);
12891294
cache_unregister_net(nn->svc_export_cache, net);
1295+
cache_destroy_net(nn->svc_expkey_cache, net);
12901296
cache_destroy_net(nn->svc_export_cache, net);
1291-
svcauth_unix_purge();
1297+
svcauth_unix_purge(net);
12921298

12931299
dprintk("nfsd: export shutdown complete (net: %p).\n", net);
12941300
}

‎fs/nfsd/netns.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct cld_net;
2929
struct nfsd_net {
3030
struct cld_net *cld_net;
3131

32+
struct cache_detail *svc_expkey_cache;
3233
struct cache_detail *svc_export_cache;
3334
};
3435

‎fs/nfsd/nfsctl.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,14 @@ static int exports_open(struct inode *inode, struct file *file)
129129
{
130130
int err;
131131
struct seq_file *seq;
132+
struct nfsd_net *nn = net_generic(&init_net, nfsd_net_id);
132133

133134
err = seq_open(file, &nfs_exports_op);
134135
if (err)
135136
return err;
136137

137138
seq = file->private_data;
138-
seq->private = &svc_export_cache;
139+
seq->private = nn->svc_export_cache;
139140
return 0;
140141
}
141142

‎include/linux/nfsd/export.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ int exp_rootfh(struct net *, struct auth_domain *,
143143
__be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
144144
__be32 nfserrno(int errno);
145145

146-
extern struct cache_detail svc_export_cache;
147-
148146
static inline void exp_put(struct svc_export *exp)
149147
{
150148
cache_put(&exp->h, exp->cd);

‎include/linux/sunrpc/svcauth.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ extern struct auth_domain *auth_domain_lookup(char *name, struct auth_domain *ne
130130
extern struct auth_domain *auth_domain_find(char *name);
131131
extern struct auth_domain *auth_unix_lookup(struct net *net, struct in6_addr *addr);
132132
extern int auth_unix_forget_old(struct auth_domain *dom);
133-
extern void svcauth_unix_purge(void);
133+
extern void svcauth_unix_purge(struct net *net);
134134
extern void svcauth_unix_info_release(struct svc_xprt *xpt);
135135
extern int svcauth_unix_set_client(struct svc_rqst *rqstp);
136136

‎net/sunrpc/svcauth_unix.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -346,17 +346,12 @@ static inline int ip_map_update(struct net *net, struct ip_map *ipm,
346346
return __ip_map_update(sn->ip_map_cache, ipm, udom, expiry);
347347
}
348348

349-
350-
void svcauth_unix_purge(void)
349+
void svcauth_unix_purge(struct net *net)
351350
{
352-
struct net *net;
353-
354-
for_each_net(net) {
355-
struct sunrpc_net *sn;
351+
struct sunrpc_net *sn;
356352

357-
sn = net_generic(net, sunrpc_net_id);
358-
cache_purge(sn->ip_map_cache);
359-
}
353+
sn = net_generic(net, sunrpc_net_id);
354+
cache_purge(sn->ip_map_cache);
360355
}
361356
EXPORT_SYMBOL_GPL(svcauth_unix_purge);
362357

0 commit comments

Comments
 (0)