diff options
| -rw-r--r-- | fs/nfsd/netns.h | 2 | ||||
| -rw-r--r-- | fs/nfsd/nfs4idmap.c | 24 |
2 files changed, 16 insertions, 10 deletions
diff --git a/fs/nfsd/netns.h b/fs/nfsd/netns.h index 948a718e24a..39365636b24 100644 --- a/fs/nfsd/netns.h +++ b/fs/nfsd/netns.h | |||
| @@ -33,7 +33,7 @@ struct nfsd_net { | |||
| 33 | struct cache_detail *svc_export_cache; | 33 | struct cache_detail *svc_export_cache; |
| 34 | 34 | ||
| 35 | struct cache_detail *idtoname_cache; | 35 | struct cache_detail *idtoname_cache; |
| 36 | 36 | struct cache_detail *nametoid_cache; | |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | extern int nfsd_net_id; | 39 | extern int nfsd_net_id; |
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index b285a693af8..286a7f8f202 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c | |||
| @@ -301,8 +301,6 @@ idtoname_update(struct cache_detail *cd, struct ent *new, struct ent *old) | |||
| 301 | * Name -> ID cache | 301 | * Name -> ID cache |
| 302 | */ | 302 | */ |
| 303 | 303 | ||
| 304 | static struct cache_head *nametoid_table[ENT_HASHMAX]; | ||
| 305 | |||
| 306 | static inline int | 304 | static inline int |
| 307 | nametoid_hash(struct ent *ent) | 305 | nametoid_hash(struct ent *ent) |
| 308 | { | 306 | { |
| @@ -362,10 +360,9 @@ static struct ent *nametoid_update(struct cache_detail *, struct ent *, | |||
| 362 | struct ent *); | 360 | struct ent *); |
| 363 | static int nametoid_parse(struct cache_detail *, char *, int); | 361 | static int nametoid_parse(struct cache_detail *, char *, int); |
| 364 | 362 | ||
| 365 | static struct cache_detail nametoid_cache = { | 363 | static struct cache_detail nametoid_cache_template = { |
| 366 | .owner = THIS_MODULE, | 364 | .owner = THIS_MODULE, |
| 367 | .hash_size = ENT_HASHMAX, | 365 | .hash_size = ENT_HASHMAX, |
| 368 | .hash_table = nametoid_table, | ||
| 369 | .name = "nfs4.nametoid", | 366 | .name = "nfs4.nametoid", |
| 370 | .cache_put = ent_put, | 367 | .cache_put = ent_put, |
| 371 | .cache_upcall = nametoid_upcall, | 368 | .cache_upcall = nametoid_upcall, |
| @@ -479,11 +476,18 @@ nfsd_idmap_init(struct net *net) | |||
| 479 | rv = cache_register_net(nn->idtoname_cache, net); | 476 | rv = cache_register_net(nn->idtoname_cache, net); |
| 480 | if (rv) | 477 | if (rv) |
| 481 | goto destroy_idtoname_cache; | 478 | goto destroy_idtoname_cache; |
| 482 | rv = cache_register_net(&nametoid_cache, net); | 479 | nn->nametoid_cache = cache_create_net(&nametoid_cache_template, net); |
| 483 | if (rv) | 480 | if (IS_ERR(nn->nametoid_cache)) { |
| 481 | rv = PTR_ERR(nn->idtoname_cache); | ||
| 484 | goto unregister_idtoname_cache; | 482 | goto unregister_idtoname_cache; |
| 483 | } | ||
| 484 | rv = cache_register_net(nn->nametoid_cache, net); | ||
| 485 | if (rv) | ||
| 486 | goto destroy_nametoid_cache; | ||
| 485 | return 0; | 487 | return 0; |
| 486 | 488 | ||
| 489 | destroy_nametoid_cache: | ||
| 490 | cache_destroy_net(nn->nametoid_cache, net); | ||
| 487 | unregister_idtoname_cache: | 491 | unregister_idtoname_cache: |
| 488 | cache_unregister_net(nn->idtoname_cache, net); | 492 | cache_unregister_net(nn->idtoname_cache, net); |
| 489 | destroy_idtoname_cache: | 493 | destroy_idtoname_cache: |
| @@ -497,8 +501,9 @@ nfsd_idmap_shutdown(struct net *net) | |||
| 497 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | 501 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
| 498 | 502 | ||
| 499 | cache_unregister_net(nn->idtoname_cache, net); | 503 | cache_unregister_net(nn->idtoname_cache, net); |
| 500 | cache_unregister_net(&nametoid_cache, net); | 504 | cache_unregister_net(nn->nametoid_cache, net); |
| 501 | cache_destroy_net(nn->idtoname_cache, net); | 505 | cache_destroy_net(nn->idtoname_cache, net); |
| 506 | cache_destroy_net(nn->nametoid_cache, net); | ||
| 502 | } | 507 | } |
| 503 | 508 | ||
| 504 | static int | 509 | static int |
| @@ -541,19 +546,20 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen | |||
| 541 | .type = type, | 546 | .type = type, |
| 542 | }; | 547 | }; |
| 543 | int ret; | 548 | int ret; |
| 549 | struct nfsd_net *nn = net_generic(rqstp->rq_xprt->xpt_net, nfsd_net_id); | ||
| 544 | 550 | ||
| 545 | if (namelen + 1 > sizeof(key.name)) | 551 | if (namelen + 1 > sizeof(key.name)) |
| 546 | return nfserr_badowner; | 552 | return nfserr_badowner; |
| 547 | memcpy(key.name, name, namelen); | 553 | memcpy(key.name, name, namelen); |
| 548 | key.name[namelen] = '\0'; | 554 | key.name[namelen] = '\0'; |
| 549 | strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname)); | 555 | strlcpy(key.authname, rqst_authname(rqstp), sizeof(key.authname)); |
| 550 | ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item); | 556 | ret = idmap_lookup(rqstp, nametoid_lookup, &key, nn->nametoid_cache, &item); |
| 551 | if (ret == -ENOENT) | 557 | if (ret == -ENOENT) |
| 552 | return nfserr_badowner; | 558 | return nfserr_badowner; |
| 553 | if (ret) | 559 | if (ret) |
| 554 | return nfserrno(ret); | 560 | return nfserrno(ret); |
| 555 | *id = item->id; | 561 | *id = item->id; |
| 556 | cache_put(&item->h, &nametoid_cache); | 562 | cache_put(&item->h, nn->nametoid_cache); |
| 557 | return 0; | 563 | return 0; |
| 558 | } | 564 | } |
| 559 | 565 | ||
