On Tue, 2012-05-29 at 12:38 +0800, Peng Tao wrote: > NFS DIO bypasses generic DIO code path. So we need to plug/unplug > on our own. > > Signed-off-by: Peng Tao <tao.peng@xxxxxxx> > --- > fs/nfs/blocklayout/blocklayout.c | 47 +++++++++++++++++++++++++++++++++++++- > 1 files changed, 46 insertions(+), 1 deletions(-) > > diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c > index bab432f..b48b08b 100644 > --- a/fs/nfs/blocklayout/blocklayout.c > +++ b/fs/nfs/blocklayout/blocklayout.c > @@ -251,6 +251,7 @@ bl_read_pagelist(struct nfs_read_data *rdata) > > dprintk("%s enter nr_pages %u offset %lld count %u\n", __func__, > rdata->pages.npages, f_offset, (unsigned int)rdata->args.count); > + BUG_ON(header->dreq && header->layout_private == NULL); > > if (!bl_check_alignment(f_offset, rdata->args.count, PAGE_CACHE_MASK)) > goto use_mds; > @@ -320,9 +321,17 @@ out: > bl_put_extent(cow_read); > bl_submit_bio(READ, bio); > put_parallel(par); > + if (header->dreq && !header->moreio) { > + blk_finish_plug((struct blk_plug *)header->layout_private); > + kfree(header->layout_private); Wait... Why can't this just go in the block-specific ->pg_doio() callback? Why does it need to go to your read_pagelist()/write_pagelist()? > + } > return PNFS_ATTEMPTED; > > - use_mds: > +use_mds: > + if (header->dreq) { > + blk_finish_plug((struct blk_plug *)header->layout_private); > + kfree(header->layout_private); > + } > dprintk("Giving up and using normal NFS\n"); > return PNFS_NOT_ATTEMPTED; > } > @@ -575,6 +584,8 @@ bl_write_pagelist(struct nfs_write_data *wdata, int sync) > unsigned long blkmask = PAGE_CACHE_MASK; > > dprintk("%s enter, %Zu@%lld\n", __func__, count, offset); > + BUG_ON(header->dreq && header->layout_private == NULL); > + > /* Check for alignment first */ > if (header->dreq) > blkmask = NFS_SERVER(header->inode)->pnfs_blksize - 1; > @@ -740,8 +751,16 @@ out: > bl_put_extent(be); > bl_submit_bio(WRITE, bio); > put_parallel(par); > + if (header->dreq && !header->moreio) { > + blk_finish_plug((struct blk_plug *)header->layout_private); > + kfree(header->layout_private); > + } > return PNFS_ATTEMPTED; > out_mds: > + if (header->dreq) { > + blk_finish_plug((struct blk_plug *)header->layout_private); > + kfree(header->layout_private); > + } > bl_put_extent(be); > kfree(par); > return PNFS_NOT_ATTEMPTED; > @@ -1017,15 +1036,30 @@ bl_clear_layoutdriver(struct nfs_server *server) > static void > bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) > { > + BUG_ON(pgio->pg_layout_private != NULL); > + > if (!bl_check_alignment(req->wb_offset, req->wb_bytes, PAGE_CACHE_MASK)) > nfs_pageio_reset_read_mds(pgio); > else > pnfs_generic_pg_init_read(pgio, req); > + > + if (pgio->pg_dreq && pgio->pg_lseg) { > + struct blk_plug *plug; > + /* Freed in bl_read_pagelist */ > + plug = kmalloc(sizeof(struct blk_plug), GFP_KERNEL); > + if (plug != NULL) { > + blk_start_plug(plug); > + pgio->pg_layout_private = plug; > + } else > + nfs_pageio_reset_read_mds(pgio); > + } > } > > static void > bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) > { > + BUG_ON(pgio->pg_layout_private != NULL); > + > if (pgio->pg_dreq) { > /* Direct write should be blksize aligned */ > unsigned blkmask = NFS_SERVER(pgio->pg_inode)->pnfs_blksize - 1; > @@ -1038,6 +1072,17 @@ bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) > nfs_pageio_reset_write_mds(pgio); > else > pnfs_generic_pg_init_write(pgio, req); > + > + if (pgio->pg_dreq && pgio->pg_lseg) { > + struct blk_plug *plug; > + /* Freed in bl_write_pagelist */ > + plug = kmalloc(sizeof(struct blk_plug), GFP_NOFS); > + if (plug != NULL) { > + blk_start_plug(plug); > + pgio->pg_layout_private = plug; > + } else > + nfs_pageio_reset_write_mds(pgio); > + } > } > > static const struct nfs_pageio_ops bl_pg_read_ops = { -- Trond Myklebust Linux NFS client maintainer NetApp Trond.Myklebust@xxxxxxxxxx www.netapp.com ��.n��������+%������w��{.n�����{��w���jg��������ݢj����G�������j:+v���w�m������w�������h�����٥