Skip to content

Commit 9ceddd9

Browse files
trondmyJ. Bruce Fields
authored andcommitted
knfsd: Allow lockless lookups of the exports
Convert structs svc_expkey and svc_export to allow RCU protected lookups. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent fd5d2f7 commit 9ceddd9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

fs/nfsd/export.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static void expkey_put(struct kref *ref)
4646
!test_bit(CACHE_NEGATIVE, &key->h.flags))
4747
path_put(&key->ek_path);
4848
auth_domain_put(key->ek_client);
49-
kfree(key);
49+
kfree_rcu(key, ek_rcu);
5050
}
5151

5252
static void expkey_request(struct cache_detail *cd,
@@ -265,7 +265,7 @@ svc_expkey_lookup(struct cache_detail *cd, struct svc_expkey *item)
265265
struct cache_head *ch;
266266
int hash = svc_expkey_hash(item);
267267

268-
ch = sunrpc_cache_lookup(cd, &item->h, hash);
268+
ch = sunrpc_cache_lookup_rcu(cd, &item->h, hash);
269269
if (ch)
270270
return container_of(ch, struct svc_expkey, h);
271271
else
@@ -314,7 +314,7 @@ static void svc_export_put(struct kref *ref)
314314
auth_domain_put(exp->ex_client);
315315
nfsd4_fslocs_free(&exp->ex_fslocs);
316316
kfree(exp->ex_uuid);
317-
kfree(exp);
317+
kfree_rcu(exp, ex_rcu);
318318
}
319319

320320
static void svc_export_request(struct cache_detail *cd,
@@ -780,7 +780,7 @@ svc_export_lookup(struct svc_export *exp)
780780
struct cache_head *ch;
781781
int hash = svc_export_hash(exp);
782782

783-
ch = sunrpc_cache_lookup(exp->cd, &exp->h, hash);
783+
ch = sunrpc_cache_lookup_rcu(exp->cd, &exp->h, hash);
784784
if (ch)
785785
return container_of(ch, struct svc_export, h);
786786
else
@@ -1216,9 +1216,9 @@ static int e_show(struct seq_file *m, void *p)
12161216
}
12171217

12181218
const struct seq_operations nfs_exports_op = {
1219-
.start = cache_seq_start,
1220-
.next = cache_seq_next,
1221-
.stop = cache_seq_stop,
1219+
.start = cache_seq_start_rcu,
1220+
.next = cache_seq_next_rcu,
1221+
.stop = cache_seq_stop_rcu,
12221222
.show = e_show,
12231223
};
12241224

fs/nfsd/export.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ struct svc_export {
6161
u32 ex_layout_types;
6262
struct nfsd4_deviceid_map *ex_devid_map;
6363
struct cache_detail *cd;
64+
struct rcu_head ex_rcu;
6465
};
6566

6667
/* an "export key" (expkey) maps a filehandlefragement to an
@@ -75,6 +76,7 @@ struct svc_expkey {
7576
u32 ek_fsid[6];
7677

7778
struct path ek_path;
79+
struct rcu_head ek_rcu;
7880
};
7981

8082
#define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))

0 commit comments

Comments
 (0)