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/nfs4state.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/nfs4state.c')
-rw-r--r-- | fs/nfs/nfs4state.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index bc683ed477e1..df5b4807daa7 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -1113,6 +1113,27 @@ static int nfs4_reclaim_lease(struct nfs_client *clp) | |||
1113 | return status; | 1113 | return status; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | #ifdef CONFIG_NFS_V4_1 | ||
1117 | |||
1118 | static int nfs4_initialize_session(struct nfs_client *clp) | ||
1119 | { | ||
1120 | int status; | ||
1121 | |||
1122 | status = nfs4_proc_create_session(clp, 0); | ||
1123 | if (!status) { | ||
1124 | nfs_mark_client_ready(clp, NFS_CS_READY); | ||
1125 | } else if (status == -NFS4ERR_STALE_CLIENTID) { | ||
1126 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | ||
1127 | set_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state); | ||
1128 | } else { | ||
1129 | nfs_mark_client_ready(clp, status); | ||
1130 | } | ||
1131 | return status; | ||
1132 | } | ||
1133 | #else /* CONFIG_NFS_V4_1 */ | ||
1134 | static int nfs4_initialize_session(struct nfs_client *clp) { return 0; } | ||
1135 | #endif /* CONFIG_NFS_V4_1 */ | ||
1136 | |||
1116 | static void nfs4_state_manager(struct nfs_client *clp) | 1137 | static void nfs4_state_manager(struct nfs_client *clp) |
1117 | { | 1138 | { |
1118 | int status = 0; | 1139 | int status = 0; |
@@ -1126,6 +1147,9 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1126 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); | 1147 | set_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state); |
1127 | if (status == -EAGAIN) | 1148 | if (status == -EAGAIN) |
1128 | continue; | 1149 | continue; |
1150 | if (clp->cl_cons_state == | ||
1151 | NFS_CS_SESSION_INITING) | ||
1152 | nfs_mark_client_ready(clp, status); | ||
1129 | goto out_error; | 1153 | goto out_error; |
1130 | } | 1154 | } |
1131 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); | 1155 | clear_bit(NFS4CLNT_CHECK_LEASE, &clp->cl_state); |
@@ -1136,7 +1160,16 @@ static void nfs4_state_manager(struct nfs_client *clp) | |||
1136 | if (status != 0) | 1160 | if (status != 0) |
1137 | continue; | 1161 | continue; |
1138 | } | 1162 | } |
1139 | 1163 | /* Setup the session */ | |
1164 | if (nfs4_has_session(clp) && | ||
1165 | test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) { | ||
1166 | status = nfs4_initialize_session(clp); | ||
1167 | if (status) { | ||
1168 | if (status == -NFS4ERR_STALE_CLIENTID) | ||
1169 | continue; | ||
1170 | goto out_error; | ||
1171 | } | ||
1172 | } | ||
1140 | /* First recover reboot state... */ | 1173 | /* First recover reboot state... */ |
1141 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { | 1174 | if (test_and_clear_bit(NFS4CLNT_RECLAIM_REBOOT, &clp->cl_state)) { |
1142 | status = nfs4_do_reclaim(clp, &nfs4_reboot_recovery_ops); | 1175 | status = nfs4_do_reclaim(clp, &nfs4_reboot_recovery_ops); |