Ver código fonte

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>
Trond Myklebust 6 anos atrás
pai
commit
9ceddd9da1
2 arquivos alterados com 9 adições e 7 exclusões
  1. 7 7
      fs/nfsd/export.c
  2. 2 0
      fs/nfsd/export.h

+ 7 - 7
fs/nfsd/export.c

@@ -46,7 +46,7 @@ static void expkey_put(struct kref *ref)
 	    !test_bit(CACHE_NEGATIVE, &key->h.flags))
 	    !test_bit(CACHE_NEGATIVE, &key->h.flags))
 		path_put(&key->ek_path);
 		path_put(&key->ek_path);
 	auth_domain_put(key->ek_client);
 	auth_domain_put(key->ek_client);
-	kfree(key);
+	kfree_rcu(key, ek_rcu);
 }
 }
 
 
 static void expkey_request(struct cache_detail *cd,
 static void expkey_request(struct cache_detail *cd,
@@ -265,7 +265,7 @@ svc_expkey_lookup(struct cache_detail *cd, struct svc_expkey *item)
 	struct cache_head *ch;
 	struct cache_head *ch;
 	int hash = svc_expkey_hash(item);
 	int hash = svc_expkey_hash(item);
 
 
-	ch = sunrpc_cache_lookup(cd, &item->h, hash);
+	ch = sunrpc_cache_lookup_rcu(cd, &item->h, hash);
 	if (ch)
 	if (ch)
 		return container_of(ch, struct svc_expkey, h);
 		return container_of(ch, struct svc_expkey, h);
 	else
 	else
@@ -314,7 +314,7 @@ static void svc_export_put(struct kref *ref)
 	auth_domain_put(exp->ex_client);
 	auth_domain_put(exp->ex_client);
 	nfsd4_fslocs_free(&exp->ex_fslocs);
 	nfsd4_fslocs_free(&exp->ex_fslocs);
 	kfree(exp->ex_uuid);
 	kfree(exp->ex_uuid);
-	kfree(exp);
+	kfree_rcu(exp, ex_rcu);
 }
 }
 
 
 static void svc_export_request(struct cache_detail *cd,
 static void svc_export_request(struct cache_detail *cd,
@@ -780,7 +780,7 @@ svc_export_lookup(struct svc_export *exp)
 	struct cache_head *ch;
 	struct cache_head *ch;
 	int hash = svc_export_hash(exp);
 	int hash = svc_export_hash(exp);
 
 
-	ch = sunrpc_cache_lookup(exp->cd, &exp->h, hash);
+	ch = sunrpc_cache_lookup_rcu(exp->cd, &exp->h, hash);
 	if (ch)
 	if (ch)
 		return container_of(ch, struct svc_export, h);
 		return container_of(ch, struct svc_export, h);
 	else
 	else
@@ -1216,9 +1216,9 @@ static int e_show(struct seq_file *m, void *p)
 }
 }
 
 
 const struct seq_operations nfs_exports_op = {
 const struct seq_operations nfs_exports_op = {
-	.start	= cache_seq_start,
-	.next	= cache_seq_next,
-	.stop	= cache_seq_stop,
+	.start	= cache_seq_start_rcu,
+	.next	= cache_seq_next_rcu,
+	.stop	= cache_seq_stop_rcu,
 	.show	= e_show,
 	.show	= e_show,
 };
 };
 
 

+ 2 - 0
fs/nfsd/export.h

@@ -61,6 +61,7 @@ struct svc_export {
 	u32			ex_layout_types;
 	u32			ex_layout_types;
 	struct nfsd4_deviceid_map *ex_devid_map;
 	struct nfsd4_deviceid_map *ex_devid_map;
 	struct cache_detail	*cd;
 	struct cache_detail	*cd;
+	struct rcu_head		ex_rcu;
 };
 };
 
 
 /* an "export key" (expkey) maps a filehandlefragement to an
 /* an "export key" (expkey) maps a filehandlefragement to an
@@ -75,6 +76,7 @@ struct svc_expkey {
 	u32			ek_fsid[6];
 	u32			ek_fsid[6];
 
 
 	struct path		ek_path;
 	struct path		ek_path;
+	struct rcu_head		ek_rcu;
 };
 };
 
 
 #define EX_ISSYNC(exp)		(!((exp)->ex_flags & NFSEXP_ASYNC))
 #define EX_ISSYNC(exp)		(!((exp)->ex_flags & NFSEXP_ASYNC))