Skip to content

Commit 24d40a3

Browse files
trondmyJ. Bruce Fields
authored andcommitted
knfsd: Lockless lookup of NFSv4 identities.
Enable RCU protected lookups of the NFSv4 idmap. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent f2b112c commit 24d40a3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/nfsd/nfs4idmap.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct ent {
6565
u32 id;
6666
char name[IDMAP_NAMESZ];
6767
char authname[IDMAP_NAMESZ];
68+
struct rcu_head rcu_head;
6869
};
6970

7071
/* Common entry handling */
@@ -89,7 +90,7 @@ static void
8990
ent_put(struct kref *ref)
9091
{
9192
struct ent *map = container_of(ref, struct ent, h.ref);
92-
kfree(map);
93+
kfree_rcu(map, rcu_head);
9394
}
9495

9596
static struct cache_head *
@@ -264,8 +265,8 @@ idtoname_parse(struct cache_detail *cd, char *buf, int buflen)
264265
static struct ent *
265266
idtoname_lookup(struct cache_detail *cd, struct ent *item)
266267
{
267-
struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
268-
idtoname_hash(item));
268+
struct cache_head *ch = sunrpc_cache_lookup_rcu(cd, &item->h,
269+
idtoname_hash(item));
269270
if (ch)
270271
return container_of(ch, struct ent, h);
271272
else
@@ -422,8 +423,8 @@ nametoid_parse(struct cache_detail *cd, char *buf, int buflen)
422423
static struct ent *
423424
nametoid_lookup(struct cache_detail *cd, struct ent *item)
424425
{
425-
struct cache_head *ch = sunrpc_cache_lookup(cd, &item->h,
426-
nametoid_hash(item));
426+
struct cache_head *ch = sunrpc_cache_lookup_rcu(cd, &item->h,
427+
nametoid_hash(item));
427428
if (ch)
428429
return container_of(ch, struct ent, h);
429430
else

0 commit comments

Comments
 (0)