Skip to content

Commit f890edb

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

1 file changed

Lines changed: 24 additions & 26 deletions

File tree

‎fs/nfsd/nfs4idmap.c‎

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,9 @@ warn_no_idmapd(struct cache_detail *detail, int has_died)
183183

184184

185185
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 *);
188189

189190
static struct cache_detail idtoname_cache = {
190191
.owner = THIS_MODULE,
@@ -244,7 +245,7 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
244245
goto out;
245246

246247
error = -ENOMEM;
247-
res = idtoname_lookup(&ent);
248+
res = idtoname_lookup(cd, &ent);
248249
if (!res)
249250
goto out;
250251

@@ -260,11 +261,11 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
260261
else
261262
memcpy(ent.name, buf1, sizeof(ent.name));
262263
error = -ENOMEM;
263-
res = idtoname_update(&ent, res);
264+
res = idtoname_update(cd, &ent, res);
264265
if (res == NULL)
265266
goto out;
266267

267-
cache_put(&res->h, &idtoname_cache);
268+
cache_put(&res->h, cd);
268269

269270
error = 0;
270271
out:
@@ -275,10 +276,9 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
275276

276277

277278
static struct ent *
278-
idtoname_lookup(struct ent *item)
279+
idtoname_lookup(struct cache_detail *cd, struct ent *item)
279280
{
280-
struct cache_head *ch = sunrpc_cache_lookup(&idtoname_cache,
281-
&item->h,
281+
struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
282282
idtoname_hash(item));
283283
if (ch)
284284
return container_of(ch, struct ent, h);
@@ -287,10 +287,9 @@ idtoname_lookup(struct ent *item)
287287
}
288288

289289
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)
291291
{
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,
294293
idtoname_hash(new));
295294
if (ch)
296295
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)
359358
return 0;
360359
}
361360

362-
static struct ent *nametoid_lookup(struct ent *);
363-
static struct ent *nametoid_update(struct ent *, struct ent *);
361+
static struct ent *nametoid_lookup(struct cache_detail *, struct ent *);
362+
static struct ent *nametoid_update(struct cache_detail *, struct ent *,
363+
struct ent *);
364364
static int nametoid_parse(struct cache_detail *, char *, int);
365365

366366
static struct cache_detail nametoid_cache = {
@@ -426,14 +426,14 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
426426
set_bit(CACHE_NEGATIVE, &ent.h.flags);
427427

428428
error = -ENOMEM;
429-
res = nametoid_lookup(&ent);
429+
res = nametoid_lookup(cd, &ent);
430430
if (res == NULL)
431431
goto out;
432-
res = nametoid_update(&ent, res);
432+
res = nametoid_update(cd, &ent, res);
433433
if (res == NULL)
434434
goto out;
435435

436-
cache_put(&res->h, &nametoid_cache);
436+
cache_put(&res->h, cd);
437437
error = 0;
438438
out:
439439
kfree(buf1);
@@ -443,10 +443,9 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
443443

444444

445445
static struct ent *
446-
nametoid_lookup(struct ent *item)
446+
nametoid_lookup(struct cache_detail *cd, struct ent *item)
447447
{
448-
struct cache_head *ch = sunrpc_cache_lookup(&nametoid_cache,
449-
&item->h,
448+
struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
450449
nametoid_hash(item));
451450
if (ch)
452451
return container_of(ch, struct ent, h);
@@ -455,10 +454,9 @@ nametoid_lookup(struct ent *item)
455454
}
456455

457456
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)
459458
{
460-
struct cache_head *ch = sunrpc_cache_update(&nametoid_cache,
461-
&new->h, &old->h,
459+
struct cache_head *ch = sunrpc_cache_update(cd, &new->h, &old->h,
462460
nametoid_hash(new));
463461
if (ch)
464462
return container_of(ch, struct ent, h);
@@ -493,20 +491,20 @@ nfsd_idmap_shutdown(void)
493491

494492
static int
495493
idmap_lookup(struct svc_rqst *rqstp,
496-
struct ent *(*lookup_fn)(struct ent *), struct ent *key,
497-
struct cache_detail *detail, struct ent **item)
494+
struct ent *(*lookup_fn)(struct cache_detail *, struct ent *),
495+
struct ent *key, struct cache_detail *detail, struct ent **item)
498496
{
499497
int ret;
500498

501-
*item = lookup_fn(key);
499+
*item = lookup_fn(detail, key);
502500
if (!*item)
503501
return -ENOMEM;
504502
retry:
505503
ret = cache_check(detail, &(*item)->h, &rqstp->rq_chandle);
506504

507505
if (ret == -ETIMEDOUT) {
508506
struct ent *prev_item = *item;
509-
*item = lookup_fn(key);
507+
*item = lookup_fn(detail, key);
510508
if (*item != prev_item)
511509
goto retry;
512510
cache_put(&(*item)->h, detail);

0 commit comments

Comments
 (0)