From: Bryan Schumaker <bjschuma@xxxxxxxxxx> This list is used by nfs4_find_no_client_ident(), and needs to be locked before traversing. Since this function is about to move to a different file, I created functions to get a pointer to the list head and manage the lock. Signed-off-by: Bryan Schumaker <bjschuma@xxxxxxxxxx> --- fs/nfs/client.c | 26 ++++++++++++++++++++------ fs/nfs/nfs.h | 2 ++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 778ef62..56da3b6 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1177,17 +1177,18 @@ struct nfs_client * nfs4_find_client_no_ident(const struct sockaddr *addr) { struct nfs_client *clp; + struct list_head *cl_list = nfs_client_list_start(); - spin_lock(&nfs_client_lock); - list_for_each_entry(clp, &nfs_client_list, cl_share_link) { + list_for_each_entry(clp, cl_list, cl_share_link) { if (nfs4_cb_match_client(addr, clp, 0) == false) continue; atomic_inc(&clp->cl_count); - spin_unlock(&nfs_client_lock); - return clp; + goto out; } - spin_unlock(&nfs_client_lock); - return NULL; + clp = NULL; +out: + nfs_client_list_end(); + return clp; } /* @@ -1850,6 +1851,19 @@ static void nfs_server_list_stop(struct seq_file *p, void *v) spin_unlock(&nfs_client_lock); } +struct list_head *nfs_client_list_start(void) +{ + spin_lock(&nfs_client_lock); + return &nfs_client_list; +} +EXPORT_SYMBOL_GPL(nfs_client_list_start); + +void nfs_client_list_end(void) +{ + spin_unlock(&nfs_client_lock); +} +EXPORT_SYMBOL_GPL(nfs_client_list_end); + /* * display a header line followed by a load of call lines */ diff --git a/fs/nfs/nfs.h b/fs/nfs/nfs.h index 13321fd..5f2d632 100644 --- a/fs/nfs/nfs.h +++ b/fs/nfs/nfs.h @@ -66,6 +66,8 @@ void unregister_nfs_version(struct nfs_subversion *); struct nfs_server *nfs_alloc_server(void); struct nfs_server *do_nfs_clone_server(struct nfs_server *, struct nfs_server *, struct nfs_fh *, struct nfs_fattr *); +struct list_head *nfs_client_list_start(void); +void nfs_client_list_end(void); /* Exported in dir.c */ int nfs_lookup_revalidate(struct dentry *, struct nameidata *); -- 1.7.8.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html