Commit 202c312d authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Fix NFSv4 trunking discovery

If walking the list in nfs4[01]_walk_client_list fails, then the most
likely explanation is that the server dropped the clientid before we
actually managed to confirm it. As long as our nfs_client is the very
last one in the list to be tested, the caller can be assured that this
is the case when the final return value is NFS4ERR_STALE_CLIENTID.
Reported-by: default avatarBen Greear <greearb@candelatech.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: stable@vger.kernel.org [>=3.7]
Tested-by: default avatarBen Greear <greearb@candelatech.com>
parent 4ae19c2d
...@@ -352,14 +352,8 @@ int nfs40_walk_client_list(struct nfs_client *new, ...@@ -352,14 +352,8 @@ int nfs40_walk_client_list(struct nfs_client *new,
} }
spin_unlock(&nn->nfs_client_lock); spin_unlock(&nn->nfs_client_lock);
/* No match found. The server lost our clientid */
out: out:
/*
* No matching nfs_client found. This should be impossible,
* because the new nfs_client has already been added to
* nfs_client_list by nfs_get_client().
*
* Don't BUG(), since the caller is holding a mutex.
*/
if (prev) if (prev)
nfs_put_client(prev); nfs_put_client(prev);
dprintk("NFS: <-- %s status = %d\n", __func__, status); dprintk("NFS: <-- %s status = %d\n", __func__, status);
...@@ -430,7 +424,7 @@ int nfs41_walk_client_list(struct nfs_client *new, ...@@ -430,7 +424,7 @@ int nfs41_walk_client_list(struct nfs_client *new,
{ {
struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id);
struct nfs_client *pos, *n, *prev = NULL; struct nfs_client *pos, *n, *prev = NULL;
int error; int status = -NFS4ERR_STALE_CLIENTID;
spin_lock(&nn->nfs_client_lock); spin_lock(&nn->nfs_client_lock);
list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) { list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) {
...@@ -446,8 +440,8 @@ int nfs41_walk_client_list(struct nfs_client *new, ...@@ -446,8 +440,8 @@ int nfs41_walk_client_list(struct nfs_client *new,
nfs_put_client(prev); nfs_put_client(prev);
prev = pos; prev = pos;
error = nfs_wait_client_init_complete(pos); status = nfs_wait_client_init_complete(pos);
if (error < 0) { if (status < 0) {
nfs_put_client(pos); nfs_put_client(pos);
spin_lock(&nn->nfs_client_lock); spin_lock(&nn->nfs_client_lock);
continue; continue;
...@@ -480,16 +474,10 @@ int nfs41_walk_client_list(struct nfs_client *new, ...@@ -480,16 +474,10 @@ int nfs41_walk_client_list(struct nfs_client *new,
return 0; return 0;
} }
/* /* No matching nfs_client found. */
* No matching nfs_client found. This should be impossible,
* because the new nfs_client has already been added to
* nfs_client_list by nfs_get_client().
*
* Don't BUG(), since the caller is holding a mutex.
*/
spin_unlock(&nn->nfs_client_lock); spin_unlock(&nn->nfs_client_lock);
pr_err("NFS: %s Error: no matching nfs_client found\n", __func__); dprintk("NFS: <-- %s status = %d\n", __func__, status);
return -NFS4ERR_STALE_CLIENTID; return status;
} }
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
......
...@@ -136,16 +136,11 @@ int nfs40_discover_server_trunking(struct nfs_client *clp, ...@@ -136,16 +136,11 @@ int nfs40_discover_server_trunking(struct nfs_client *clp,
clp->cl_confirm = clid.confirm; clp->cl_confirm = clid.confirm;
status = nfs40_walk_client_list(clp, result, cred); status = nfs40_walk_client_list(clp, result, cred);
switch (status) { if (status == 0) {
case -NFS4ERR_STALE_CLIENTID:
set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
case 0:
/* Sustain the lease, even if it's empty. If the clientid4 /* Sustain the lease, even if it's empty. If the clientid4
* goes stale it's of no use for trunking discovery. */ * goes stale it's of no use for trunking discovery. */
nfs4_schedule_state_renewal(*result); nfs4_schedule_state_renewal(*result);
break;
} }
out: out:
return status; return status;
} }
...@@ -1863,6 +1858,7 @@ int nfs4_discover_server_trunking(struct nfs_client *clp, ...@@ -1863,6 +1858,7 @@ int nfs4_discover_server_trunking(struct nfs_client *clp,
case -ETIMEDOUT: case -ETIMEDOUT:
case -EAGAIN: case -EAGAIN:
ssleep(1); ssleep(1);
case -NFS4ERR_STALE_CLIENTID:
dprintk("NFS: %s after status %d, retrying\n", dprintk("NFS: %s after status %d, retrying\n",
__func__, status); __func__, status);
goto again; goto again;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment