diff options
Diffstat (limited to 'fs/nfs')
| -rw-r--r-- | fs/nfs/nfs4client.c | 45 | ||||
| -rw-r--r-- | fs/nfs/nfs4proc.c | 1 | ||||
| -rw-r--r-- | fs/nfs/nfs4state.c | 8 |
3 files changed, 37 insertions, 17 deletions
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index ac4fc9a8fdbc..66b6664dcd4c 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c | |||
| @@ -300,7 +300,7 @@ int nfs40_walk_client_list(struct nfs_client *new, | |||
| 300 | struct rpc_cred *cred) | 300 | struct rpc_cred *cred) |
| 301 | { | 301 | { |
| 302 | struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); | 302 | struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); |
| 303 | struct nfs_client *pos, *n, *prev = NULL; | 303 | struct nfs_client *pos, *prev = NULL; |
| 304 | struct nfs4_setclientid_res clid = { | 304 | struct nfs4_setclientid_res clid = { |
| 305 | .clientid = new->cl_clientid, | 305 | .clientid = new->cl_clientid, |
| 306 | .confirm = new->cl_confirm, | 306 | .confirm = new->cl_confirm, |
| @@ -308,10 +308,23 @@ int nfs40_walk_client_list(struct nfs_client *new, | |||
| 308 | int status = -NFS4ERR_STALE_CLIENTID; | 308 | int status = -NFS4ERR_STALE_CLIENTID; |
| 309 | 309 | ||
| 310 | spin_lock(&nn->nfs_client_lock); | 310 | spin_lock(&nn->nfs_client_lock); |
| 311 | list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) { | 311 | list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { |
| 312 | /* If "pos" isn't marked ready, we can't trust the | 312 | /* If "pos" isn't marked ready, we can't trust the |
| 313 | * remaining fields in "pos" */ | 313 | * remaining fields in "pos" */ |
| 314 | if (pos->cl_cons_state < NFS_CS_READY) | 314 | if (pos->cl_cons_state > NFS_CS_READY) { |
| 315 | atomic_inc(&pos->cl_count); | ||
| 316 | spin_unlock(&nn->nfs_client_lock); | ||
| 317 | |||
| 318 | if (prev) | ||
| 319 | nfs_put_client(prev); | ||
| 320 | prev = pos; | ||
| 321 | |||
| 322 | status = nfs_wait_client_init_complete(pos); | ||
| 323 | spin_lock(&nn->nfs_client_lock); | ||
| 324 | if (status < 0) | ||
| 325 | continue; | ||
| 326 | } | ||
| 327 | if (pos->cl_cons_state != NFS_CS_READY) | ||
| 315 | continue; | 328 | continue; |
| 316 | 329 | ||
| 317 | if (pos->rpc_ops != new->rpc_ops) | 330 | if (pos->rpc_ops != new->rpc_ops) |
| @@ -423,16 +436,16 @@ int nfs41_walk_client_list(struct nfs_client *new, | |||
| 423 | struct rpc_cred *cred) | 436 | struct rpc_cred *cred) |
| 424 | { | 437 | { |
| 425 | struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); | 438 | struct nfs_net *nn = net_generic(new->cl_net, nfs_net_id); |
| 426 | struct nfs_client *pos, *n, *prev = NULL; | 439 | struct nfs_client *pos, *prev = NULL; |
| 427 | int status = -NFS4ERR_STALE_CLIENTID; | 440 | int status = -NFS4ERR_STALE_CLIENTID; |
| 428 | 441 | ||
| 429 | spin_lock(&nn->nfs_client_lock); | 442 | spin_lock(&nn->nfs_client_lock); |
| 430 | list_for_each_entry_safe(pos, n, &nn->nfs_client_list, cl_share_link) { | 443 | list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { |
| 431 | /* If "pos" isn't marked ready, we can't trust the | 444 | /* If "pos" isn't marked ready, we can't trust the |
| 432 | * remaining fields in "pos", especially the client | 445 | * remaining fields in "pos", especially the client |
| 433 | * ID and serverowner fields. Wait for CREATE_SESSION | 446 | * ID and serverowner fields. Wait for CREATE_SESSION |
| 434 | * to finish. */ | 447 | * to finish. */ |
| 435 | if (pos->cl_cons_state < NFS_CS_READY) { | 448 | if (pos->cl_cons_state > NFS_CS_READY) { |
| 436 | atomic_inc(&pos->cl_count); | 449 | atomic_inc(&pos->cl_count); |
| 437 | spin_unlock(&nn->nfs_client_lock); | 450 | spin_unlock(&nn->nfs_client_lock); |
| 438 | 451 | ||
| @@ -440,18 +453,17 @@ int nfs41_walk_client_list(struct nfs_client *new, | |||
| 440 | nfs_put_client(prev); | 453 | nfs_put_client(prev); |
| 441 | prev = pos; | 454 | prev = pos; |
| 442 | 455 | ||
| 443 | nfs4_schedule_lease_recovery(pos); | ||
| 444 | status = nfs_wait_client_init_complete(pos); | 456 | status = nfs_wait_client_init_complete(pos); |
| 445 | if (status < 0) { | 457 | if (status == 0) { |
| 446 | nfs_put_client(pos); | 458 | nfs4_schedule_lease_recovery(pos); |
| 447 | spin_lock(&nn->nfs_client_lock); | 459 | status = nfs4_wait_clnt_recover(pos); |
| 448 | continue; | ||
| 449 | } | 460 | } |
| 450 | status = pos->cl_cons_state; | ||
| 451 | spin_lock(&nn->nfs_client_lock); | 461 | spin_lock(&nn->nfs_client_lock); |
| 452 | if (status < 0) | 462 | if (status < 0) |
| 453 | continue; | 463 | continue; |
| 454 | } | 464 | } |
| 465 | if (pos->cl_cons_state != NFS_CS_READY) | ||
| 466 | continue; | ||
| 455 | 467 | ||
| 456 | if (pos->rpc_ops != new->rpc_ops) | 468 | if (pos->rpc_ops != new->rpc_ops) |
| 457 | continue; | 469 | continue; |
| @@ -469,17 +481,18 @@ int nfs41_walk_client_list(struct nfs_client *new, | |||
| 469 | continue; | 481 | continue; |
| 470 | 482 | ||
| 471 | atomic_inc(&pos->cl_count); | 483 | atomic_inc(&pos->cl_count); |
| 472 | spin_unlock(&nn->nfs_client_lock); | 484 | *result = pos; |
| 485 | status = 0; | ||
| 473 | dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n", | 486 | dprintk("NFS: <-- %s using nfs_client = %p ({%d})\n", |
| 474 | __func__, pos, atomic_read(&pos->cl_count)); | 487 | __func__, pos, atomic_read(&pos->cl_count)); |
| 475 | 488 | break; | |
| 476 | *result = pos; | ||
| 477 | return 0; | ||
| 478 | } | 489 | } |
| 479 | 490 | ||
| 480 | /* No matching nfs_client found. */ | 491 | /* No matching nfs_client found. */ |
| 481 | spin_unlock(&nn->nfs_client_lock); | 492 | spin_unlock(&nn->nfs_client_lock); |
| 482 | dprintk("NFS: <-- %s status = %d\n", __func__, status); | 493 | dprintk("NFS: <-- %s status = %d\n", __func__, status); |
| 494 | if (prev) | ||
| 495 | nfs_put_client(prev); | ||
| 483 | return status; | 496 | return status; |
| 484 | } | 497 | } |
| 485 | #endif /* CONFIG_NFS_V4_1 */ | 498 | #endif /* CONFIG_NFS_V4_1 */ |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 26431cf62ddb..0ad025eb523b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
| @@ -1046,6 +1046,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) | |||
| 1046 | /* Save the delegation */ | 1046 | /* Save the delegation */ |
| 1047 | nfs4_stateid_copy(&stateid, &delegation->stateid); | 1047 | nfs4_stateid_copy(&stateid, &delegation->stateid); |
| 1048 | rcu_read_unlock(); | 1048 | rcu_read_unlock(); |
| 1049 | nfs_release_seqid(opendata->o_arg.seqid); | ||
| 1049 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); | 1050 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); |
| 1050 | if (ret != 0) | 1051 | if (ret != 0) |
| 1051 | goto out; | 1052 | goto out; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 6ace365c6334..d41a3518509f 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
| @@ -1886,7 +1886,13 @@ again: | |||
| 1886 | status = PTR_ERR(clnt); | 1886 | status = PTR_ERR(clnt); |
| 1887 | break; | 1887 | break; |
| 1888 | } | 1888 | } |
| 1889 | clp->cl_rpcclient = clnt; | 1889 | /* Note: this is safe because we haven't yet marked the |
| 1890 | * client as ready, so we are the only user of | ||
| 1891 | * clp->cl_rpcclient | ||
| 1892 | */ | ||
| 1893 | clnt = xchg(&clp->cl_rpcclient, clnt); | ||
| 1894 | rpc_shutdown_client(clnt); | ||
| 1895 | clnt = clp->cl_rpcclient; | ||
| 1890 | goto again; | 1896 | goto again; |
| 1891 | 1897 | ||
| 1892 | case -NFS4ERR_MINOR_VERS_MISMATCH: | 1898 | case -NFS4ERR_MINOR_VERS_MISMATCH: |
