Skip to content

Commit 437f914

Browse files
trondmyJ. Bruce Fields
authored andcommitted
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>
1 parent 9d5afd9 commit 437f914

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

fs/nfs/dns_resolve.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct nfs_dns_ent {
6565

6666
struct sockaddr_storage addr;
6767
size_t addrlen;
68+
struct rcu_head rcu_head;
6869
};
6970

7071

@@ -101,15 +102,23 @@ static void nfs_dns_ent_init(struct cache_head *cnew,
101102
}
102103
}
103104

104-
static void nfs_dns_ent_put(struct kref *ref)
105+
static void nfs_dns_ent_free_rcu(struct rcu_head *head)
105106
{
106107
struct nfs_dns_ent *item;
107108

108-
item = container_of(ref, struct nfs_dns_ent, h.ref);
109+
item = container_of(head, struct nfs_dns_ent, rcu_head);
109110
kfree(item->hostname);
110111
kfree(item);
111112
}
112113

114+
static void nfs_dns_ent_put(struct kref *ref)
115+
{
116+
struct nfs_dns_ent *item;
117+
118+
item = container_of(ref, struct nfs_dns_ent, h.ref);
119+
call_rcu(item, nfs_dns_ent_free_rcu);
120+
}
121+
113122
static struct cache_head *nfs_dns_ent_alloc(void)
114123
{
115124
struct nfs_dns_ent *item = kmalloc(sizeof(*item), GFP_KERNEL);
@@ -195,7 +204,7 @@ static struct nfs_dns_ent *nfs_dns_lookup(struct cache_detail *cd,
195204
{
196205
struct cache_head *ch;
197206

198-
ch = sunrpc_cache_lookup(cd,
207+
ch = sunrpc_cache_lookup_rcu(cd,
199208
&key->h,
200209
nfs_dns_hash(key));
201210
if (!ch)

0 commit comments

Comments
 (0)