NFSv4.1: pNFS has no business touching the slot table waitq...
Subsystems (2)
cover NFSv4.1: pNFS has no business touching the slot table waitq...
From: Andy Adamson <[email protected]>
Hi Trond:
How about this?
I tested this patch against the rpc_wake_up version - no difference in run time for DS disconnect.
I have not yet tested DS invalid layout, but since
the invalid layout does not trigger a deviceid invalidation, each call using the layout will go through filelayout_async_handle_error, free the slot, and wake up the next task on the ds session fore channel slot table waitq, and the filelayout_read/write_prepare routines do not reset to the MDS.
-->Andy
Andy Adamson (1):
NFSv4.1 do not wake up all tasks on data server reset to MDS
fs/nfs/internal.h | 1 + fs/nfs/nfs4filelayout.c | 5 ++--- fs/nfs/nfs4proc.c | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.7.6
PATCH 1/1 NFSv4.1 do not wake up all tasks on data server reset to MDS
From: Andy Adamson <[email protected]>
There is no advantage to waking up all rpc tasks on each data server disconnect or invalid layout error.
For DS disconnect errors where the data server is reseting all I/O to the MDS, tasks wakened from the fore channel slot table waitq are immediately reset to use the MDS session, and do not request a data server session slot, and so do not call nfs41_session_free_slot, and do not wake up the next task on the data server session fore channel slot table wait queue.
Replace the call to rpc_wake_up which wakes up all tasks with a call to rpc_wake_up_first in the filelayout I/O prepare routines for the case where I/O is redirected to the MDS.
Share code with nfs4_check_drain_fc_complete.
--- fs/nfs/internal.h | 1 + fs/nfs/nfs4filelayout.c | 5 ++--- fs/nfs/nfs4proc.c | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-)
fs/nfs/internal.h +1 -0
@@ -490,6 +490,7 @@ extern int nfs40_walk_client_list(struct nfs_client *clp,extern int nfs41_walk_client_list (struct nfs_client *clp,struct nfs_client **result,struct rpc_cred *cred); +extern bool nfs4_wake_up_first (struct nfs4_session *ses);/* * Determine the device name as a string
fs/nfs/nfs4filelayout.c +2 -3
@@ -131,7 +131,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,struct nfs_server *mds_server =NFS_SERVER (inode);struct nfs4_deviceid_node *devid =FILELAYOUT_DEVID_NODE (lseg);struct nfs_client *mds_client = mds_server->nfs_client; -struct nfs4_slot_table *tbl = &clp->cl_session->fc_slot_table;if (task->tk_status >=0 )return 0 ;
@@ -191,7 +190,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,* layout is destroyed and a new valid layout is obtained. */ pnfs_destroy_layout (NFS_I (inode)); -rpc_wake_up (&tbl->slot_tbl_waitq); goto reset;/* RPC connection errors */ case -ECONNREFUSED :
@@ -206,7 +204,6 @@ static int filelayout_async_handle_error(struct rpc_task *task,nfs4_mark_deviceid_unavailable (devid);clear_bit (NFS_INO_LAYOUTCOMMIT , &NFS_I (inode)->flags);_pnfs_return_layout (inode); -rpc_wake_up (&tbl->slot_tbl_waitq);nfs4_ds_disconnect (clp);/* fall through */ default :
@@ -294,6 +291,7 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data)if (filelayout_reset_to_mds (rdata->header->lseg)) {dprintk ("%s task %u reset io to MDS\n" , __func__, task->tk_pid);filelayout_reset_read (rdata); +nfs4_wake_up_first (rdata->ds_clp->cl_session);rpc_exit (task,0 );return ; }
@@ -396,6 +394,7 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data)if (filelayout_reset_to_mds (wdata->header->lseg)) {dprintk ("%s task %u reset io to MDS\n" , __func__, task->tk_pid);filelayout_reset_write (wdata); +nfs4_wake_up_first (wdata->ds_clp->cl_session);rpc_exit (task,0 );return ; }
fs/nfs/nfs4proc.c +13 -5
@@ -438,17 +438,25 @@ bool nfs4_set_task_privileged(struct rpc_task *task, void *dummy)return true; } -/* -* Signal state manager thread if session fore channel is drained -*/ -static void nfs4_check_drain_fc_complete (struct nfs4_session *ses) +bool nfs4_wake_up_first (struct nfs4_session *ses) {if (!test_bit (NFS4_SESSION_DRAINING , &ses->session_state)) {rpc_wake_up_first (&ses->fc_slot_table.slot_tbl_waitq, nfs4_set_task_privileged,NULL ); -return ; +return true; } +return false; +} +EXPORT_SYMBOL_GPL (nfs4_wake_up_first); +/* +* Signal state manager thread if session fore channel is drained +*/ +static void nfs4_check_drain_fc_complete (struct nfs4_session *ses) +{ + +if (nfs4_wake_up_first (ses)) +return ;if (ses->fc_slot_table.highest_used_slotid !=NFS4_NO_SLOT )return ;
Signature · 1 line
1.7.7.6
Re: [PATCH 1/1] NFSv4.1 do not wake up all tasks on data server reset to MDS
T24gVHVlLCAyMDEyLTEwLTA5IGF0IDE3OjIwIC0wNDAwLCBhbmRyb3NAbmV0YXBwLmNvbSB3cm90 ZToNCj4gRnJvbTogQW5keSBBZGFtc29uIDxhbmRyb3NAbmV0YXBwLmNvbT4NCj4gDQo+IFRoZXJl IGlzIG5vIGFkdmFudGFnZSB0byB3YWtpbmcgdXAgYWxsIHJwYyB0YXNrcyBvbiBlYWNoIGRhdGEg c2VydmVyIGRpc2Nvbm5lY3QNCj4gb3IgaW52YWxpZCBsYXlvdXQgZXJyb3IuDQo+IA0KPiBGb3Ig RFMgZGlzY29ubmVjdCBlcnJvcnMgd2hlcmUgdGhlIGRhdGEgc2VydmVyIGlzIHJlc2V0aW5nIGFs bCBJL08gdG8gdGhlIE1EUywNCj4gdGFza3Mgd2FrZW5lZCBmcm9tIHRoZSBmb3JlIGNoYW5uZWwg c2xvdCB0YWJsZSB3YWl0cSBhcmUgaW1tZWRpYXRlbHkgcmVzZXQNCj4gdG8gdXNlIHRoZSBNRFMg c2Vzc2lvbiwgYW5kIGRvIG5vdCByZXF1ZXN0IGEgZGF0YSBzZXJ2ZXIgc2Vzc2lvbiBzbG90LCBh bmQNCj4gc28gZG8gbm90IGNhbGwgbmZzNDFfc2Vzc2lvbl9mcmVlX3Nsb3QsIGFuZCBkbyBub3Qg d2FrZSB1cCB0aGUgbmV4dCB0YXNrIG9uDQo+IHRoZSBkYXRhIHNlcnZlciBzZXNzaW9uIGZvcmUg Y2hhbm5lbCBzbG90IHRhYmxlIHdhaXQgcXVldWUuDQo+IA0KPiBSZXBsYWNlIHRoZSBjYWxsIHRv IHJwY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zdHJ1Y3Qg bmZzNF9zbG90X3RhYmxlICp0Ymw7DQogDQpAQCAtNDg2LDYgKzQ4Niw3IEBAIHN0YXRpYyB2b2lk IG5mczQxX3NlcXVlbmNlX2ZyZWVfc2xvdChzdHJ1Y3QgbmZzNF9zZXF1ZW5jZV9yZXMgKnJlcykN CiAJc3Bpbl91bmxvY2soJnRibC0+c2xvdF90YmxfbG9jayk7DQogCXJlcy0+c3Jfc2xvdCA9IE5V TEw7DQogfQ0KK0VYUE9SVF9TWU1CT0xfR1BMKG5mczQxX3NlcXVlbmNlX2ZyZWVfc2xvdCk7DQog DQogc3RhdGljIGludCBuZnM0MV9zZXF1ZW5jZV9kb25lKHN0cnVjdCBycGNfdGFzayAqdGFzaywg c3RydWN0IG5mczRfc2VxdWVuY2VfcmVzICpyZXMpDQogew0KDQotLSANClRyb25kIE15a2xlYnVz dA0KTGludXggTkZTIGNsaWVudCBtYWludGFpbmVyDQoNCk5ldEFwcA0KVHJvbmQuTXlrbGVidXN0 QG5ldGFwcC5jb20NCnd3dy5uZXRhcHAuY29tDQo=
Re: [PATCH 1/1] NFSv4.1 do not wake up all tasks on data server reset to MDS
Quoted 12 lines · Trond
Quoted 11 lines · On Tue, 2012-10-09 at 17:20 -0400, [email protected] wrote:
From: Andy Adamson <[email protected]>
There is no advantage to waking up all rpc tasks on each data server disconnect or invalid layout error.
For DS disconnect errors where the data server is reseting all I/O to the MDS, tasks wakened from the fore channel slot table waitq are immediately reset to use the MDS session, and do not request a data server session slot, and so do not call
nfs41_session_free_slot, and do not wake up the next task on the data server session fore channel slot table wait queue.
Quoted 8 lines
Quoted 5 lines
Replace the call to
rpc_wake_upwhich wakes up all tasks with a call torpc_wake_up_firstin the filelayout I/O prepare routines for the case where I/O is redirected to the MDS.Share code with
nfs4_check_drain_fc_complete.This will still have false positive wakeups, though, since there is no connection to number of slots that are available.
I can't see that number of slots available is an issue. The Deviceid is bad due to a DS connection error.
case 1) DS Role: All of the tasks are to be redirected to a (working) MDS session on another nfs_client. None of the disconnected DS session slots will be used, no reason to wait for a slot that will not be used.
case 2) MDS DS Role, and MDS is the DS's MDS: No chance of recovery, as there is no working MDS to redirect to. Wait for a slot, don't wait for a slot, no difference.
case 3) MDS DS Role, and MDS is not the DS's MDS: Here is where this patch fails, and come to think of it, rpc_wake_up is the way to go. The disconnected session slot_table_waitq can contain both MDS and DS traffic. The MDS traffic is hard mounted and will fail (disconnected). So, having the DS tasks which can be redirected to a (working) MDS session wait behind failed hard mounted MDS tasks will not work as the hard mounted MDS tasks will retry forever starving the DS tasks, and we could end up with a bunch of DS tasks still on the disconnected session wait queue with all MDS tasks taking the slots.
My patch which calls rpc_wake_up_first in filelayout_read/write_prepare can also result in DS tasks being starved behind MDS hard mounted tasks as failed DS tasks give up their slot via the session code, and so MDS tasks could use all the slots and DS recovery will fail.
This is why the rpc_wake_up call in filelayout_async_handle_error for the DS disconnect case is correct. It separates the DS from the MDS traffic guaranteeing all DS tasks will be redirected. The "churn" makes no difference in case 1 as all tasks will be redirected or in case 2 as no tasks will succeed.
So I vote for keeping the rpc_wake_up in the DS disconnect case.
-->Andy
Quoted 100 lines
How about rather just letting the session code drive the wakeups? I'm thinking something like the following patch:
8<--------------------------------------------------------------
fs/nfs/nfs4_fs.h +1
-0@@ -248,6 +248,7 @@ extern int nfs4_setup_sequence(const struct nfs_server *server,extern int nfs41_setup_sequence (struct nfs4_session *session,struct nfs4_sequence_args *args,struct nfs4_sequence_res *res,struct rpc_task *task); +extern void nfs41_sequence_free_slot (struct nfs4_sequence_res *res);extern void nfs4_destroy_session (struct nfs4_session *session);extern struct nfs4_session *nfs4_alloc_session (struct nfs_client *clp);extern int nfs4_proc_create_session (struct nfs_client *,struct rpc_cred *);fs/nfs/nfs4filelayout.c +12
-10@@ -291,19 +291,20 @@ static void filelayout_read_prepare(struct rpc_task *task, void *data) {struct nfs_read_data *rdata = data; +if (nfs41_setup_sequence (rdata->ds_clp->cl_session, + &rdata->args.seq_args, &rdata->res.seq_res, + task)) +return ; +if (filelayout_reset_to_mds (rdata->header->lseg)) {dprintk ("%s task %u reset io to MDS\n" , __func__, task->tk_pid);filelayout_reset_read (rdata); +nfs41_sequence_free_slot (&rdata->res.seq_res);rpc_exit (task,0 );return ; } rdata->read_done_cb = filelayout_read_done_cb; -if (nfs41_setup_sequence (rdata->ds_clp->cl_session, - &rdata->args.seq_args, &rdata->res.seq_res, - task)) -return ; -rpc_call_start (task); }@@ -393,17 +394,18 @@ static void filelayout_write_prepare(struct rpc_task *task, void *data) {struct nfs_write_data *wdata = data; +if (nfs41_setup_sequence (wdata->ds_clp->cl_session, + &wdata->args.seq_args, &wdata->res.seq_res, + task)) +return ; +if (filelayout_reset_to_mds (wdata->header->lseg)) {dprintk ("%s task %u reset io to MDS\n" , __func__, task->tk_pid);filelayout_reset_write (wdata); +nfs41_sequence_free_slot (&rdata->res.seq_res);rpc_exit (task,0 );return ; } -if (nfs41_setup_sequence (wdata->ds_clp->cl_session, - &wdata->args.seq_args, &wdata->res.seq_res, - task)) -return ; -rpc_call_start (task); }fs/nfs/nfs4proc.c +2
-1@@ -468,7 +468,7 @@ void nfs4_check_drain_bc_complete(struct nfs4_session *ses)complete (&ses->bc_slot_table.complete); } -static void nfs41_sequence_free_slot (struct nfs4_sequence_res *res) +void nfs41_sequence_free_slot (struct nfs4_sequence_res *res) {struct nfs4_slot_table *tbl;@@ -486,6 +486,7 @@ static void nfs41_sequence_free_slot(struct nfs4_sequence_res *res)spin_unlock (&tbl->slot_tbl_lock); res->sr_slot =NULL ; } +EXPORT_SYMBOL_GPL (nfs41_sequence_free_slot);static int nfs41_sequence_done (struct rpc_task *task,struct nfs4_sequence_res *res) {Signature · 7 lines
-- Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com