: Fix EAGAIN handling for the filelayout
Subsystems (2)
cover : Fix EAGAIN handling for the filelayout
These patches remove pnfs_call_done and all the routines associated with it. They were quite buggy for filelayout, and tended to crash the client anytime EAGAIN handling was invoked (in particular on short reads.)
The first patch just has filelayout avoid using them entirely. It should NOT be reverted in the post-submit.
The subsequent patches remove the unused code for pnfs-submit. It is expected they will be reverted in the post-submit.
Fred
PATCH 1/4 pnfs-submit: filelayout: Stop using pnfs_call_done and friends
The current handling is quite flawed. The rpc_call_done function can restart the rpc, so doing anything after the call doesn't work.
In particular:
The current code often ends trying to resend the rpc twice.
The lseg_put should be in the release call, not the done call. There is no way to distinguish whether a retry should be through the DS or MDS If rpc_run_task returns an error, rpc_call_done won't even be called.
--- fs/nfs/nfs4filelayout.c | 30 +++++++++++++++++++++++++++--- fs/nfs/pnfs.c | 1 + 2 files changed, 28 insertions(+), 3 deletions(-)
fs/nfs/nfs4filelayout.c +27 -3
@@ -54,6 +54,7 @@#include "nfs4filelayout.h" #include "nfs4_fs.h" #include "internal.h" +#include "pnfs.h" #define NFSDBG_FACILITY NFSDBG_PNFS_LD
@@ -151,7 +152,17 @@ static void filelayout_read_call_done(struct rpc_task *task, void *data) rdata->args.offset = rdata->fldata.orig_offset; } - pnfs_callback_ops->nfs_readlist_complete (rdata); +/* Note this may cause RPC to be resent */ + rdata->pdata.call_ops->rpc_call_done (task, data); +} + +static void filelayout_read_release (void *data) +{ +struct nfs_read_data *rdata = (struct nfs_read_data *)data; + +put_lseg (rdata->pdata.lseg); + rdata->pdata.lseg =NULL ; + rdata->pdata.call_ops->rpc_release (data); }static void filelayout_write_call_done (struct rpc_task *task,void *data)
@@ -164,17 +175,29 @@ static void filelayout_write_call_done(struct rpc_task *task, void *data) wdata->args.offset = wdata->fldata.orig_offset; } - pnfs_callback_ops->nfs_writelist_complete (wdata); +/* Note this may cause RPC to be resent */ + wdata->pdata.call_ops->rpc_call_done (task, data); +} + +static void filelayout_write_release (void *data) +{ +struct nfs_write_data *wdata = (struct nfs_write_data *)data; + +put_lseg (wdata->pdata.lseg); + wdata->pdata.lseg =NULL ; + wdata->pdata.call_ops->rpc_release (data); }struct rpc_call_ops filelayout_read_call_ops = { .rpc_call_prepare = nfs_read_prepare, .rpc_call_done = filelayout_read_call_done, + .rpc_release = filelayout_read_release, };struct rpc_call_ops filelayout_write_call_ops = { .rpc_call_prepare = nfs_write_prepare, .rpc_call_done = filelayout_write_call_done, + .rpc_release = filelayout_write_release, };/* Perform sync or async reads.
@@ -539,12 +562,13 @@ static void filelayout_commit_call_done(struct rpc_task *task, void *data) {struct nfs_write_data *wdata = (struct nfs_write_data *)data; - pnfs_callback_ops->nfs_commit_complete (wdata); + wdata->pdata.call_ops->rpc_call_done (task, data); }static struct rpc_call_ops filelayout_commit_call_ops = { .rpc_call_prepare = nfs_write_prepare, .rpc_call_done = filelayout_commit_call_done, + .rpc_release = filelayout_write_release, };/*
fs/nfs/pnfs.c +1 -0
@@ -452,6 +452,7 @@ put_lseg(struct pnfs_layout_segment *lseg)if (do_wake_up)wake_up (&nfsi->lo_waitq); } +EXPORT_SYMBOL (put_lseg);static inline u64 end_offset (u64 start,u64 len)
Signature · 1 line
1.6.6.1
PATCH 2/4 pnfs-submit: Remove checks for non-rpc drivers
Removes PNFS_NO_RPC and pnfs_use_rpc()
--- fs/nfs/nfs4filelayout.c | 1 - fs/nfs/nfs4proc.c | 9 --------- fs/nfs/pnfs.c | 40 +++++----------------------------------- fs/nfs/pnfs.h | 13 ------------- include/linux/nfs4_pnfs.h | 10 ---------- include/linux/nfs_xdr.h | 3 --- 6 files changed, 5 insertions(+), 71 deletions(-)
fs/nfs/nfs4filelayout.c +0 -1
@@ -753,7 +753,6 @@ struct layoutdriver_io_operations filelayout_io_operations = { };struct layoutdriver_policy_operations filelayout_policy_operations = { - .flags =PNFS_USE_RPC_CODE , .get_stripesize = filelayout_get_stripesize, .pg_test = filelayout_pg_test, };
fs/nfs/nfs4proc.c +0 -9
@@ -3175,9 +3175,6 @@ static int pnfs4_read_done(struct rpc_task *task, struct nfs_read_data *data)dprintk ("--> %s\n" , __func__); -if (data->pdata.pnfsflags &PNFS_NO_RPC ) -return 0 ; - status = task->tk_status >=0 ?0 : task->tk_status;/* Is this a DS session */
@@ -3225,9 +3222,6 @@ static int pnfs4_write_done(struct rpc_task *task, struct nfs_write_data *data) data->args.count = data->pdata.orig_count; } -if (data->pdata.pnfsflags &PNFS_NO_RPC ) -return 0 ; -/* Is this a DS session */ if (data->fldata.ds_nfs_client) {dprintk ("%s DS write\n" , __func__);
@@ -3278,9 +3272,6 @@ static int pnfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data)dprintk ("--> %s task->tk_status %d\n" , __func__, task->tk_status); -if (data->pdata.pnfsflags &PNFS_NO_RPC ) -return 0 ; -/* Is this a DS session */ if (data->fldata.ds_nfs_client) {dprintk ("%s DS commit\n" , __func__);
fs/nfs/pnfs.c +5 -35
@@ -1406,24 +1406,16 @@ pnfs_call_done(struct pnfs_call_data *pdata, struct rpc_task *task, void *data) pdata->call_ops->rpc_call_done (task, data);if (pdata->pnfs_error == -EAGAIN || task->tk_status == -EAGAIN )return -EAGAIN ; -if (pdata->pnfsflags &PNFS_NO_RPC ) { - pdata->call_ops->rpc_release (data); - }else { -/* -* just restore original rpc call ops -* rpc_release will be called later by the rpc scheduling layer. -*/ - task->tk_ops = pdata->call_ops; - } +/* +* just restore original rpc call ops +* rpc_release will be called later by the rpc scheduling layer. +*/ + task->tk_ops = pdata->call_ops;return 0 ; }/* Post-write completion function * Invoked by all layout drivers when write_pagelist is done. -* -* NOTE: callers set data->pnfsflags PNFS_NO_RPC -* so that the NFS cleanup routines perform only the page cache -* cleanup. */ static void pnfs_write_retry (struct work_struct *work)
@@ -1450,18 +1442,6 @@ pnfs_writeback_done(struct nfs_write_data *data)dprintk ("%s: Begin (status %d)\n" , __func__, data->task.tk_status); -/* update last write offset and need layout commit -* for non-files layout types (files layout calls -* pnfs4_write_done for this) -*/ -if ((pdata->pnfsflags &PNFS_NO_RPC ) && - data->task.tk_status >=0 && data->res.count >0 ) { -struct nfs_inode *nfsi =NFS_I (data->inode); - -pnfs_update_last_write (nfsi, data->args.offset, data->res.count); -pnfs_need_layoutcommit (nfsi, data->args.context); - } -if (pnfs_call_done (pdata, &data->task, data) == -EAGAIN ) {INIT_WORK (&data->task.u.tk_work, pnfs_write_retry);queue_work (nfsiod_workqueue, &data->task.u.tk_work);
@@ -1507,8 +1487,6 @@ pnfs_writepages(struct nfs_write_data *wdata, int how) __func__, how, numpages); -if (!pnfs_use_rpc (nfss)) - wdata->pdata.pnfsflags |=PNFS_NO_RPC ; wdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->write_pagelist( &nfsi->layout,
@@ -1521,7 +1499,6 @@ pnfs_writepages(struct nfs_write_data *wdata, int how) wdata);if (trypnfs ==PNFS_NOT_ATTEMPTED ) { - wdata->pdata.pnfsflags &= ~PNFS_NO_RPC ; wdata->pdata.lseg =NULL ;put_lseg (lseg); }
@@ -1597,8 +1574,6 @@ pnfs_readpages(struct nfs_read_data *rdata)dprintk ("%s: Calling layout driver read with %d pages\n" , __func__, numpages); -if (!pnfs_use_rpc (nfss)) - rdata->pdata.pnfsflags |=PNFS_NO_RPC ; rdata->pdata.lseg = lseg; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->read_pagelist( &nfsi->layout,
@@ -1609,7 +1584,6 @@ pnfs_readpages(struct nfs_read_data *rdata) args->count, rdata);if (trypnfs ==PNFS_NOT_ATTEMPTED ) { - rdata->pdata.pnfsflags &= ~PNFS_NO_RPC ; rdata->pdata.lseg =NULL ;put_lseg (lseg); }
@@ -1688,12 +1662,8 @@ pnfs_commit(struct nfs_write_data *data, int sync)* This will be done by passing the buck to the layout driver. */ data->pdata.lseg =NULL ; -if (!pnfs_use_rpc (nfss)) - data->pdata.pnfsflags |=PNFS_NO_RPC ; trypnfs = nfss->pnfs_curr_ld->ld_io_ops->commit (&nfsi->layout, sync, data); -if (trypnfs ==PNFS_NOT_ATTEMPTED ) - data->pdata.pnfsflags &= ~PNFS_NO_RPC ;dprintk ("%s End (trypnfs:%d)\n" , __func__, trypnfs);return trypnfs; }
fs/nfs/pnfs.h +0 -13
@@ -195,14 +195,6 @@ static inline int pnfs_get_read_status(struct nfs_read_data *data) return data->pdata.pnfs_error; } -static inline int pnfs_use_rpc (struct nfs_server *nfss) -{ -if (pnfs_enabled_sb (nfss)) -return pnfs_ld_use_rpc_code (nfss->pnfs_curr_ld); - -return 1 ; -} -#else /* CONFIG_NFS_V4_1 */ static inline void get_lseg (struct pnfs_layout_segment *lseg)
@@ -253,11 +245,6 @@ static inline int pnfs_get_read_status(struct nfs_read_data *data)return 0 ; } -static inline int pnfs_use_rpc (struct nfs_server *nfss) -{ -return 1 ; -} -static inline int pnfs_layoutcommit_inode (struct inode *inode,int sync) {return 0 ;
include/linux/nfs4_pnfs.h +0 -10
@@ -173,9 +173,6 @@ struct layoutdriver_io_operations { };enum layoutdriver_policy_flags { -/* Should the full nfs rpc cleanup code be used after io */ -PNFS_USE_RPC_CODE =1 <<0 , -/* Should the NFS req. gather algorithm cross stripe boundaries? */ PNFS_GATHER_ACROSS_STRIPES =1 <<1 ,
@@ -193,13 +190,6 @@ struct layoutdriver_policy_operations {int (*pg_test)(struct nfs_pageio_descriptor *,struct nfs_page *,struct nfs_page *); }; -/* Should the full nfs rpc cleanup code be used after io */ -static inline int -pnfs_ld_use_rpc_code (struct pnfs_layoutdriver_type *ld) -{ -return ld->ld_policy_ops->flags &PNFS_USE_RPC_CODE ; -} -/* Should the NFS req. gather algorithm cross stripe boundaries? */ static inline int pnfs_ld_gather_across_stripes (struct pnfs_layoutdriver_type *ld)
include/linux/nfs_xdr.h +0 -3
@@ -967,8 +967,6 @@ struct nfs_page;#define NFS_PAGEVEC_SIZE (8U)#if defined(CONFIG_NFS_V4_1 ) -/* pnfsflag values */ -#define PNFS_NO_RPC 0x0001/* non rpc result callback switch */ /* pnfs-specific data needed for read, write, and commit calls */ struct pnfs_call_data {
@@ -976,7 +974,6 @@ struct pnfs_call_data {const struct rpc_call_ops *call_ops;u32 orig_count;/* for retry via MDS */ int pnfs_error; -u8 pnfsflags;u8 how;/* for FLUSH_STABLE */ };
Signature · 1 line
1.6.6.1
PATCH 3/4 pnfs-submit: Remove pnfs_call_done and friends
Filelayout isn't using it, so rip it all out.
--- fs/nfs/pnfs.c | 109 --------------------------------------------- include/linux/nfs4_pnfs.h | 9 ---- 2 files changed, 0 insertions(+), 118 deletions(-)
fs/nfs/pnfs.c +0 -109
@@ -1398,56 +1398,6 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode)pnfs_set_pg_test (inode, pgio); } -static int -pnfs_call_done (struct pnfs_call_data *pdata,struct rpc_task *task,void *data) -{ -put_lseg (pdata->lseg); - pdata->lseg =NULL ; - pdata->call_ops->rpc_call_done (task, data); -if (pdata->pnfs_error == -EAGAIN || task->tk_status == -EAGAIN ) -return -EAGAIN ; -/* -* just restore original rpc call ops -* rpc_release will be called later by the rpc scheduling layer. -*/ - task->tk_ops = pdata->call_ops; -return 0 ; -} - -/* Post-write completion function -* Invoked by all layout drivers when write_pagelist is done. -*/ -static void -pnfs_write_retry (struct work_struct *work) -{ -struct rpc_task *task; -struct nfs_write_data *wdata; -struct nfs4_pnfs_layout_segment range; - -dprintk ("%s enter\n" , __func__); - task = container_of(work, struct rpc_task, u.tk_work); - wdata = container_of(task, struct nfs_write_data, task); - range.iomode =IOMODE_RW ; - range.offset = wdata->args.offset; - range.length = wdata->args.count; -_pnfs_return_layout (wdata->inode, &range,NULL ,RETURN_FILE , true); -pnfs_initiate_write (wdata,NFS_CLIENT (wdata->inode), - wdata->pdata.call_ops, wdata->pdata.how); -} - -static void -pnfs_writeback_done (struct nfs_write_data *data) -{ -struct pnfs_call_data *pdata = &data->pdata; - -dprintk ("%s: Begin (status %d)\n" , __func__, data->task.tk_status); - -if (pnfs_call_done (pdata, &data->task, data) == -EAGAIN ) { -INIT_WORK (&data->task.u.tk_work, pnfs_write_retry); -queue_work (nfsiod_workqueue, &data->task.u.tk_work); - } -} -/* * Call the appropriate parallel I/O subsystem write function. * If no I/O device driver exists, or one does match the returned
@@ -1506,40 +1456,6 @@ pnfs_writepages(struct nfs_write_data *wdata, int how)return trypnfs; } -/* Post-read completion function. Invoked by all layout drivers when -* read_pagelist is done -*/ -static void -pnfs_read_retry (struct work_struct *work) -{ -struct rpc_task *task; -struct nfs_read_data *rdata; -struct nfs4_pnfs_layout_segment range; - -dprintk ("%s enter\n" , __func__); - task = container_of(work, struct rpc_task, u.tk_work); - rdata = container_of(task, struct nfs_read_data, task); - range.iomode =IOMODE_RW ; - range.offset = rdata->args.offset; - range.length = rdata->args.count; -_pnfs_return_layout (rdata->inode, &range,NULL ,RETURN_FILE , true); -pnfs_initiate_read (rdata,NFS_CLIENT (rdata->inode), - rdata->pdata.call_ops); -} - -static void -pnfs_read_done (struct nfs_read_data *data) -{ -struct pnfs_call_data *pdata = &data->pdata; - -dprintk ("%s: Begin (status %d)\n" , __func__, data->task.tk_status); - -if (pnfs_call_done (pdata, &data->task, data) == -EAGAIN ) { -INIT_WORK (&data->task.u.tk_work, pnfs_read_retry); -queue_work (nfsiod_workqueue, &data->task.u.tk_work); - } -} -/* * Call the appropriate parallel I/O subsystem read function. * If no I/O device driver exists, or one does match the returned
@@ -1623,28 +1539,6 @@ _pnfs_try_to_commit(struct nfs_write_data *data,return pnfs_commit (data, how); } -/* pNFS Commit callback function for all layout drivers */ -static void -pnfs_commit_done (struct nfs_write_data *data) -{ -struct pnfs_call_data *pdata = &data->pdata; - -dprintk ("%s: Begin (status %d)\n" , __func__, data->task.tk_status); - -if (pnfs_call_done (pdata, &data->task, data) == -EAGAIN ) { -struct nfs4_pnfs_layout_segment range = { - .iomode =IOMODE_RW , - .offset = data->args.offset, - .length = data->args.count, - }; -dprintk ("%s: retrying\n" , __func__); -_pnfs_return_layout (data->inode, &range,NULL ,RETURN_FILE , - true); -pnfs_initiate_commit (data,NFS_CLIENT (data->inode), - pdata->call_ops, pdata->how,1 ); - } -} -static enum pnfs_try_status pnfs_commit (struct nfs_write_data *data,int sync) {
@@ -1796,9 +1690,6 @@ out_free:*/ struct pnfs_client_operations pnfs_ops = { .nfs_getdeviceinfo = nfs4_pnfs_getdeviceinfo, - .nfs_readlist_complete = pnfs_read_done, - .nfs_writelist_complete = pnfs_writeback_done, - .nfs_commit_complete = pnfs_commit_done, };EXPORT_SYMBOL (pnfs_unregister_layoutdriver);
include/linux/nfs4_pnfs.h +0 -9
@@ -279,15 +279,6 @@ extern void nfs4_unset_layout_deviceid(struct pnfs_layout_segment *,struct pnfs_client_operations {int (*nfs_getdeviceinfo) (struct nfs_server *,struct pnfs_device *dev); - -/* Post read callback. */ -void (*nfs_readlist_complete) (struct nfs_read_data *nfs_data); - -/* Post write callback. */ -void (*nfs_writelist_complete) (struct nfs_write_data *nfs_data); - -/* Post commit callback. */ -void (*nfs_commit_complete) (struct nfs_write_data *nfs_data);void (*nfs_return_layout) (struct inode *); };
Signature · 1 line
1.6.6.1
PATCH 4/4 pnfs-submit: Remove pnfs_error
It was only being used to signal EAGAIN to the no longer existing pnfs_call_done functions.
--- fs/nfs/nfs4filelayout.c | 6 ------ fs/nfs/pnfs.c | 3 --- fs/nfs/pnfs.h | 10 ---------- fs/nfs/read.c | 6 +----- fs/nfs/write.c | 9 ++------- include/linux/nfs_xdr.h | 1 - 6 files changed, 3 insertions(+), 32 deletions(-)
fs/nfs/nfs4filelayout.c +0 -6
@@ -254,9 +254,6 @@ filelayout_read_pagelist(struct pnfs_layout_type *layoutid,/* Perform an asynchronous read */ nfs_initiate_read (data, ds->ds_clp->cl_rpcclient, &filelayout_read_call_ops); - - data->pdata.pnfs_error =0 ; -return PNFS_ATTEMPTED ; }
@@ -304,8 +301,6 @@ filelayout_write_pagelist(struct pnfs_layout_type *layoutid,*/ nfs_initiate_write (data, ds->ds_clp->cl_rpcclient, &filelayout_write_call_ops, sync); - - data->pdata.pnfs_error =0 ;return PNFS_ATTEMPTED ; }
@@ -678,7 +673,6 @@ filelayout_commit(struct pnfs_layout_type *layoutid, int sync, }kfree (clone_list);kfree (ds_page_list); - data->pdata.pnfs_error =0 ;return PNFS_ATTEMPTED ; mem_error:
fs/nfs/pnfs.c +0 -3
@@ -1513,7 +1513,6 @@ _pnfs_try_to_read_data(struct nfs_read_data *data, {dprintk ("%s: Utilizing pNFS I/O\n" , __func__); data->pdata.call_ops = call_ops; - data->pdata.pnfs_error =0 ;return pnfs_readpages (data); }
@@ -1523,7 +1522,6 @@ _pnfs_try_to_write_data(struct nfs_write_data *data, {dprintk ("--> %s\n" , __func__); data->pdata.call_ops = call_ops; - data->pdata.pnfs_error =0 ; data->pdata.how = how;return pnfs_writepages (data, how); }
@@ -1534,7 +1532,6 @@ _pnfs_try_to_commit(struct nfs_write_data *data, {dprintk ("%s: Utilizing pNFS I/O\n" , __func__); data->pdata.call_ops = call_ops; - data->pdata.pnfs_error =0 ; data->pdata.how = how;return pnfs_commit (data, how); }
fs/nfs/pnfs.h +0 -10
@@ -185,16 +185,6 @@ static inline void pnfs_update_layout(struct inode *ino, } } -static inline int pnfs_get_write_status (struct nfs_write_data *data) -{ -return data->pdata.pnfs_error; -} - -static inline int pnfs_get_read_status (struct nfs_read_data *data) -{ -return data->pdata.pnfs_error; -} -#else /* CONFIG_NFS_V4_1 */ static inline void get_lseg (struct pnfs_layout_segment *lseg)
fs/nfs/read.c +1 -5
@@ -205,8 +205,7 @@ int pnfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt, const struct rpc_call_ops *call_ops) {if (pnfs_try_to_read_data (data, call_ops) ==PNFS_ATTEMPTED ) -return pnfs_get_read_status (data); - +return 0 ;return nfs_initiate_read (data, clnt, call_ops); }
@@ -400,9 +399,6 @@ static void nfs_readpage_retry(struct rpc_task *task, struct nfs_read_data *data argp->offset += resp->count; argp->pgbase += resp->count; argp->count -= resp->count; -#ifdef CONFIG_NFS_V4_1 - data->pdata.pnfs_error = -EAGAIN ; -#endif /* CONFIG_NFS_V4_1 */ nfs_restart_rpc (task, clp); }
fs/nfs/write.c +2 -7
@@ -851,8 +851,7 @@ int pnfs_initiate_write(struct nfs_write_data *data, int how) {if (pnfs_try_to_write_data (data, call_ops, how) ==PNFS_ATTEMPTED ) -return pnfs_get_write_status (data); - +return 0 ;return nfs_initiate_write (data, clnt, call_ops, how); }
@@ -1258,9 +1257,6 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)*/ argp->stable =NFS_FILE_SYNC ; } -#ifdef CONFIG_NFS_V4_1 - data->pdata.pnfs_error = -EAGAIN ; -#endif /* CONFIG_NFS_V4_1 */ nfs_restart_rpc (task, clp);return -EAGAIN ; }
@@ -1350,8 +1346,7 @@ int pnfs_initiate_commit(struct nfs_write_data *data, {if (pnfs && (pnfs_try_to_commit (data, &nfs_commit_ops, how) ==PNFS_ATTEMPTED )) -return pnfs_get_write_status (data); - +return 0 ;return nfs_initiate_commit (data, clnt, &nfs_commit_ops, how); }
include/linux/nfs_xdr.h +0 -1
@@ -973,7 +973,6 @@ struct pnfs_call_data {struct pnfs_layout_segment *lseg;const struct rpc_call_ops *call_ops;u32 orig_count;/* for retry via MDS */ -int pnfs_error;u8 how;/* for FLUSH_STABLE */ };
Signature · 1 line
1.6.6.1
Quoted 10 lines · Fred Isaman
These patches remove
pnfs_call_doneand all the routines associated with it. They were quite buggy for filelayout, and tended to crash the client anytime EAGAIN handling was invoked (in particular on short reads.)The first patch just has filelayout avoid using them entirely. It should NOT be reverted in the post-submit.
The subsequent patches remove the unused code for pnfs-submit. It is expected they will be reverted in the post-submit.
Quoted 6 lines
Fred
--
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
Merged at pnfs-all-2.6.35-rc3-2010-06-14 pnfs-submit patches 2/4 to 4/4 reverted in pnfs post submit.
Thanks!
Benny