diff options
| author | Stanislav Kinsbursky <skinsbursky@parallels.com> | 2012-03-29 11:34:16 -0400 |
|---|---|---|
| committer | J. Bruce Fields <bfields@redhat.com> | 2012-04-11 17:55:05 -0400 |
| commit | f890edbbeff6928b7db0c6179a9036cbd4f0efbf (patch) | |
| tree | 82c057972c3b9e5247a1f6be8a3f99850a05cb96 | |
| parent | c89172e36e3d3972f9f3fa107c1f3e666f1e05cf (diff) | |
NFSd: remove hard-coded dereferences to name-to-id and id-to-name caches
These dereferences to global static caches are redundant. They also prevents
converting these caches into per-net ones. So this patch is cleanup + precursor
of patch set,a which will make them per-net.
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| -rw-r--r-- | fs/nfsd/nfs4idmap.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c index 322d11ce06a..2ff44708ea9 100644 --- a/fs/nfsd/nfs4idmap.c +++ b/fs/nfsd/nfs4idmap.c | |||
| @@ -183,8 +183,9 @@ warn_no_idmapd(struct cache_detail *detail, int has_died) | |||
| 183 | 183 | ||
| 184 | 184 | ||
| 185 | static int idtoname_parse(struct cache_detail *, char *, int); | 185 | static int idtoname_parse(struct cache_detail *, char *, int); |
| 186 | static struct ent *idtoname_lookup(struct ent *); | 186 | static struct ent *idtoname_lookup(struct cache_detail *, struct ent *); |
| 187 | static struct ent *idtoname_update(struct ent *, struct ent *); | 187 | static struct ent *idtoname_update(struct cache_detail *, struct ent *, |
| 188 | struct ent *); | ||
| 188 | 189 | ||
| 189 | static struct cache_detail idtoname_cache = { | 190 | static struct cache_detail idtoname_cache = { |
| 190 | .owner = THIS_MODULE, | 191 | .owner = THIS_MODULE, |
| @@ -244,7 +245,7 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen) | |||
| 244 | goto out; | 245 | goto out; |
| 245 | 246 | ||
| 246 | error = -ENOMEM; | 247 | error = -ENOMEM; |
| 247 | res = idtoname_lookup(&ent); | 248 | res = idtoname_lookup(cd, &ent); |
| 248 | if (!res) | 249 | if (!res) |
| 249 | goto out; | 250 | goto out; |
| 250 | 251 | ||
| @@ -260,11 +261,11 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen) | |||
| 260 | else | 261 | else |
| 261 | memcpy(ent.name, buf1, sizeof(ent.name)); | 262 | memcpy(ent.name, buf1, sizeof(ent.name)); |
| 262 | error = -ENOMEM; | 263 | error = -ENOMEM; |
| 263 | res = idtoname_update(&ent, res); | 264 | res = idtoname_update(cd, &ent, res); |
| 264 | if (res == NULL) | 265 | if (res == NULL) |
| 265 | goto out; | 266 | goto out; |
| 266 | 267 | ||
| 267 | cache_put(&res->h, &idtoname_cache); | 268 | cache_put(&res->h, cd); |
| 268 | 269 | ||
| 269 | error = 0; | 270 | error = 0; |
| 270 | out: | 271 | out: |
| @@ -275,10 +276,9 @@ out: | |||
| 275 | 276 | ||
| 276 | 277 | ||
| 277 | static struct ent * | 278 | static struct ent * |
| 278 | idtoname_lookup(struct ent *item) | 279 | idtoname_lookup(struct cache_detail *cd, struct ent *item) |
| 279 | { | 280 | { |
| 280 | struct cache_head *ch = sunrpc_cache_lookup(&idtoname_cache, | 281 | struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h, |
| 281 | &item->h, | ||
| 282 | idtoname_hash(item)); | 282 | idtoname_hash(item)); |
| 283 | if (ch) | 283 | if (ch) |
| 284 | return container_of(ch, struct ent, h); | 284 | return container_of(ch, struct ent, h); |
| @@ -287,10 +287,9 @@ idtoname_lookup(struct ent *item) | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | static struct ent * | 289 | static struct ent * |
| 290 | idtoname_update(struct ent *new, struct ent *old) | 290 | idtoname_update(struct cache_detail *cd, struct ent *new, struct ent *old) |
| 291 | { | 291 | { |
| 292 | struct cache_head *ch = sunrpc_cache_update(&idtoname_cache, | 292 | struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h, |
| 293 | &new->h, &old->h, | ||
| 294 | idtoname_hash(new)); | 293 | idtoname_hash(new)); |
| 295 | if (ch) | 294 | if (ch) |
| 296 | return container_of(ch, struct ent, h); | 295 | return container_of(ch, struct ent, h); |
| @@ -359,8 +358,9 @@ nametoid_show(struct seq_file *m, struct cache_detail *cd, struct cache_head *h) | |||
| 359 | return 0; | 358 | return 0; |
| 360 | } | 359 | } |
| 361 | 360 | ||
| 362 | static struct ent *nametoid_lookup(struct ent *); | 361 | static struct ent *nametoid_lookup(struct cache_detail *, struct ent *); |
| 363 | static struct ent *nametoid_update(struct ent *, struct ent *); | 362 | static struct ent *nametoid_update(struct cache_detail *, struct ent *, |
| 363 | struct ent *); | ||
| 364 | static int nametoid_parse(struct cache_detail *, char *, int); | 364 | static int nametoid_parse(struct cache_detail *, char *, int); |
| 365 | 365 | ||
| 366 | static struct cache_detail nametoid_cache = { | 366 | static struct cache_detail nametoid_cache = { |
| @@ -426,14 +426,14 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen) | |||
| 426 | set_bit(CACHE_NEGATIVE, &ent.h.flags); | 426 | set_bit(CACHE_NEGATIVE, &ent.h.flags); |
| 427 | 427 | ||
| 428 | error = -ENOMEM; | 428 | error = -ENOMEM; |
| 429 | res = nametoid_lookup(&ent); | 429 | res = nametoid_lookup(cd, &ent); |
| 430 | if (res == NULL) | 430 | if (res == NULL) |
| 431 | goto out; | 431 | goto out; |
| 432 | res = nametoid_update(&ent, res); | 432 | res = nametoid_update(cd, &ent, res); |
| 433 | if (res == NULL) | 433 | if (res == NULL) |
| 434 | goto out; | 434 | goto out; |
| 435 | 435 | ||
| 436 | cache_put(&res->h, &nametoid_cache); | 436 | cache_put(&res->h, cd); |
| 437 | error = 0; | 437 | error = 0; |
| 438 | out: | 438 | out: |
| 439 | kfree(buf1); | 439 | kfree(buf1); |
| @@ -443,10 +443,9 @@ out: | |||
| 443 | 443 | ||
| 444 | 444 | ||
| 445 | static struct ent * | 445 | static struct ent * |
| 446 | nametoid_lookup(struct ent *item) | 446 | nametoid_lookup(struct cache_detail *cd, struct ent *item) |
| 447 | { | 447 | { |
| 448 | struct cache_head *ch = sunrpc_cache_lookup(&nametoid_cache, | 448 | struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h, |
| 449 | &item->h, | ||
| 450 | nametoid_hash(item)); | 449 | nametoid_hash(item)); |
| 451 | if (ch) | 450 | if (ch) |
| 452 | return container_of(ch, struct ent, h); | 451 | return container_of(ch, struct ent, h); |
| @@ -455,10 +454,9 @@ nametoid_lookup(struct ent *item) | |||
| 455 | } | 454 | } |
| 456 | 455 | ||
| 457 | static struct ent * | 456 | static struct ent * |
| 458 | nametoid_update(struct ent *new, struct ent *old) | 457 | nametoid_update(struct cache_detail *cd, struct ent *new, struct ent *old) |
| 459 | { | 458 | { |
| 460 | struct cache_head *ch = sunrpc_cache_update(&nametoid_cache, | 459 | struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h, |
| 461 | &new->h, &old->h, | ||
| 462 | nametoid_hash(new)); | 460 | nametoid_hash(new)); |
| 463 | if (ch) | 461 | if (ch) |
| 464 | return container_of(ch, struct ent, h); | 462 | return container_of(ch, struct ent, h); |
| @@ -493,12 +491,12 @@ nfsd_idmap_shutdown(void) | |||
| 493 | 491 | ||
| 494 | static int | 492 | static int |
| 495 | idmap_lookup(struct svc_rqst *rqstp, | 493 | idmap_lookup(struct svc_rqst *rqstp, |
| 496 | struct ent *(*lookup_fn)(struct ent *), struct ent *key, | 494 | struct ent *(*lookup_fn)(struct cache_detail *, struct ent *), |
| 497 | struct cache_detail *detail, struct ent **item) | 495 | struct ent *key, struct cache_detail *detail, struct ent **item) |
| 498 | { | 496 | { |
| 499 | int ret; | 497 | int ret; |
| 500 | 498 | ||
| 501 | *item = lookup_fn(key); | 499 | *item = lookup_fn(detail, key); |
| 502 | if (!*item) | 500 | if (!*item) |
| 503 | return -ENOMEM; | 501 | return -ENOMEM; |
| 504 | retry: | 502 | retry: |
| @@ -506,7 +504,7 @@ idmap_lookup(struct svc_rqst *rqstp, | |||
| 506 | 504 | ||
| 507 | if (ret == -ETIMEDOUT) { | 505 | if (ret == -ETIMEDOUT) { |
| 508 | struct ent *prev_item = *item; | 506 | struct ent *prev_item = *item; |
| 509 | *item = lookup_fn(key); | 507 | *item = lookup_fn(detail, key); |
| 510 | if (*item != prev_item) | 508 | if (*item != prev_item) |
| 511 | goto retry; | 509 | goto retry; |
| 512 | cache_put(&(*item)->h, detail); | 510 | cache_put(&(*item)->h, detail); |
