* pageio_init simplifications, V2
@ 2014-04-16 13:07 Christoph Hellwig
2014-04-16 13:07 ` [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops Christoph Hellwig
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Christoph Hellwig @ 2014-04-16 13:07 UTC (permalink / raw)
To: Trond Myklebust; +Cc: Anna Schumaker, linux-nfs
Changes since last version:
- add the missing exports as pointed out by Anna
- handle the pnfs fallback to MDS case correctly
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops 2014-04-16 13:07 pageio_init simplifications, V2 Christoph Hellwig @ 2014-04-16 13:07 ` Christoph Hellwig 2014-04-17 14:50 ` Anna Schumaker 2014-04-16 13:07 ` [PATCH 2/2] nfs: remove ->read_pageio_init " Christoph Hellwig 2014-05-28 23:01 ` pageio_init simplifications, V2 Trond Myklebust 2 siblings, 1 reply; 6+ messages in thread From: Christoph Hellwig @ 2014-04-16 13:07 UTC (permalink / raw) To: Trond Myklebust; +Cc: Anna Schumaker, linux-nfs The write_pageio_init method is just a very convoluted way to grab the right nfs_pageio_ops vector. The vector to chose is not a choice of protocol version, but just a pNFS vs MDS I/O choice that can simply be done inside nfs_pageio_init_write based on the presence of a layout driver, and a new force_mds flag to the special case of falling back to MDS I/O on a pNFS-capable volume. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/nfs/direct.c | 4 ++-- fs/nfs/internal.h | 2 +- fs/nfs/nfs3proc.c | 1 - fs/nfs/nfs4proc.c | 1 - fs/nfs/pnfs.c | 16 +--------------- fs/nfs/pnfs.h | 8 -------- fs/nfs/proc.c | 1 - fs/nfs/write.c | 21 +++++++++++++-------- include/linux/nfs_xdr.h | 2 -- 9 files changed, 17 insertions(+), 39 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index b8797ae..6a31102 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -564,7 +564,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) dreq->count = 0; get_dreq(dreq); - NFS_PROTO(dreq->inode)->write_pageio_init(&desc, dreq->inode, FLUSH_STABLE, + nfs_pageio_init_write(&desc, dreq->inode, FLUSH_STABLE, false, &nfs_direct_write_completion_ops); desc.pg_dreq = dreq; @@ -874,7 +874,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, size_t requested_bytes = 0; unsigned long seg; - NFS_PROTO(inode)->write_pageio_init(&desc, inode, FLUSH_COND_STABLE, + nfs_pageio_init_write(&desc, inode, FLUSH_COND_STABLE, false, &nfs_direct_write_completion_ops); desc.pg_dreq = dreq; get_dreq(dreq); diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index dd8bfc2..8431083 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -422,7 +422,7 @@ int nfs_remount(struct super_block *sb, int *flags, char *raw_data); /* write.c */ extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, - struct inode *inode, int ioflags, + struct inode *inode, int ioflags, bool force_mds, const struct nfs_pgio_completion_ops *compl_ops); extern struct nfs_write_header *nfs_writehdr_alloc(void); extern void nfs_writehdr_free(struct nfs_pgio_header *hdr); diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index db60149..e984880 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -951,7 +951,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .read_rpc_prepare = nfs3_proc_read_rpc_prepare, .read_done = nfs3_read_done, .write_setup = nfs3_proc_write_setup, - .write_pageio_init = nfs_pageio_init_write, .write_rpc_prepare = nfs3_proc_write_rpc_prepare, .write_done = nfs3_write_done, .commit_setup = nfs3_proc_commit_setup, diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 397be39..8da0c62 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -8437,7 +8437,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .read_rpc_prepare = nfs4_proc_read_rpc_prepare, .read_done = nfs4_read_done, .write_setup = nfs4_proc_write_setup, - .write_pageio_init = pnfs_pageio_init_write, .write_rpc_prepare = nfs4_proc_write_rpc_prepare, .write_done = nfs4_write_done, .commit_setup = nfs4_proc_commit_setup, diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index cb53d45..9edac9f 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1447,20 +1447,6 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0); } -void -pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, - int ioflags, - const struct nfs_pgio_completion_ops *compl_ops) -{ - struct nfs_server *server = NFS_SERVER(inode); - struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; - - if (ld == NULL) - nfs_pageio_init_write(pgio, inode, ioflags, compl_ops); - else - nfs_pageio_init(pgio, inode, ld->pg_write_ops, compl_ops, server->wsize, ioflags); -} - bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req) @@ -1496,7 +1482,7 @@ int pnfs_write_done_resend_to_mds(struct inode *inode, LIST_HEAD(failed); /* Resend all requests through the MDS */ - nfs_pageio_init_write(&pgio, inode, FLUSH_STABLE, compl_ops); + nfs_pageio_init_write(&pgio, inode, FLUSH_STABLE, true, compl_ops); pgio.pg_dreq = dreq; while (!list_empty(head)) { struct nfs_page *req = nfs_list_entry(head->next); diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index 0237939..e9ac8fb 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -182,8 +182,6 @@ void pnfs_put_lseg(struct pnfs_layout_segment *lseg); void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *, const struct nfs_pgio_completion_ops *); -void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, - int, const struct nfs_pgio_completion_ops *); void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32); void unset_pnfs_layoutdriver(struct nfs_server *); @@ -467,12 +465,6 @@ static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, str nfs_pageio_init_read(pgio, inode, compl_ops); } -static inline void pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags, - const struct nfs_pgio_completion_ops *compl_ops) -{ - nfs_pageio_init_write(pgio, inode, ioflags, compl_ops); -} - static inline int pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how, struct nfs_commit_info *cinfo) diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index e55ce9e..f9cc295 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -739,7 +739,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .read_rpc_prepare = nfs_proc_read_rpc_prepare, .read_done = nfs_read_done, .write_setup = nfs_proc_write_setup, - .write_pageio_init = nfs_pageio_init_write, .write_rpc_prepare = nfs_proc_write_rpc_prepare, .write_done = nfs_write_done, .commit_setup = nfs_proc_commit_setup, diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 9a3b6a4..0bd1724 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -354,10 +354,8 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc struct nfs_pageio_descriptor pgio; int err; - NFS_PROTO(page_file_mapping(page)->host)->write_pageio_init(&pgio, - page->mapping->host, - wb_priority(wbc), - &nfs_async_write_completion_ops); + nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc), + false, &nfs_async_write_completion_ops); err = nfs_do_writepage(page, wbc, &pgio); nfs_pageio_complete(&pgio); if (err < 0) @@ -400,7 +398,8 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); - NFS_PROTO(inode)->write_pageio_init(&pgio, inode, wb_priority(wbc), &nfs_async_write_completion_ops); + nfs_pageio_init_write(&pgio, inode, wb_priority(wbc), false, + &nfs_async_write_completion_ops); err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio); nfs_pageio_complete(&pgio); @@ -1282,11 +1281,17 @@ static const struct nfs_pageio_ops nfs_pageio_write_ops = { }; void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, - struct inode *inode, int ioflags, + struct inode *inode, int ioflags, bool force_mds, const struct nfs_pgio_completion_ops *compl_ops) { - nfs_pageio_init(pgio, inode, &nfs_pageio_write_ops, compl_ops, - NFS_SERVER(inode)->wsize, ioflags); + struct nfs_server *server = NFS_SERVER(inode); + const struct nfs_pageio_ops *pg_ops = &nfs_pageio_write_ops; + +#ifdef CONFIG_NFS_V4_1 + if (server->pnfs_curr_ld && !force_mds) + pg_ops = server->pnfs_curr_ld->pg_write_ops; +#endif + nfs_pageio_init(pgio, inode, pg_ops, compl_ops, server->wsize, ioflags); } EXPORT_SYMBOL_GPL(nfs_pageio_init_write); diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 6fb5b23..78216f8 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1471,8 +1471,6 @@ struct nfs_rpc_ops { int (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *); int (*read_done) (struct rpc_task *, struct nfs_read_data *); void (*write_setup) (struct nfs_write_data *, struct rpc_message *); - void (*write_pageio_init)(struct nfs_pageio_descriptor *, struct inode *, int, - const struct nfs_pgio_completion_ops *); int (*write_rpc_prepare)(struct rpc_task *, struct nfs_write_data *); int (*write_done) (struct rpc_task *, struct nfs_write_data *); void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *); -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops 2014-04-16 13:07 ` [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops Christoph Hellwig @ 2014-04-17 14:50 ` Anna Schumaker 0 siblings, 0 replies; 6+ messages in thread From: Anna Schumaker @ 2014-04-17 14:50 UTC (permalink / raw) To: Christoph Hellwig, Trond Myklebust; +Cc: Anna Schumaker, linux-nfs On 04/16/2014 09:07 AM, Christoph Hellwig wrote: > The write_pageio_init method is just a very convoluted way to grab the > right nfs_pageio_ops vector. The vector to chose is not a choice of > protocol version, but just a pNFS vs MDS I/O choice that can simply be > done inside nfs_pageio_init_write based on the presence of a layout > driver, and a new force_mds flag to the special case of falling back > to MDS I/O on a pNFS-capable volume. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Tested-by: Anna Schumaker <Anna.Schumaker@Netapp.com> > --- > fs/nfs/direct.c | 4 ++-- > fs/nfs/internal.h | 2 +- > fs/nfs/nfs3proc.c | 1 - > fs/nfs/nfs4proc.c | 1 - > fs/nfs/pnfs.c | 16 +--------------- > fs/nfs/pnfs.h | 8 -------- > fs/nfs/proc.c | 1 - > fs/nfs/write.c | 21 +++++++++++++-------- > include/linux/nfs_xdr.h | 2 -- > 9 files changed, 17 insertions(+), 39 deletions(-) > > diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c > index b8797ae..6a31102 100644 > --- a/fs/nfs/direct.c > +++ b/fs/nfs/direct.c > @@ -564,7 +564,7 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq) > dreq->count = 0; > get_dreq(dreq); > > - NFS_PROTO(dreq->inode)->write_pageio_init(&desc, dreq->inode, FLUSH_STABLE, > + nfs_pageio_init_write(&desc, dreq->inode, FLUSH_STABLE, false, > &nfs_direct_write_completion_ops); > desc.pg_dreq = dreq; > > @@ -874,7 +874,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, > size_t requested_bytes = 0; > unsigned long seg; > > - NFS_PROTO(inode)->write_pageio_init(&desc, inode, FLUSH_COND_STABLE, > + nfs_pageio_init_write(&desc, inode, FLUSH_COND_STABLE, false, > &nfs_direct_write_completion_ops); > desc.pg_dreq = dreq; > get_dreq(dreq); > diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h > index dd8bfc2..8431083 100644 > --- a/fs/nfs/internal.h > +++ b/fs/nfs/internal.h > @@ -422,7 +422,7 @@ int nfs_remount(struct super_block *sb, int *flags, char *raw_data); > > /* write.c */ > extern void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, > - struct inode *inode, int ioflags, > + struct inode *inode, int ioflags, bool force_mds, > const struct nfs_pgio_completion_ops *compl_ops); > extern struct nfs_write_header *nfs_writehdr_alloc(void); > extern void nfs_writehdr_free(struct nfs_pgio_header *hdr); > diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c > index db60149..e984880 100644 > --- a/fs/nfs/nfs3proc.c > +++ b/fs/nfs/nfs3proc.c > @@ -951,7 +951,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { > .read_rpc_prepare = nfs3_proc_read_rpc_prepare, > .read_done = nfs3_read_done, > .write_setup = nfs3_proc_write_setup, > - .write_pageio_init = nfs_pageio_init_write, > .write_rpc_prepare = nfs3_proc_write_rpc_prepare, > .write_done = nfs3_write_done, > .commit_setup = nfs3_proc_commit_setup, > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c > index 397be39..8da0c62 100644 > --- a/fs/nfs/nfs4proc.c > +++ b/fs/nfs/nfs4proc.c > @@ -8437,7 +8437,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { > .read_rpc_prepare = nfs4_proc_read_rpc_prepare, > .read_done = nfs4_read_done, > .write_setup = nfs4_proc_write_setup, > - .write_pageio_init = pnfs_pageio_init_write, > .write_rpc_prepare = nfs4_proc_write_rpc_prepare, > .write_done = nfs4_write_done, > .commit_setup = nfs4_proc_commit_setup, > diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c > index cb53d45..9edac9f 100644 > --- a/fs/nfs/pnfs.c > +++ b/fs/nfs/pnfs.c > @@ -1447,20 +1447,6 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, > nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0); > } > > -void > -pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, > - int ioflags, > - const struct nfs_pgio_completion_ops *compl_ops) > -{ > - struct nfs_server *server = NFS_SERVER(inode); > - struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; > - > - if (ld == NULL) > - nfs_pageio_init_write(pgio, inode, ioflags, compl_ops); > - else > - nfs_pageio_init(pgio, inode, ld->pg_write_ops, compl_ops, server->wsize, ioflags); > -} > - > bool > pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, > struct nfs_page *req) > @@ -1496,7 +1482,7 @@ int pnfs_write_done_resend_to_mds(struct inode *inode, > LIST_HEAD(failed); > > /* Resend all requests through the MDS */ > - nfs_pageio_init_write(&pgio, inode, FLUSH_STABLE, compl_ops); > + nfs_pageio_init_write(&pgio, inode, FLUSH_STABLE, true, compl_ops); > pgio.pg_dreq = dreq; > while (!list_empty(head)) { > struct nfs_page *req = nfs_list_entry(head->next); > diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h > index 0237939..e9ac8fb 100644 > --- a/fs/nfs/pnfs.h > +++ b/fs/nfs/pnfs.h > @@ -182,8 +182,6 @@ void pnfs_put_lseg(struct pnfs_layout_segment *lseg); > > void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *, > const struct nfs_pgio_completion_ops *); > -void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *, > - int, const struct nfs_pgio_completion_ops *); > > void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32); > void unset_pnfs_layoutdriver(struct nfs_server *); > @@ -467,12 +465,6 @@ static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, str > nfs_pageio_init_read(pgio, inode, compl_ops); > } > > -static inline void pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags, > - const struct nfs_pgio_completion_ops *compl_ops) > -{ > - nfs_pageio_init_write(pgio, inode, ioflags, compl_ops); > -} > - > static inline int > pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how, > struct nfs_commit_info *cinfo) > diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c > index e55ce9e..f9cc295 100644 > --- a/fs/nfs/proc.c > +++ b/fs/nfs/proc.c > @@ -739,7 +739,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { > .read_rpc_prepare = nfs_proc_read_rpc_prepare, > .read_done = nfs_read_done, > .write_setup = nfs_proc_write_setup, > - .write_pageio_init = nfs_pageio_init_write, > .write_rpc_prepare = nfs_proc_write_rpc_prepare, > .write_done = nfs_write_done, > .commit_setup = nfs_proc_commit_setup, > diff --git a/fs/nfs/write.c b/fs/nfs/write.c > index 9a3b6a4..0bd1724 100644 > --- a/fs/nfs/write.c > +++ b/fs/nfs/write.c > @@ -354,10 +354,8 @@ static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc > struct nfs_pageio_descriptor pgio; > int err; > > - NFS_PROTO(page_file_mapping(page)->host)->write_pageio_init(&pgio, > - page->mapping->host, > - wb_priority(wbc), > - &nfs_async_write_completion_ops); > + nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc), > + false, &nfs_async_write_completion_ops); > err = nfs_do_writepage(page, wbc, &pgio); > nfs_pageio_complete(&pgio); > if (err < 0) > @@ -400,7 +398,8 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) > > nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); > > - NFS_PROTO(inode)->write_pageio_init(&pgio, inode, wb_priority(wbc), &nfs_async_write_completion_ops); > + nfs_pageio_init_write(&pgio, inode, wb_priority(wbc), false, > + &nfs_async_write_completion_ops); > err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio); > nfs_pageio_complete(&pgio); > > @@ -1282,11 +1281,17 @@ static const struct nfs_pageio_ops nfs_pageio_write_ops = { > }; > > void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, > - struct inode *inode, int ioflags, > + struct inode *inode, int ioflags, bool force_mds, > const struct nfs_pgio_completion_ops *compl_ops) > { > - nfs_pageio_init(pgio, inode, &nfs_pageio_write_ops, compl_ops, > - NFS_SERVER(inode)->wsize, ioflags); > + struct nfs_server *server = NFS_SERVER(inode); > + const struct nfs_pageio_ops *pg_ops = &nfs_pageio_write_ops; > + > +#ifdef CONFIG_NFS_V4_1 > + if (server->pnfs_curr_ld && !force_mds) > + pg_ops = server->pnfs_curr_ld->pg_write_ops; > +#endif > + nfs_pageio_init(pgio, inode, pg_ops, compl_ops, server->wsize, ioflags); > } > EXPORT_SYMBOL_GPL(nfs_pageio_init_write); > > diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h > index 6fb5b23..78216f8 100644 > --- a/include/linux/nfs_xdr.h > +++ b/include/linux/nfs_xdr.h > @@ -1471,8 +1471,6 @@ struct nfs_rpc_ops { > int (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *); > int (*read_done) (struct rpc_task *, struct nfs_read_data *); > void (*write_setup) (struct nfs_write_data *, struct rpc_message *); > - void (*write_pageio_init)(struct nfs_pageio_descriptor *, struct inode *, int, > - const struct nfs_pgio_completion_ops *); > int (*write_rpc_prepare)(struct rpc_task *, struct nfs_write_data *); > int (*write_done) (struct rpc_task *, struct nfs_write_data *); > void (*commit_setup) (struct nfs_commit_data *, struct rpc_message *); ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] nfs: remove ->read_pageio_init from rpc ops 2014-04-16 13:07 pageio_init simplifications, V2 Christoph Hellwig 2014-04-16 13:07 ` [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops Christoph Hellwig @ 2014-04-16 13:07 ` Christoph Hellwig 2014-04-17 14:50 ` Anna Schumaker 2014-05-28 23:01 ` pageio_init simplifications, V2 Trond Myklebust 2 siblings, 1 reply; 6+ messages in thread From: Christoph Hellwig @ 2014-04-16 13:07 UTC (permalink / raw) To: Trond Myklebust; +Cc: Anna Schumaker, linux-nfs The read_pageio_init method is just a very convoluted way to grab the right nfs_pageio_ops vector. The vector to chose is not a choice of protocol version, but just a pNFS vs MDS I/O choice that can simply be done inside nfs_pageio_init_write based on the presence of a layout driver, and a new force_mds flag to the special case of falling back to MDS I/O on a pNFS-capable volume. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/nfs/direct.c | 2 +- fs/nfs/internal.h | 2 +- fs/nfs/nfs3proc.c | 1 - fs/nfs/nfs4proc.c | 1 - fs/nfs/pnfs.c | 15 +-------------- fs/nfs/pnfs.h | 9 --------- fs/nfs/proc.c | 1 - fs/nfs/read.c | 19 ++++++++++++++----- include/linux/nfs_xdr.h | 2 -- 9 files changed, 17 insertions(+), 35 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 6a31102..bbe688e 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -424,7 +424,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq, size_t requested_bytes = 0; unsigned long seg; - NFS_PROTO(dreq->inode)->read_pageio_init(&desc, dreq->inode, + nfs_pageio_init_read(&desc, dreq->inode, false, &nfs_direct_read_completion_ops); get_dreq(dreq); desc.pg_dreq = dreq; diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 8431083..98fe618 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -398,7 +398,7 @@ struct nfs_pgio_completion_ops; extern struct nfs_read_header *nfs_readhdr_alloc(void); extern void nfs_readhdr_free(struct nfs_pgio_header *hdr); extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, - struct inode *inode, + struct inode *inode, bool force_mds, const struct nfs_pgio_completion_ops *compl_ops); extern int nfs_initiate_read(struct rpc_clnt *clnt, struct nfs_read_data *data, diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index e984880..d873241 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -947,7 +947,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { .pathconf = nfs3_proc_pathconf, .decode_dirent = nfs3_decode_dirent, .read_setup = nfs3_proc_read_setup, - .read_pageio_init = nfs_pageio_init_read, .read_rpc_prepare = nfs3_proc_read_rpc_prepare, .read_done = nfs3_read_done, .write_setup = nfs3_proc_write_setup, diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 8da0c62..21cd1f2 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -8433,7 +8433,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { .set_capabilities = nfs4_server_capabilities, .decode_dirent = nfs4_decode_dirent, .read_setup = nfs4_proc_read_setup, - .read_pageio_init = pnfs_pageio_init_read, .read_rpc_prepare = nfs4_proc_read_rpc_prepare, .read_done = nfs4_read_done, .write_setup = nfs4_proc_write_setup, diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 9edac9f..3d5bc2b 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1434,19 +1434,6 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, } EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); -void -pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, - const struct nfs_pgio_completion_ops *compl_ops) -{ - struct nfs_server *server = NFS_SERVER(inode); - struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; - - if (ld == NULL) - nfs_pageio_init_read(pgio, inode, compl_ops); - else - nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0); -} - bool pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, struct nfs_page *req) @@ -1641,7 +1628,7 @@ int pnfs_read_done_resend_to_mds(struct inode *inode, LIST_HEAD(failed); /* Resend all requests through the MDS */ - nfs_pageio_init_read(&pgio, inode, compl_ops); + nfs_pageio_init_read(&pgio, inode, true, compl_ops); pgio.pg_dreq = dreq; while (!list_empty(head)) { struct nfs_page *req = nfs_list_entry(head->next); diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index e9ac8fb..94a9a18 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -180,9 +180,6 @@ extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp); void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo); void pnfs_put_lseg(struct pnfs_layout_segment *lseg); -void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *, - const struct nfs_pgio_completion_ops *); - void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32); void unset_pnfs_layoutdriver(struct nfs_server *); void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *); @@ -459,12 +456,6 @@ static inline void unset_pnfs_layoutdriver(struct nfs_server *s) { } -static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, - const struct nfs_pgio_completion_ops *compl_ops) -{ - nfs_pageio_init_read(pgio, inode, compl_ops); -} - static inline int pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how, struct nfs_commit_info *cinfo) diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index f9cc295..8cc227f 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c @@ -735,7 +735,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { .pathconf = nfs_proc_pathconf, .decode_dirent = nfs2_decode_dirent, .read_setup = nfs_proc_read_setup, - .read_pageio_init = nfs_pageio_init_read, .read_rpc_prepare = nfs_proc_read_rpc_prepare, .read_done = nfs_read_done, .write_setup = nfs_proc_write_setup, diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 411aedd..7f87461 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -24,6 +24,7 @@ #include "internal.h" #include "iostat.h" #include "fscache.h" +#include "pnfs.h" #define NFSDBG_FACILITY NFSDBG_PAGECACHE @@ -114,11 +115,17 @@ int nfs_return_empty_page(struct page *page) } void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, - struct inode *inode, + struct inode *inode, bool force_mds, const struct nfs_pgio_completion_ops *compl_ops) { - nfs_pageio_init(pgio, inode, &nfs_pageio_read_ops, compl_ops, - NFS_SERVER(inode)->rsize, 0); + struct nfs_server *server = NFS_SERVER(inode); + const struct nfs_pageio_ops *pg_ops = &nfs_pageio_read_ops; + +#ifdef CONFIG_NFS_V4_1 + if (server->pnfs_curr_ld && !force_mds) + pg_ops = server->pnfs_curr_ld->pg_read_ops; +#endif + nfs_pageio_init(pgio, inode, pg_ops, compl_ops, server->rsize, 0); } EXPORT_SYMBOL_GPL(nfs_pageio_init_read); @@ -147,7 +154,8 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, if (len < PAGE_CACHE_SIZE) zero_user_segment(page, len, PAGE_CACHE_SIZE); - NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops); + nfs_pageio_init_read(&pgio, inode, false, + &nfs_async_read_completion_ops); nfs_pageio_add_request(&pgio, new); nfs_pageio_complete(&pgio); NFS_I(inode)->read_io += pgio.pg_bytes_written; @@ -654,7 +662,8 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, if (ret == 0) goto read_complete; /* all pages were read */ - NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops); + nfs_pageio_init_read(&pgio, inode, false, + &nfs_async_read_completion_ops); ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 78216f8..3e8fc1f 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1466,8 +1466,6 @@ struct nfs_rpc_ops { int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); void (*read_setup) (struct nfs_read_data *, struct rpc_message *); - void (*read_pageio_init)(struct nfs_pageio_descriptor *, struct inode *, - const struct nfs_pgio_completion_ops *); int (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *); int (*read_done) (struct rpc_task *, struct nfs_read_data *); void (*write_setup) (struct nfs_write_data *, struct rpc_message *); -- 1.7.10.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] nfs: remove ->read_pageio_init from rpc ops 2014-04-16 13:07 ` [PATCH 2/2] nfs: remove ->read_pageio_init " Christoph Hellwig @ 2014-04-17 14:50 ` Anna Schumaker 0 siblings, 0 replies; 6+ messages in thread From: Anna Schumaker @ 2014-04-17 14:50 UTC (permalink / raw) To: Christoph Hellwig, Trond Myklebust; +Cc: Anna Schumaker, linux-nfs On 04/16/2014 09:07 AM, Christoph Hellwig wrote: > The read_pageio_init method is just a very convoluted way to grab the > right nfs_pageio_ops vector. The vector to chose is not a choice of > protocol version, but just a pNFS vs MDS I/O choice that can simply be > done inside nfs_pageio_init_write based on the presence of a layout > driver, and a new force_mds flag to the special case of falling back > to MDS I/O on a pNFS-capable volume. > > Signed-off-by: Christoph Hellwig <hch@lst.de> The commit message for this patch needs to change "nfs_pageio_init_write" into "nfs_pageio_init_read". I haven't had any problems with the code! Tested-by: Anna Schumaker <Anna.Schumaker@Netapp.com> > --- > fs/nfs/direct.c | 2 +- > fs/nfs/internal.h | 2 +- > fs/nfs/nfs3proc.c | 1 - > fs/nfs/nfs4proc.c | 1 - > fs/nfs/pnfs.c | 15 +-------------- > fs/nfs/pnfs.h | 9 --------- > fs/nfs/proc.c | 1 - > fs/nfs/read.c | 19 ++++++++++++++----- > include/linux/nfs_xdr.h | 2 -- > 9 files changed, 17 insertions(+), 35 deletions(-) > > diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c > index 6a31102..bbe688e 100644 > --- a/fs/nfs/direct.c > +++ b/fs/nfs/direct.c > @@ -424,7 +424,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq, > size_t requested_bytes = 0; > unsigned long seg; > > - NFS_PROTO(dreq->inode)->read_pageio_init(&desc, dreq->inode, > + nfs_pageio_init_read(&desc, dreq->inode, false, > &nfs_direct_read_completion_ops); > get_dreq(dreq); > desc.pg_dreq = dreq; > diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h > index 8431083..98fe618 100644 > --- a/fs/nfs/internal.h > +++ b/fs/nfs/internal.h > @@ -398,7 +398,7 @@ struct nfs_pgio_completion_ops; > extern struct nfs_read_header *nfs_readhdr_alloc(void); > extern void nfs_readhdr_free(struct nfs_pgio_header *hdr); > extern void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, > - struct inode *inode, > + struct inode *inode, bool force_mds, > const struct nfs_pgio_completion_ops *compl_ops); > extern int nfs_initiate_read(struct rpc_clnt *clnt, > struct nfs_read_data *data, > diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c > index e984880..d873241 100644 > --- a/fs/nfs/nfs3proc.c > +++ b/fs/nfs/nfs3proc.c > @@ -947,7 +947,6 @@ const struct nfs_rpc_ops nfs_v3_clientops = { > .pathconf = nfs3_proc_pathconf, > .decode_dirent = nfs3_decode_dirent, > .read_setup = nfs3_proc_read_setup, > - .read_pageio_init = nfs_pageio_init_read, > .read_rpc_prepare = nfs3_proc_read_rpc_prepare, > .read_done = nfs3_read_done, > .write_setup = nfs3_proc_write_setup, > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c > index 8da0c62..21cd1f2 100644 > --- a/fs/nfs/nfs4proc.c > +++ b/fs/nfs/nfs4proc.c > @@ -8433,7 +8433,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = { > .set_capabilities = nfs4_server_capabilities, > .decode_dirent = nfs4_decode_dirent, > .read_setup = nfs4_proc_read_setup, > - .read_pageio_init = pnfs_pageio_init_read, > .read_rpc_prepare = nfs4_proc_read_rpc_prepare, > .read_done = nfs4_read_done, > .write_setup = nfs4_proc_write_setup, > diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c > index 9edac9f..3d5bc2b 100644 > --- a/fs/nfs/pnfs.c > +++ b/fs/nfs/pnfs.c > @@ -1434,19 +1434,6 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, > } > EXPORT_SYMBOL_GPL(pnfs_generic_pg_init_write); > > -void > -pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, > - const struct nfs_pgio_completion_ops *compl_ops) > -{ > - struct nfs_server *server = NFS_SERVER(inode); > - struct pnfs_layoutdriver_type *ld = server->pnfs_curr_ld; > - > - if (ld == NULL) > - nfs_pageio_init_read(pgio, inode, compl_ops); > - else > - nfs_pageio_init(pgio, inode, ld->pg_read_ops, compl_ops, server->rsize, 0); > -} > - > bool > pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev, > struct nfs_page *req) > @@ -1641,7 +1628,7 @@ int pnfs_read_done_resend_to_mds(struct inode *inode, > LIST_HEAD(failed); > > /* Resend all requests through the MDS */ > - nfs_pageio_init_read(&pgio, inode, compl_ops); > + nfs_pageio_init_read(&pgio, inode, true, compl_ops); > pgio.pg_dreq = dreq; > while (!list_empty(head)) { > struct nfs_page *req = nfs_list_entry(head->next); > diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h > index e9ac8fb..94a9a18 100644 > --- a/fs/nfs/pnfs.h > +++ b/fs/nfs/pnfs.h > @@ -180,9 +180,6 @@ extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp); > void pnfs_get_layout_hdr(struct pnfs_layout_hdr *lo); > void pnfs_put_lseg(struct pnfs_layout_segment *lseg); > > -void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *, > - const struct nfs_pgio_completion_ops *); > - > void set_pnfs_layoutdriver(struct nfs_server *, const struct nfs_fh *, u32); > void unset_pnfs_layoutdriver(struct nfs_server *); > void pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *, struct nfs_page *); > @@ -459,12 +456,6 @@ static inline void unset_pnfs_layoutdriver(struct nfs_server *s) > { > } > > -static inline void pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode, > - const struct nfs_pgio_completion_ops *compl_ops) > -{ > - nfs_pageio_init_read(pgio, inode, compl_ops); > -} > - > static inline int > pnfs_commit_list(struct inode *inode, struct list_head *mds_pages, int how, > struct nfs_commit_info *cinfo) > diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c > index f9cc295..8cc227f 100644 > --- a/fs/nfs/proc.c > +++ b/fs/nfs/proc.c > @@ -735,7 +735,6 @@ const struct nfs_rpc_ops nfs_v2_clientops = { > .pathconf = nfs_proc_pathconf, > .decode_dirent = nfs2_decode_dirent, > .read_setup = nfs_proc_read_setup, > - .read_pageio_init = nfs_pageio_init_read, > .read_rpc_prepare = nfs_proc_read_rpc_prepare, > .read_done = nfs_read_done, > .write_setup = nfs_proc_write_setup, > diff --git a/fs/nfs/read.c b/fs/nfs/read.c > index 411aedd..7f87461 100644 > --- a/fs/nfs/read.c > +++ b/fs/nfs/read.c > @@ -24,6 +24,7 @@ > #include "internal.h" > #include "iostat.h" > #include "fscache.h" > +#include "pnfs.h" > > #define NFSDBG_FACILITY NFSDBG_PAGECACHE > > @@ -114,11 +115,17 @@ int nfs_return_empty_page(struct page *page) > } > > void nfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, > - struct inode *inode, > + struct inode *inode, bool force_mds, > const struct nfs_pgio_completion_ops *compl_ops) > { > - nfs_pageio_init(pgio, inode, &nfs_pageio_read_ops, compl_ops, > - NFS_SERVER(inode)->rsize, 0); > + struct nfs_server *server = NFS_SERVER(inode); > + const struct nfs_pageio_ops *pg_ops = &nfs_pageio_read_ops; > + > +#ifdef CONFIG_NFS_V4_1 > + if (server->pnfs_curr_ld && !force_mds) > + pg_ops = server->pnfs_curr_ld->pg_read_ops; > +#endif > + nfs_pageio_init(pgio, inode, pg_ops, compl_ops, server->rsize, 0); > } > EXPORT_SYMBOL_GPL(nfs_pageio_init_read); > > @@ -147,7 +154,8 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode, > if (len < PAGE_CACHE_SIZE) > zero_user_segment(page, len, PAGE_CACHE_SIZE); > > - NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops); > + nfs_pageio_init_read(&pgio, inode, false, > + &nfs_async_read_completion_ops); > nfs_pageio_add_request(&pgio, new); > nfs_pageio_complete(&pgio); > NFS_I(inode)->read_io += pgio.pg_bytes_written; > @@ -654,7 +662,8 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, > if (ret == 0) > goto read_complete; /* all pages were read */ > > - NFS_PROTO(inode)->read_pageio_init(&pgio, inode, &nfs_async_read_completion_ops); > + nfs_pageio_init_read(&pgio, inode, false, > + &nfs_async_read_completion_ops); > > ret = read_cache_pages(mapping, pages, readpage_async_filler, &desc); > > diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h > index 78216f8..3e8fc1f 100644 > --- a/include/linux/nfs_xdr.h > +++ b/include/linux/nfs_xdr.h > @@ -1466,8 +1466,6 @@ struct nfs_rpc_ops { > int (*set_capabilities)(struct nfs_server *, struct nfs_fh *); > int (*decode_dirent)(struct xdr_stream *, struct nfs_entry *, int); > void (*read_setup) (struct nfs_read_data *, struct rpc_message *); > - void (*read_pageio_init)(struct nfs_pageio_descriptor *, struct inode *, > - const struct nfs_pgio_completion_ops *); > int (*read_rpc_prepare)(struct rpc_task *, struct nfs_read_data *); > int (*read_done) (struct rpc_task *, struct nfs_read_data *); > void (*write_setup) (struct nfs_write_data *, struct rpc_message *); ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: pageio_init simplifications, V2 2014-04-16 13:07 pageio_init simplifications, V2 Christoph Hellwig 2014-04-16 13:07 ` [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops Christoph Hellwig 2014-04-16 13:07 ` [PATCH 2/2] nfs: remove ->read_pageio_init " Christoph Hellwig @ 2014-05-28 23:01 ` Trond Myklebust 2 siblings, 0 replies; 6+ messages in thread From: Trond Myklebust @ 2014-05-28 23:01 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Anna Schumaker, Linux NFS Mailing List On Wed, Apr 16, 2014 at 9:07 AM, Christoph Hellwig <hch@lst.de> wrote: > Changes since last version: > > - add the missing exports as pointed out by Anna > - handle the pnfs fallback to MDS case correctly > Thanks! Applied... -- Trond Myklebust Linux NFS client maintainer, PrimaryData trond.myklebust@primarydata.com ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-28 23:01 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-04-16 13:07 pageio_init simplifications, V2 Christoph Hellwig 2014-04-16 13:07 ` [PATCH 1/2] nfs: remove ->write_pageio_init from rpc ops Christoph Hellwig 2014-04-17 14:50 ` Anna Schumaker 2014-04-16 13:07 ` [PATCH 2/2] nfs: remove ->read_pageio_init " Christoph Hellwig 2014-04-17 14:50 ` Anna Schumaker 2014-05-28 23:01 ` pageio_init simplifications, V2 Trond Myklebust
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).