NFS: Wait for session recovery to finish before returning
Subsystems (2)
PATCH 1/1 NFS: Wait for session recovery to finish before returning
From: Bryan Schumaker <[email protected]>
Currently, we will schedule session recovery and then return to the caller of nfs4_handle_exception. This works for most cases, but causes a hang on the following test case:
Client Server
------ ------
Open file over NFS v4.1
Write to file
Expire client
Try to lock file
The server will return NFS4ERR_BADSESSION, prompting the client to schedule recovery. However, the client will continue placing lock attempts and the open recovery never seems to be scheduled. The simplest solution is to wait for session recovery to run before retrying the lock.
--- fs/nfs/nfs4proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfs/nfs4proc.c +1 -2
@@ -338,8 +338,7 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, strucdprintk ("%s ERROR: %d Reset session\n" , __func__, errorcode);nfs4_schedule_session_recovery (clp->cl_session, errorcode); - exception->retry =1 ; -break ; + goto wait_on_recovery;#endif /* defined(CONFIG_NFS_V4_1) */ case -NFS4ERR_FILE_OPEN :if (exception->timeout >HZ ) {
Signature · 1 line
1.8.0
Quoted 13 lines · On Tue, Oct 30, 2012 at 4:06 PM, <[email protected]> wrote:
From: Bryan Schumaker <[email protected]>
Currently, we will schedule session recovery and then return to the caller of
nfs4_handle_exception. This works for most cases, but causes a hang on the following test case:Client Server
------ ------
Open file over NFS v4.1
Write to file
Expire client
Try to lock file
Quoted 3 lines
The server will return
NFS4ERR_BADSESSION, prompting the client to schedule recovery. However, the client will continue placing lock attempts and the open recovery never seems to be scheduled.
I need more detail. Is this what is happening?
When the first NFS4ERR_BADSESSION error arrives, session recovery starts by setting the NFS4_SESSION_DRAINING bit which places all non RPC_PRIORITY_PRIVILEGED tasks with OP_SEQUENCE on the slot_tbl_waitq, so the lock requests should be placed on the slot_tbl_waitq and not go on the wire.
Once the session is drained, DESTROY_SESSION and CREATE_SESSION are called and one will return with NFS4ERR_STALE_CLIENTID kicking off the EXCHANGE_ID / CREATE_SESSION to establish a new clientid.
Do you see the clientid being recovered?
Once the new session is created, it inherits the slot_tbl_waitq of the old session, and all the lock requests and any other tasks piled up on the slot_tbl_waitq will run. At the same time, the state_manager thread is running recovery for any OPENs established under the old clientid, and then their associated LOCKs.
The OPEN and LOCK recovery tasks run with RPC_PRIORITY_PRIVILEGE which should mean that they get run before the RPC tasks with lower priority.
So my question (finally!): How is open recovery starvation happening? nfs41_sequence_free_slot => nfs4_check_drain_fc_complete => rpc_wake_up_first on the session slot_tbl_waitq, which in turn calls __rpc_find_next_queued_priority which should choose RPC_PRIORITY_PRIVILEGE tasks over lower privileged tasks on the session slot_tbl_waitq.
So even with a bunch of slots, when the first one returns and and free it's slot, the priority tasks (e.g. open recovery) should run.
-->Andy
Quoted 3 lines
The
simplest solution is to wait for session recovery to run before retrying the lock.
If on the wire RPCs return with NFS4ERR_BADSESSION, and then wait for session recovery in the exception handler, they will not call their rpc_release function
Quoted 27 lines
Signed-off-by Bryan Schumaker <[email protected]>--- fs/nfs/nfs4proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/nfs/nfs4proc.c +1
-3@@ -338,8 +338,7 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, strucdprintk ("%s ERROR: %d Reset session\n" , __func__, errorcode);nfs4_schedule_session_recovery (clp->cl_session, errorcode); - exception->retry =1 ; -break ; + goto wait_on_recovery;#endif /* defined(CONFIG_NFS_V4_1) */ case -NFS4ERR_FILE_OPEN :if (exception->timeout >HZ ) { --1.8.0
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 56 lines · Andy Adamson
Quoted 13 lines · On Tue, Oct 30, 2012 at 4:06 PM, <[email protected]> wrote:
From: Bryan Schumaker <[email protected]>
Currently, we will schedule session recovery and then return to the caller of
nfs4_handle_exception. This works for most cases, but causes a hang on the following test case:Client Server
------ ------
Open file over NFS v4.1
Write to file
Expire client
Try to lock fileQuoted 3 lines
The server will return
NFS4ERR_BADSESSION, prompting the client to schedule recovery. However, the client will continue placing lock attempts and the open recovery never seems to be scheduled.I need more detail. Is this what is happening?
When the first
NFS4ERR_BADSESSIONerror arrives, session recovery starts by setting theNFS4_SESSION_DRAININGbit which places all nonRPC_PRIORITY_PRIVILEGEDtasks withOP_SEQUENCEon theslot_tbl_waitq, so the lock requests should be placed on theslot_tbl_waitqand not go on the wire.Once the session is drained,
DESTROY_SESSIONandCREATE_SESSIONare called and one will return withNFS4ERR_STALE_CLIENTIDkicking off theEXCHANGE_ID/CREATE_SESSIONto establish a new clientid.Do you see the clientid being recovered?
Once the new session is created, it inherits the
slot_tbl_waitqof the old session, and all the lock requests and any other tasks piled up on theslot_tbl_waitqwill run. At the same time, thestate_managerthread is running recovery for any OPENs established under the old clientid, and then their associated LOCKs.The OPEN and LOCK recovery tasks run with
RPC_PRIORITY_PRIVILEGEwhich should mean that they get run before the RPC tasks with lower priority.So my question (finally!): How is open recovery starvation happening?
nfs41_sequence_free_slot=>nfs4_check_drain_fc_complete=>rpc_wake_up_firston the sessionslot_tbl_waitq, which in turn calls__rpc_find_next_queued_prioritywhich should chooseRPC_PRIORITY_PRIVILEGEtasks over lower privileged tasks on the sessionslot_tbl_waitq.So even with a bunch of slots, when the first one returns and and free it's slot, the priority tasks (e.g. open recovery) should run.
-->Andy
Quoted 7 lines
Quoted 3 lines
The
simplest solution is to wait for session recovery to run before retrying the lock.If on the wire RPCs return with
NFS4ERR_BADSESSION, and then wait for session recovery in the exception handler, they will not call theirrpc_releasefunction
Please ignore the above sentence - it was early thinking....
-->Andy
Quoted 28 lines
Quoted 28 lines
Signed-off-by Bryan Schumaker <[email protected]>--- fs/nfs/nfs4proc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/nfs/nfs4proc.c +1
-3@@ -338,8 +338,7 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, strucdprintk ("%s ERROR: %d Reset session\n" , __func__, errorcode);nfs4_schedule_session_recovery (clp->cl_session, errorcode); - exception->retry =1 ; -break ; + goto wait_on_recovery;#endif /* defined(CONFIG_NFS_V4_1) */ case -NFS4ERR_FILE_OPEN :if (exception->timeout >HZ ) { --1.8.0
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html