提交 13bbc06a 编写于 作者: T Trond Myklebust 提交者: Linus Torvalds

[PATCH] NFS: Fix NFSv4 callback regression

The change in semantics for nfs_find_client() introduced by David breaks the
NFSv4 callback channel.

Also, replace another completely broken BUG_ON() in nfs_find_client().  In
initialised clients, clp->cl_cons_state == 0, and callers of that function
should in any case never want to see clients that are uninitialised.
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 7d9ac06f
...@@ -232,11 +232,15 @@ void nfs_put_client(struct nfs_client *clp) ...@@ -232,11 +232,15 @@ void nfs_put_client(struct nfs_client *clp)
* Find a client by address * Find a client by address
* - caller must hold nfs_client_lock * - caller must hold nfs_client_lock
*/ */
static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int nfsversion) static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int nfsversion, int match_port)
{ {
struct nfs_client *clp; struct nfs_client *clp;
list_for_each_entry(clp, &nfs_client_list, cl_share_link) { list_for_each_entry(clp, &nfs_client_list, cl_share_link) {
/* Don't match clients that failed to initialise properly */
if (clp->cl_cons_state < 0)
continue;
/* Different NFS versions cannot share the same nfs_client */ /* Different NFS versions cannot share the same nfs_client */
if (clp->cl_nfsversion != nfsversion) if (clp->cl_nfsversion != nfsversion)
continue; continue;
...@@ -245,7 +249,7 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int ...@@ -245,7 +249,7 @@ static struct nfs_client *__nfs_find_client(const struct sockaddr_in *addr, int
sizeof(clp->cl_addr.sin_addr)) != 0) sizeof(clp->cl_addr.sin_addr)) != 0)
continue; continue;
if (clp->cl_addr.sin_port == addr->sin_port) if (!match_port || clp->cl_addr.sin_port == addr->sin_port)
goto found; goto found;
} }
...@@ -265,11 +269,12 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in *addr, int nfsversio ...@@ -265,11 +269,12 @@ struct nfs_client *nfs_find_client(const struct sockaddr_in *addr, int nfsversio
struct nfs_client *clp; struct nfs_client *clp;
spin_lock(&nfs_client_lock); spin_lock(&nfs_client_lock);
clp = __nfs_find_client(addr, nfsversion); clp = __nfs_find_client(addr, nfsversion, 0);
spin_unlock(&nfs_client_lock); spin_unlock(&nfs_client_lock);
if (clp != NULL && clp->cl_cons_state != NFS_CS_READY) {
BUG_ON(clp && clp->cl_cons_state == 0); nfs_put_client(clp);
clp = NULL;
}
return clp; return clp;
} }
...@@ -292,7 +297,7 @@ static struct nfs_client *nfs_get_client(const char *hostname, ...@@ -292,7 +297,7 @@ static struct nfs_client *nfs_get_client(const char *hostname,
do { do {
spin_lock(&nfs_client_lock); spin_lock(&nfs_client_lock);
clp = __nfs_find_client(addr, nfsversion); clp = __nfs_find_client(addr, nfsversion, 1);
if (clp) if (clp)
goto found_client; goto found_client;
if (new) if (new)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册