diff options
author | Andy Adamson <andros@netapp.com> | 2009-04-01 09:22:38 -0400 |
---|---|---|
committer | Benny Halevy <bhalevy@panasas.com> | 2009-06-17 15:25:06 -0400 |
commit | 76db6d9500caeaa774a3e32a997eba30bbdc176b (patch) | |
tree | f1c1c2647ecb67dd519d00938be07f360d7680b1 /fs/nfs/client.c | |
parent | ac72b7b3b3263ce64d55094eac1d1bde5f34e64a (diff) |
nfs41: add session setup to the state manager
At mount, nfs_alloc_client sets the cl_state NFS4CLNT_LEASE_EXPIRED bit
and nfs4_alloc_session sets the NFS4CLNT_SESSION_SETUP bit, so both bits are
set when nfs4_lookup_root calls nfs4_recover_expired_lease which schedules
the nfs4_state_manager and waits for it to complete.
Place the session setup after the clientid establishment in nfs4_state_manager
so that the session is setup right after the clientid has been established
without rescheduling the state manager.
Unlike nfsv4.0, the nfs_client struct is not ready to use until the session
has been established. Postpone marking the nfs_client struct to NFS_CS_READY
until after a successful CREATE_SESSION call so that other threads cannot use
the client until the session is established.
If the EXCHANGE_ID call fails and the session has not been setup (the
NFS4CLNT_SESSION_SETUP bit is set), mark the client with the error and return.
If the session setup CREATE_SESSION call fails with NFS4ERR_STALE_CLIENTID
which could occur due to server reboot or network partition inbetween the
EXCHANGE_ID and CREATE_SESSION call, reset the NFS4CLNT_LEASE_EXPIRED and
NFS4CLNT_SESSION_SETUP bits and try again.
If the CREATE_SESSION call fails with other errors, mark the client with
the error and return.
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: NFS_CS_SESSION_SETUP cl_cons_state for back channel setup]
On session setup, the CREATE_SESSION reply races with the server back channel
probe which needs to succeed to setup the back channel. Set a new
cl_cons_state NFS_CS_SESSION_SETUP just prior to the CREATE_SESSION call
and add it as a valid state to nfs_find_client so that the client back channel
can find the nfs_client struct and won't drop the server backchannel probe.
Use a new cl_cons_state so that NFSv4.0 back channel behaviour which only
sets NFS_CS_READY is unchanged.
Adjust waiting on the nfs_client_active_wq accordingly.
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfs41: rename NFS_CS_SESSION_SETUP to NFS_CS_SESSION_INITING]
Signed-off-by: Andy Adamson <andros@netapp.com>
[nfs41: set NFS_CL_SESSION_INITING in alloc_session]
Signed-off-by: Andy Adamson <andros@netapp.com>
[nfs41: move session setup into a function]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[moved nfs4_proc_create_session declaration here]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/client.c')
-rw-r--r-- | fs/nfs/client.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index bb7432d83b5a..d28a987f569e 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -366,7 +366,8 @@ struct nfs_client *nfs_find_client(const struct sockaddr *addr, u32 nfsversion) | |||
366 | struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; | 366 | struct sockaddr *clap = (struct sockaddr *)&clp->cl_addr; |
367 | 367 | ||
368 | /* Don't match clients that failed to initialise properly */ | 368 | /* Don't match clients that failed to initialise properly */ |
369 | if (clp->cl_cons_state != NFS_CS_READY) | 369 | if (!(clp->cl_cons_state == NFS_CS_READY || |
370 | clp->cl_cons_state == NFS_CS_SESSION_INITING)) | ||
370 | continue; | 371 | continue; |
371 | 372 | ||
372 | /* Different NFS versions cannot share the same nfs_client */ | 373 | /* Different NFS versions cannot share the same nfs_client */ |
@@ -499,7 +500,7 @@ found_client: | |||
499 | nfs_free_client(new); | 500 | nfs_free_client(new); |
500 | 501 | ||
501 | error = wait_event_killable(nfs_client_active_wq, | 502 | error = wait_event_killable(nfs_client_active_wq, |
502 | clp->cl_cons_state != NFS_CS_INITING); | 503 | clp->cl_cons_state < NFS_CS_INITING); |
503 | if (error < 0) { | 504 | if (error < 0) { |
504 | nfs_put_client(clp); | 505 | nfs_put_client(clp); |
505 | return ERR_PTR(-ERESTARTSYS); | 506 | return ERR_PTR(-ERESTARTSYS); |
@@ -520,7 +521,7 @@ found_client: | |||
520 | /* | 521 | /* |
521 | * Mark a server as ready or failed | 522 | * Mark a server as ready or failed |
522 | */ | 523 | */ |
523 | static void nfs_mark_client_ready(struct nfs_client *clp, int state) | 524 | void nfs_mark_client_ready(struct nfs_client *clp, int state) |
524 | { | 525 | { |
525 | clp->cl_cons_state = state; | 526 | clp->cl_cons_state = state; |
526 | wake_up_all(&nfs_client_active_wq); | 527 | wake_up_all(&nfs_client_active_wq); |
@@ -1135,7 +1136,8 @@ static int nfs4_init_client(struct nfs_client *clp, | |||
1135 | if (error < 0) | 1136 | if (error < 0) |
1136 | goto error; | 1137 | goto error; |
1137 | 1138 | ||
1138 | nfs_mark_client_ready(clp, NFS_CS_READY); | 1139 | if (!nfs4_has_session(clp)) |
1140 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
1139 | return 0; | 1141 | return 0; |
1140 | 1142 | ||
1141 | error: | 1143 | error: |