linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: Peng Tao <bergwolf@gmail.com>
Cc: linux-nfs@vger.kernel.org, bhalevy@tonian.com,
	Peng Tao <peng_tao@emc.com>
Subject: Re: [PATCH 4/4] pnfsblock: do ask for layout in pg_init
Date: Tue, 29 Nov 2011 11:40:23 -0500	[thread overview]
Message-ID: <1322584823.4174.15.camel@lade.trondhjem.org> (raw)
In-Reply-To: <1322887965-2938-5-git-send-email-bergwolf@gmail.com>

On Fri, 2011-12-02 at 20:52 -0800, Peng Tao wrote: 
> Asking for layout in pg_init will always make client ask for only 4KB
> layout in every layoutget. This way, client drops the IO size information
> that is meaningful for MDS in handing out layout.
> 
> In stead, if layout is not find in cache, do not send layoutget
> at once. Wait until before issuing IO in pnfs_do_multiple_reads/writes
> because that is where we know the real size of current IO. By telling the
> real IO size to MDS, MDS will have a better chance to give proper layout.

Why can't you just split pnfs_update_layout() into 2 sub-functions
instead of duplicating it in private block code?

Then call layoutget in your pg_doio() callback instead of adding a
redundant pnfs_update_layout to
pnfs_do_multiple_reads/pnfs_do_multiple_writes...


