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

NFS: Lockless DNS lookups

Enable RCU protected lookup in the legacy DNS resolver.

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
437f9145 9d5afd94

+12 -3
+12 -3
fs/nfs/dns_resolve.c
··· 65 65 66 66 struct sockaddr_storage addr; 67 67 size_t addrlen; 68 + struct rcu_head rcu_head; 68 69 }; 69 70 70 71 ··· 102 101 } 103 102 } 104 103 104 + static void nfs_dns_ent_free_rcu(struct rcu_head *head) 105 + { 106 + struct nfs_dns_ent *item; 107 + 108 + item = container_of(head, struct nfs_dns_ent, rcu_head); 109 + kfree(item->hostname); 110 + kfree(item); 111 + } 112 + 105 113 static void nfs_dns_ent_put(struct kref *ref) 106 114 { 107 115 struct nfs_dns_ent *item; 108 116 109 117 item = container_of(ref, struct nfs_dns_ent, h.ref); 110 - kfree(item->hostname); 111 - kfree(item); 118 + call_rcu(item, nfs_dns_ent_free_rcu); 112 119 } 113 120 114 121 static struct cache_head *nfs_dns_ent_alloc(void) ··· 204 195 { 205 196 struct cache_head *ch; 206 197 207 - ch = sunrpc_cache_lookup(cd, 198 + ch = sunrpc_cache_lookup_rcu(cd, 208 199 &key->h, 209 200 nfs_dns_hash(key)); 210 201 if (!ch)