aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandros Batsakis <batsakis@netapp.com>2009-12-15 00:27:58 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-12-15 13:58:23 -0500
commit5601a00d671fe89f9b087513244abcd08ad67e7d (patch)
treefbc2a850ab9d82bb796294403b2d3e9b57f9e7f9
parentb257957e502a2c467c3c75005215a3f45ecb7f25 (diff)
nfs: run state manager in privileged mode
Signed-off-by: Alexandros Batsakis <batsakis@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs4proc.c3
-rw-r--r--fs/nfs/nfs4state.c34
2 files changed, 16 insertions, 21 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 18cce76867ce..4d6560a73949 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -477,7 +477,8 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
477 tbl = &session->fc_slot_table; 477 tbl = &session->fc_slot_table;
478 478
479 spin_lock(&tbl->slot_tbl_lock); 479 spin_lock(&tbl->slot_tbl_lock);
480 if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state)) { 480 if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state) &&
481 !rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) {
481 /* 482 /*
482 * The state manager will wait until the slot table is empty. 483 * The state manager will wait until the slot table is empty.
483 * Schedule the reset thread 484 * Schedule the reset thread
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 0e45075836b2..6674b28ddb66 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -135,9 +135,9 @@ static int nfs41_setup_state_renewal(struct nfs_client *clp)
135 return status; 135 return status;
136} 136}
137 137
138static void nfs41_end_drain_session(struct nfs_client *clp, 138static void nfs4_end_drain_session(struct nfs_client *clp)
139 struct nfs4_session *ses)
140{ 139{
140 struct nfs4_session *ses = clp->cl_session;
141 int max_slots; 141 int max_slots;
142 142
143 if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) { 143 if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) {
@@ -156,9 +156,9 @@ static void nfs41_end_drain_session(struct nfs_client *clp,
156 } 156 }
157} 157}
158 158
159static int nfs41_begin_drain_session(struct nfs_client *clp, 159static int nfs4_begin_drain_session(struct nfs_client *clp)
160 struct nfs4_session *ses)
161{ 160{
161 struct nfs4_session *ses = clp->cl_session;
162 struct nfs4_slot_table *tbl = &ses->fc_slot_table; 162 struct nfs4_slot_table *tbl = &ses->fc_slot_table;
163 163
164 spin_lock(&tbl->slot_tbl_lock); 164 spin_lock(&tbl->slot_tbl_lock);
@@ -176,16 +176,12 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
176{ 176{
177 int status; 177 int status;
178 178
179 status = nfs41_begin_drain_session(clp, clp->cl_session);
180 if (status != 0)
181 goto out;
182 status = nfs4_proc_exchange_id(clp, cred); 179 status = nfs4_proc_exchange_id(clp, cred);
183 if (status != 0) 180 if (status != 0)
184 goto out; 181 goto out;
185 status = nfs4_proc_create_session(clp); 182 status = nfs4_proc_create_session(clp);
186 if (status != 0) 183 if (status != 0)
187 goto out; 184 goto out;
188 nfs41_end_drain_session(clp, clp->cl_session);
189 nfs41_setup_state_renewal(clp); 185 nfs41_setup_state_renewal(clp);
190 nfs_mark_client_ready(clp, NFS_CS_READY); 186 nfs_mark_client_ready(clp, NFS_CS_READY);
191out: 187out:
@@ -1271,13 +1267,8 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
1271 1267
1272static int nfs4_reset_session(struct nfs_client *clp) 1268static int nfs4_reset_session(struct nfs_client *clp)
1273{ 1269{
1274 struct nfs4_session *ses = clp->cl_session;
1275 int status; 1270 int status;
1276 1271
1277 status = nfs41_begin_drain_session(clp, ses);
1278 if (status != 0)
1279 return status;
1280
1281 status = nfs4_proc_destroy_session(clp->cl_session); 1272 status = nfs4_proc_destroy_session(clp->cl_session);
1282 if (status && status != -NFS4ERR_BADSESSION && 1273 if (status && status != -NFS4ERR_BADSESSION &&
1283 status != -NFS4ERR_DEADSESSION) { 1274 status != -NFS4ERR_DEADSESSION) {
@@ -1293,19 +1284,18 @@ static int nfs4_reset_session(struct nfs_client *clp)
1293out: 1284out:
1294 /* 1285 /*
1295 * Let the state manager reestablish state 1286 * Let the state manager reestablish state
1296 * without waking other tasks yet.
1297 */ 1287 */
1298 if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) { 1288 if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) &&
1299 /* Wake up the next rpc task */ 1289 status == 0)
1300 nfs41_end_drain_session(clp, ses); 1290 nfs41_setup_state_renewal(clp);
1301 if (status == 0) 1291
1302 nfs41_setup_state_renewal(clp);
1303 }
1304 return status; 1292 return status;
1305} 1293}
1306 1294
1307#else /* CONFIG_NFS_V4_1 */ 1295#else /* CONFIG_NFS_V4_1 */
1308static int nfs4_reset_session(struct nfs_client *clp) { return 0; } 1296static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
1297static int nfs4_begin_drain_session(struct nfs_client *clp) { return 0; }
1298static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; }
1309#endif /* CONFIG_NFS_V4_1 */ 1299#endif /* CONFIG_NFS_V4_1 */
1310 1300
1311/* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors 1301/* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors
@@ -1337,6 +1327,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
1337 for(;;) { 1327 for(;;) {
1338 if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) { 1328 if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
1339 /* We're going to have to re-establish a clientid */ 1329 /* We're going to have to re-establish a clientid */
1330 nfs4_begin_drain_session(clp);
1340 status = nfs4_reclaim_lease(clp); 1331 status = nfs4_reclaim_lease(clp);
1341 if (status) { 1332 if (status) {
1342 nfs4_set_lease_expired(clp, status); 1333 nfs4_set_lease_expired(clp, status);
@@ -1363,6 +1354,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
1363 /* Initialize or reset the session */ 1354 /* Initialize or reset the session */
1364 if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) 1355 if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)
1365 && nfs4_has_session(clp)) { 1356 && nfs4_has_session(clp)) {
1357 nfs4_begin_drain_session(clp);
1366 status = nfs4_reset_session(clp); 1358 status = nfs4_reset_session(clp);
1367 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) 1359 if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
1368 continue; 1360 continue;
@@ -1396,6 +1388,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
1396 goto out_error; 1388 goto out_error;
1397 } 1389 }
1398 1390
1391 nfs4_end_drain_session(clp);
1399 if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { 1392 if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
1400 nfs_client_return_marked_delegations(clp); 1393 nfs_client_return_marked_delegations(clp);
1401 continue; 1394 continue;
@@ -1412,6 +1405,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
1412out_error: 1405out_error:
1413 printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" 1406 printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s"
1414 " with error %d\n", clp->cl_hostname, -status); 1407 " with error %d\n", clp->cl_hostname, -status);
1408 nfs4_end_drain_session(clp);
1415 nfs4_clear_state_manager_bit(clp); 1409 nfs4_clear_state_manager_bit(clp);
1416} 1410}
1417 1411