diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-03-03 20:28:59 -0500 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-03-03 20:42:23 -0500 |
commit | 48d66b9749e39e0d4cc37d635df3f18906af38a6 (patch) | |
tree | b64b126f4b74bae8b4fd3db8d26147a2d394477f /fs | |
parent | ef070dcb3989f553f5d84edf555eebc7e204099d (diff) |
NFSv4: Fix a race in NFSv4.1 server trunking discovery
We do not want to allow a race with another NFS mount to cause
nfs41_walk_client_list() to establish a lease on our nfs_client before
we're done checking for trunking.
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/client.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4client.c | 9 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 14 |
3 files changed, 17 insertions, 8 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index f9f4845db989..19874151e95c 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -433,7 +433,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat | |||
433 | 433 | ||
434 | static bool nfs_client_init_is_complete(const struct nfs_client *clp) | 434 | static bool nfs_client_init_is_complete(const struct nfs_client *clp) |
435 | { | 435 | { |
436 | return clp->cl_cons_state != NFS_CS_INITING; | 436 | return clp->cl_cons_state <= NFS_CS_READY; |
437 | } | 437 | } |
438 | 438 | ||
439 | int nfs_wait_client_init_complete(const struct nfs_client *clp) | 439 | int nfs_wait_client_init_complete(const struct nfs_client *clp) |
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 8646af9b11d2..86d6214ea022 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c | |||
@@ -621,6 +621,9 @@ int nfs41_walk_client_list(struct nfs_client *new, | |||
621 | spin_lock(&nn->nfs_client_lock); | 621 | spin_lock(&nn->nfs_client_lock); |
622 | list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { | 622 | list_for_each_entry(pos, &nn->nfs_client_list, cl_share_link) { |
623 | 623 | ||
624 | if (pos == new) | ||
625 | goto found; | ||
626 | |||
624 | if (pos->rpc_ops != new->rpc_ops) | 627 | if (pos->rpc_ops != new->rpc_ops) |
625 | continue; | 628 | continue; |
626 | 629 | ||
@@ -639,10 +642,6 @@ int nfs41_walk_client_list(struct nfs_client *new, | |||
639 | prev = pos; | 642 | prev = pos; |
640 | 643 | ||
641 | status = nfs_wait_client_init_complete(pos); | 644 | status = nfs_wait_client_init_complete(pos); |
642 | if (pos->cl_cons_state == NFS_CS_SESSION_INITING) { | ||
643 | nfs4_schedule_lease_recovery(pos); | ||
644 | status = nfs4_wait_clnt_recover(pos); | ||
645 | } | ||
646 | spin_lock(&nn->nfs_client_lock); | 645 | spin_lock(&nn->nfs_client_lock); |
647 | if (status < 0) | 646 | if (status < 0) |
648 | break; | 647 | break; |
@@ -668,7 +667,7 @@ int nfs41_walk_client_list(struct nfs_client *new, | |||
668 | */ | 667 | */ |
669 | if (!nfs4_match_client_owner_id(pos, new)) | 668 | if (!nfs4_match_client_owner_id(pos, new)) |
670 | continue; | 669 | continue; |
671 | 670 | found: | |
672 | atomic_inc(&pos->cl_count); | 671 | atomic_inc(&pos->cl_count); |
673 | *result = pos; | 672 | *result = pos; |
674 | status = 0; | 673 | status = 0; |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 5ad908e9ce9c..d8b43f0e08fc 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -346,9 +346,19 @@ int nfs41_discover_server_trunking(struct nfs_client *clp, | |||
346 | status = nfs4_proc_exchange_id(clp, cred); | 346 | status = nfs4_proc_exchange_id(clp, cred); |
347 | if (status != NFS4_OK) | 347 | if (status != NFS4_OK) |
348 | return status; | 348 | return status; |
349 | set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); | ||
350 | 349 | ||
351 | return nfs41_walk_client_list(clp, result, cred); | 350 | status = nfs41_walk_client_list(clp, result, cred); |
351 | if (status < 0) | ||
352 | return status; | ||
353 | if (clp != *result) | ||
354 | return 0; | ||
355 | |||
356 | set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state); | ||
357 | nfs4_schedule_state_manager(clp); | ||
358 | status = nfs_wait_client_init_complete(clp); | ||
359 | if (status < 0) | ||
360 | nfs_put_client(clp); | ||
361 | return status; | ||
352 | } | 362 | } |
353 | 363 | ||
354 | #endif /* CONFIG_NFS_V4_1 */ | 364 | #endif /* CONFIG_NFS_V4_1 */ |