diff options
author | Trond Myklebust <trondmy@gmail.com> | 2018-10-01 10:41:47 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2018-10-29 16:58:04 -0400 |
commit | 9ceddd9da13434a5906255c0fc528c385aded283 (patch) | |
tree | d5ed18e9728d773bab61fdda32417c13c00f94af | |
parent | fd5d2f78261bedd3a40feb1474323fddb88398b8 (diff) |
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>
-rw-r--r-- | fs/nfsd/export.c | 14 | ||||
-rw-r--r-- | fs/nfsd/export.h | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index a1143f7c2201..802993d8912f 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -46,7 +46,7 @@ static void expkey_put(struct kref *ref) | |||
46 | !test_bit(CACHE_NEGATIVE, &key->h.flags)) | 46 | !test_bit(CACHE_NEGATIVE, &key->h.flags)) |
47 | path_put(&key->ek_path); | 47 | path_put(&key->ek_path); |
48 | auth_domain_put(key->ek_client); | 48 | auth_domain_put(key->ek_client); |
49 | kfree(key); | 49 | kfree_rcu(key, ek_rcu); |
50 | } | 50 | } |
51 | 51 | ||
52 | static void expkey_request(struct cache_detail *cd, | 52 | static void expkey_request(struct cache_detail *cd, |
@@ -265,7 +265,7 @@ svc_expkey_lookup(struct cache_detail *cd, struct svc_expkey *item) | |||
265 | struct cache_head *ch; | 265 | struct cache_head *ch; |
266 | int hash = svc_expkey_hash(item); | 266 | int hash = svc_expkey_hash(item); |
267 | 267 | ||
268 | ch = sunrpc_cache_lookup(cd, &item->h, hash); | 268 | ch = sunrpc_cache_lookup_rcu(cd, &item->h, hash); |
269 | if (ch) | 269 | if (ch) |
270 | return container_of(ch, struct svc_expkey, h); | 270 | return container_of(ch, struct svc_expkey, h); |
271 | else | 271 | else |
@@ -314,7 +314,7 @@ static void svc_export_put(struct kref *ref) | |||
314 | auth_domain_put(exp->ex_client); | 314 | auth_domain_put(exp->ex_client); |
315 | nfsd4_fslocs_free(&exp->ex_fslocs); | 315 | nfsd4_fslocs_free(&exp->ex_fslocs); |
316 | kfree(exp->ex_uuid); | 316 | kfree(exp->ex_uuid); |
317 | kfree(exp); | 317 | kfree_rcu(exp, ex_rcu); |
318 | } | 318 | } |
319 | 319 | ||
320 | static void svc_export_request(struct cache_detail *cd, | 320 | static void svc_export_request(struct cache_detail *cd, |
@@ -780,7 +780,7 @@ svc_export_lookup(struct svc_export *exp) | |||
780 | struct cache_head *ch; | 780 | struct cache_head *ch; |
781 | int hash = svc_export_hash(exp); | 781 | int hash = svc_export_hash(exp); |
782 | 782 | ||
783 | ch = sunrpc_cache_lookup(exp->cd, &exp->h, hash); | 783 | ch = sunrpc_cache_lookup_rcu(exp->cd, &exp->h, hash); |
784 | if (ch) | 784 | if (ch) |
785 | return container_of(ch, struct svc_export, h); | 785 | return container_of(ch, struct svc_export, h); |
786 | else | 786 | else |
@@ -1216,9 +1216,9 @@ static int e_show(struct seq_file *m, void *p) | |||
1216 | } | 1216 | } |
1217 | 1217 | ||
1218 | const struct seq_operations nfs_exports_op = { | 1218 | const struct seq_operations nfs_exports_op = { |
1219 | .start = cache_seq_start, | 1219 | .start = cache_seq_start_rcu, |
1220 | .next = cache_seq_next, | 1220 | .next = cache_seq_next_rcu, |
1221 | .stop = cache_seq_stop, | 1221 | .stop = cache_seq_stop_rcu, |
1222 | .show = e_show, | 1222 | .show = e_show, |
1223 | }; | 1223 | }; |
1224 | 1224 | ||
diff --git a/fs/nfsd/export.h b/fs/nfsd/export.h index c8b74126ddaa..e7daa1f246f0 100644 --- a/fs/nfsd/export.h +++ b/fs/nfsd/export.h | |||
@@ -61,6 +61,7 @@ struct svc_export { | |||
61 | u32 ex_layout_types; | 61 | u32 ex_layout_types; |
62 | struct nfsd4_deviceid_map *ex_devid_map; | 62 | struct nfsd4_deviceid_map *ex_devid_map; |
63 | struct cache_detail *cd; | 63 | struct cache_detail *cd; |
64 | struct rcu_head ex_rcu; | ||
64 | }; | 65 | }; |
65 | 66 | ||
66 | /* an "export key" (expkey) maps a filehandlefragement to an | 67 | /* an "export key" (expkey) maps a filehandlefragement to an |
@@ -75,6 +76,7 @@ struct svc_expkey { | |||
75 | u32 ek_fsid[6]; | 76 | u32 ek_fsid[6]; |
76 | 77 | ||
77 | struct path ek_path; | 78 | struct path ek_path; |
79 | struct rcu_head ek_rcu; | ||
78 | }; | 80 | }; |
79 | 81 | ||
80 | #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) | 82 | #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC)) |