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

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>

authored by

Trond Myklebust and committed by
J. Bruce Fields
fd5d2f78 ae74136b

+8 -6
+8 -6
net/sunrpc/svcauth_unix.c
··· 97 97 char m_class[8]; /* e.g. "nfsd" */ 98 98 struct in6_addr m_addr; 99 99 struct unix_domain *m_client; 100 + struct rcu_head m_rcu; 100 101 }; 101 102 102 103 static void ip_map_put(struct kref *kref) ··· 108 107 if (test_bit(CACHE_VALID, &item->flags) && 109 108 !test_bit(CACHE_NEGATIVE, &item->flags)) 110 109 auth_domain_put(&im->m_client->h); 111 - kfree(im); 110 + kfree_rcu(im, m_rcu); 112 111 } 113 112 114 113 static inline int hash_ip6(const struct in6_addr *ip) ··· 287 286 288 287 strcpy(ip.m_class, class); 289 288 ip.m_addr = *addr; 290 - ch = sunrpc_cache_lookup(cd, &ip.h, 291 - hash_str(class, IP_HASHBITS) ^ 292 - hash_ip6(addr)); 289 + ch = sunrpc_cache_lookup_rcu(cd, &ip.h, 290 + hash_str(class, IP_HASHBITS) ^ 291 + hash_ip6(addr)); 293 292 294 293 if (ch) 295 294 return container_of(ch, struct ip_map, h); ··· 419 418 struct cache_head h; 420 419 kuid_t uid; 421 420 struct group_info *gi; 421 + struct rcu_head rcu; 422 422 }; 423 423 424 424 static int unix_gid_hash(kuid_t uid) ··· 434 432 if (test_bit(CACHE_VALID, &item->flags) && 435 433 !test_bit(CACHE_NEGATIVE, &item->flags)) 436 434 put_group_info(ug->gi); 437 - kfree(ug); 435 + kfree_rcu(ug, rcu); 438 436 } 439 437 440 438 static int unix_gid_match(struct cache_head *corig, struct cache_head *cnew) ··· 627 625 struct cache_head *ch; 628 626 629 627 ug.uid = uid; 630 - ch = sunrpc_cache_lookup(cd, &ug.h, unix_gid_hash(uid)); 628 + ch = sunrpc_cache_lookup_rcu(cd, &ug.h, unix_gid_hash(uid)); 631 629 if (ch) 632 630 return container_of(ch, struct unix_gid, h); 633 631 else