Skip to content

Commit 51e8586

Browse files
trondmyJ. Bruce Fields
authored andcommitted
SUNRPC: Make server side AUTH_UNIX use lockless lookups
Convert structs ip_map and unix_gid to use RCU protected lookups. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent b0e4dad commit 51e8586

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

net/sunrpc/svcauth_unix.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ struct ip_map {
9797
char m_class[8]; /* e.g. "nfsd" */
9898
struct in6_addr m_addr;
9999
struct unix_domain *m_client;
100+
struct rcu_head m_rcu;
100101
};
101102

102103
static void ip_map_put(struct kref *kref)
@@ -107,7 +108,7 @@ static void ip_map_put(struct kref *kref)
107108
if (test_bit(CACHE_VALID, &item->flags) &&
108109
!test_bit(CACHE_NEGATIVE, &item->flags))
109110
auth_domain_put(&im->m_client->h);
110-
kfree(im);
111+
kfree_rcu(im, m_rcu);
111112
}
112113

113114
static inline int hash_ip6(const struct in6_addr *ip)
@@ -286,9 +287,9 @@ static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class,
286287

287288
strcpy(ip.m_class, class);
288289
ip.m_addr = *addr;
289-
ch = sunrpc_cache_lookup(cd, &ip.h,
290-
hash_str(class, IP_HASHBITS) ^
291-
hash_ip6(addr));
290+
ch = sunrpc_cache_lookup_rcu(cd, &ip.h,
291+
hash_str(class, IP_HASHBITS) ^
292+
hash_ip6(addr));
292293

293294
if (ch)
294295
return container_of(ch, struct ip_map, h);
@@ -418,6 +419,7 @@ struct unix_gid {
418419
struct cache_head h;
419420
kuid_t uid;
420421
struct group_info *gi;
422+
struct rcu_head rcu;
421423
};
422424

423425
static int unix_gid_hash(kuid_t uid)
@@ -432,7 +434,7 @@ static void unix_gid_put(struct kref *kref)
432434
if (test_bit(CACHE_VALID, &item->flags) &&
433435
!test_bit(CACHE_NEGATIVE, &item->flags))
434436
put_group_info(ug->gi);
435-
kfree(ug);
437+
kfree_rcu(ug, rcu);
436438
}
437439

438440
static int unix_gid_match(struct cache_head *corig, struct cache_head *cnew)
@@ -625,7 +627,7 @@ static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid)
625627
struct cache_head *ch;
626628

627629
ug.uid = uid;
628-
ch = sunrpc_cache_lookup(cd, &ug.h, unix_gid_hash(uid));
630+
ch = sunrpc_cache_lookup_rcu(cd, &ug.h, unix_gid_hash(uid));
629631
if (ch)
630632
return container_of(ch, struct unix_gid, h);
631633
else

0 commit comments

Comments
 (0)