> Signed-off-by: Peng Tao <peng_tao@emc.com>
> ---
>  fs/nfs/blocklayout/blocklayout.c |   54 ++++++++++++++++++++++++++++++++++++-
>  1 files changed, 52 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
> index 48cfac3..fd585fe 100644
> --- a/fs/nfs/blocklayout/blocklayout.c
> +++ b/fs/nfs/blocklayout/blocklayout.c
> @@ -39,6 +39,7 @@
>  #include <linux/prefetch.h>
>  
>  #include "blocklayout.h"
> +#include "../internal.h"
>  
>  #define NFSDBG_FACILITY	NFSDBG_PNFS_LD
>  
> @@ -990,14 +991,63 @@ bl_clear_layoutdriver(struct nfs_server *server)
>  	return 0;
>  }
>  
> +/* While RFC doesn't limit maximum size of layout, we better limit it ourself. */
> +#define PNFSBLK_MAXRSIZE (0x1<<22)
> +#define PNFSBLK_MAXWSIZE (0x1<<21)
> +static void
> +bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
> +{
> +	struct inode *ino = pgio->pg_inode;
> +	struct pnfs_layout_hdr *lo;
> +
> +	BUG_ON(pgio->pg_lseg != NULL);
> +	spin_lock(&ino->i_lock);
> +	lo = pnfs_find_alloc_layout(ino, req->wb_context, GFP_KERNEL);

This has never been tested... It contains all sorts of bugs from
recursive attempts to take the ino->i_lock, to sleep-under-spinlock...

> +	if (!lo || test_bit(lo_fail_bit(IOMODE_READ), &lo->plh_flags)) {
> +		spin_unlock(&ino->i_lock);
> +		nfs_pageio_reset_read_mds(pgio);
> +		return;
> +	}
> +
> +	pgio->pg_bsize = PNFSBLK_MAXRSIZE;
> +	pgio->pg_lseg = pnfs_find_get_layout_locked(ino,
> +						req_offset(req),
> +						req->wb_bytes,
> +						IOMODE_READ);
> +	spin_unlock(&ino->i_lock);
> +}
> +
> +static void
> +bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
> +{
> +	struct inode *ino = pgio->pg_inode;
> +	struct pnfs_layout_hdr *lo;
> +
> +	BUG_ON(pgio->pg_lseg != NULL);
> +	spin_lock(&ino->i_lock);
> +	lo = pnfs_find_alloc_layout(ino, req->wb_context, GFP_NOFS);
> +	if (!lo || test_bit(lo_fail_bit(IOMODE_RW), &lo->plh_flags)) {
> +		spin_unlock(&ino->i_lock);
> +		nfs_pageio_reset_write_mds(pgio);
> +		return;
> +	}

Ditto...

> +
> +	pgio->pg_bsize = PNFSBLK_MAXWSIZE;
> +	pgio->pg_lseg = pnfs_find_get_layout_locked(ino,
> +						req_offset(req),
> +						req->wb_bytes,
> +						IOMODE_RW);
> +	spin_unlock(&ino->i_lock);
> +}
> +
>  static const struct nfs_pageio_ops bl_pg_read_ops = {
> -	.pg_init = pnfs_generic_pg_init_read,
> +	.pg_init = bl_pg_init_read,
>  	.pg_test = pnfs_generic_pg_test,
>  	.pg_doio = pnfs_generic_pg_readpages,
>  };
>  
>  static const struct nfs_pageio_ops bl_pg_write_ops = {
> -	.pg_init = pnfs_generic_pg_init_write,
> +	.pg_init = bl_pg_init_write,
>  	.pg_test = pnfs_generic_pg_test,
>  	.pg_doio = pnfs_generic_pg_writepages,
>  };

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@netapp.com
www.netapp.com


  reply	other threads:[~2011-11-29 16:40 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-03  4:52 [PATCH 0/4] nfs41: allow layoutget at pnfs_do_multiple_writes Peng Tao
2011-11-29 21:34 ` Boaz Harrosh
2011-11-29 21:50   ` Boaz Harrosh
2011-11-29 21:57     ` Trond Myklebust
2011-11-29 22:40       ` Boaz Harrosh
2011-11-29 22:47         ` Trond Myklebust
2011-11-29 22:58           ` Boaz Harrosh
2011-11-29 23:30             ` Trond Myklebust
2011-11-29 23:49               ` Marc Eshel
2011-11-30  0:08                 ` Trond Myklebust
2011-11-30  0:20                   ` Marc Eshel
2011-11-30  0:37                     ` Trond Myklebust
2011-11-30  0:50                       ` Boaz Harrosh
2011-11-30 19:39                         ` J. Bruce Fields
2011-11-30  0:52                       ` Marc Eshel
2011-11-30 19:44                         ` J. Bruce Fields
2011-12-01  9:47                           ` Benny Halevy
2011-12-01 11:14                             ` J. Bruce Fields
2011-12-01 11:48                               ` J. Bruce Fields
2011-11-30  0:42                   ` Boaz Harrosh
2011-11-30  0:24               ` Boaz Harrosh
2011-11-30  0:58                 ` Trond Myklebust
2011-11-30  1:46                   ` Boaz Harrosh
2011-11-30  2:07                     ` Trond Myklebust
2011-11-30  3:08                       ` Boaz Harrosh
2011-11-30 12:33                   ` Benny Halevy
2011-11-30  0:37           ` Matt W. Benjamin
2011-11-30  0:48             ` Matt W. Benjamin
2011-11-30  1:01               ` Trond Myklebust
2011-11-30  1:03                 ` Matt W. Benjamin
2011-11-29 23:01         ` Trond Myklebust
2011-11-29 23:47           ` Boaz Harrosh
2011-11-30  3:16   ` tao.peng
2011-11-30  3:50     ` Boaz Harrosh
2011-11-30  5:05       ` tao.peng
2011-11-30 12:42         ` Benny Halevy
2011-12-03  4:52 ` [PATCH 1/4] nfsv41: export pnfs_find_alloc_layout Peng Tao
2011-12-03  4:52 ` [PATCH 2/4] nfsv41: add and export pnfs_find_get_layout_locked Peng Tao
2011-12-03  4:52 ` [PATCH 3/4] nfsv41: get lseg before issue LD IO if pgio doesn't carry lseg Peng Tao
2011-11-30 13:01   ` Benny Halevy
2011-11-30 13:20     ` Peng Tao
2011-12-03  4:52 ` [PATCH 4/4] pnfsblock: do ask for layout in pg_init Peng Tao
2011-11-29 16:40   ` Trond Myklebust [this message]
2011-11-29 17:25     ` Peng Tao
2011-11-29 17:43       ` Trond Myklebust
2011-11-30  2:55         ` tao.peng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322584823.4174.15.camel@lade.trondhjem.org \
    --to=trond.myklebust@netapp.com \
    --cc=bergwolf@gmail.com \
    --cc=bhalevy@tonian.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=peng_tao@emc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).