Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stanislav Kinsbursky and committed by
J. Bruce Fields
f890edbb c89172e3

+24 -26
+24 -26
fs/nfsd/nfs4idmap.c
··· 183 183 184 184 185 185 static int idtoname_parse(struct cache_detail *, char *, int); 186 - static struct ent *idtoname_lookup(struct ent *); 187 - static struct ent *idtoname_update(struct ent *, struct ent *); 186 + static struct ent *idtoname_lookup(struct cache_detail *, struct ent *); 187 + static struct ent *idtoname_update(struct cache_detail *, struct ent *, 188 + struct ent *); 188 189 189 190 static struct cache_detail idtoname_cache = { 190 191 .owner = THIS_MODULE, ··· 245 244 goto out; 246 245 247 246 error = -ENOMEM; 248 - res = idtoname_lookup(&ent); 247 + res = idtoname_lookup(cd, &ent); 249 248 if (!res) 250 249 goto out; 251 250 ··· 261 260 else 262 261 memcpy(ent.name, buf1, sizeof(ent.name)); 263 262 error = -ENOMEM; 264 - res = idtoname_update(&ent, res); 263 + res = idtoname_update(cd, &ent, res); 265 264 if (res == NULL) 266 265 goto out; 267 266 268 - cache_put(&res->h, &idtoname_cache); 267 + cache_put(&res->h, cd); 269 268 270 269 error = 0; 271 270 out: ··· 276 275 277 276 278 277 static struct ent * 279 - idtoname_lookup(struct ent *item) 278 + idtoname_lookup(struct cache_detail *cd, struct ent *item) 280 279 { 281 - struct cache_head *ch = sunrpc_cache_lookup(&idtoname_cache, 282 - &item->h, 280 + struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h, 283 281 idtoname_hash(item)); 284 282 if (ch) 285 283 return container_of(ch, struct ent, h); ··· 287 287 } 288 288 289 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, 293 - &new->h, &old->h, 292 + struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h, 294 293 idtoname_hash(new)); 295 294 if (ch) 296 295 return container_of(ch, struct ent, h); ··· 358 359 return 0; 359 360 } 360 361 361 - static struct ent *nametoid_lookup(struct ent *); 362 - static struct ent *nametoid_update(struct ent *, struct ent *); 362 + static struct ent *nametoid_lookup(struct cache_detail *, struct ent *); 363 + static struct ent *nametoid_update(struct cache_detail *, struct ent *, 364 + struct ent *); 363 365 static int nametoid_parse(struct cache_detail *, char *, int); 364 366 365 367 static struct cache_detail nametoid_cache = { ··· 426 426 set_bit(CACHE_NEGATIVE, &ent.h.flags); 427 427 428 428 error = -ENOMEM; 429 - res = nametoid_lookup(&ent); 429 + res = nametoid_lookup(cd, &ent); 430 430 if (res == NULL) 431 431 goto out; 432 - res = nametoid_update(&ent, res); 432 + res = nametoid_update(cd, &ent, res); 433 433 if (res == NULL) 434 434 goto out; 435 435 436 - cache_put(&res->h, &nametoid_cache); 436 + cache_put(&res->h, cd); 437 437 error = 0; 438 438 out: 439 439 kfree(buf1); ··· 443 443 444 444 445 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, 449 - &item->h, 448 + struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h, 450 449 nametoid_hash(item)); 451 450 if (ch) 452 451 return container_of(ch, struct ent, h); ··· 454 455 } 455 456 456 457 static struct ent * 457 - nametoid_update(struct ent *new, struct ent *old) 458 + nametoid_update(struct cache_detail *cd, struct ent *new, struct ent *old) 458 459 { 459 - struct cache_head *ch = sunrpc_cache_update(&nametoid_cache, 460 - &new->h, &old->h, 460 + struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h, 461 461 nametoid_hash(new)); 462 462 if (ch) 463 463 return container_of(ch, struct ent, h); ··· 491 493 492 494 static int 493 495 idmap_lookup(struct svc_rqst *rqstp, 494 - struct ent *(*lookup_fn)(struct ent *), struct ent *key, 495 - struct cache_detail *detail, struct ent **item) 496 + struct ent *(*lookup_fn)(struct cache_detail *, struct ent *), 497 + struct ent *key, struct cache_detail *detail, struct ent **item) 496 498 { 497 499 int ret; 498 500 499 - *item = lookup_fn(key); 501 + *item = lookup_fn(detail, key); 500 502 if (!*item) 501 503 return -ENOMEM; 502 504 retry: ··· 504 506 505 507 if (ret == -ETIMEDOUT) { 506 508 struct ent *prev_item = *item; 507 - *item = lookup_fn(key); 509 + *item = lookup_fn(detail, key); 508 510 if (*item != prev_item) 509 511 goto retry; 510 512 cache_put(&(*item)->h, detail);