All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benny Halevy <bhalevy@tonian.com>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 5/8] NFS: Allow the nfs_pageio_descriptor to signal that a re-coalesce is needed
Date: Wed, 13 Jul 2011 16:22:02 +0300	[thread overview]
Message-ID: <4E1D9BFA.1050000@tonian.com> (raw)
In-Reply-To: <1310498994-12685-6-git-send-email-Trond.Myklebust@netapp.com>

On 2011-07-12 22:29, Trond Myklebust wrote:
> If an attempt to do pNFS fails, and we have to fall back to writing through
> the MDS, then we may want to re-coalesce the requests that we already have
> since the block size for the MDS read/writes may be different to that of
> the DS read/writes.
> 
> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
>  fs/nfs/pagelist.c        |   57 +++++++++++++++++++++++++++++++++++++++++++--
>  include/linux/nfs_page.h |    3 +-
>  2 files changed, 56 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
> index d421e19..7139dbf 100644
> --- a/fs/nfs/pagelist.c
> +++ b/fs/nfs/pagelist.c
> @@ -240,6 +240,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
>  	desc->pg_bsize = bsize;
>  	desc->pg_base = 0;
>  	desc->pg_moreio = 0;
> +	desc->pg_recoalesce = 0;
>  	desc->pg_inode = inode;
>  	desc->pg_ops = pg_ops;
>  	desc->pg_ioflags = io_flags;
> @@ -331,7 +332,7 @@ static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
>   * Returns true if the request 'req' was successfully coalesced into the
>   * existing list of pages 'desc'.
>   */
> -int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
> +static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
>  			   struct nfs_page *req)
>  {
>  	while (!nfs_pageio_do_add_request(desc, req)) {
> @@ -340,17 +341,67 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
>  		if (desc->pg_error < 0)
>  			return 0;
>  		desc->pg_moreio = 0;
> +		if (desc->pg_recoalesce)
> +			return 0;
>  	}
>  	return 1;
>  }
>  
> +static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
> +{
> +	LIST_HEAD(head);
> +
> +	do {
> +		list_splice_init(&desc->pg_list, &head);
> +		desc->pg_bytes_written -= desc->pg_count;
> +		desc->pg_count = 0;
> +		desc->pg_base = 0;
> +		desc->pg_recoalesce = 0;
> +
> +		while (!list_empty(&head)) {
> +			struct nfs_page *req;
> +
> +			req = list_first_entry(&head, struct nfs_page, wb_list);
> +			nfs_list_remove_request(req);
> +			if (__nfs_pageio_add_request(desc, req))
> +				continue;
> +			if (desc->pg_error < 0)
> +				return 0;
> +			break;
> +		}
> +	} while (desc->pg_recoalesce);
> +	return 1;
> +}
> +
> +int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
> +		struct nfs_page *req)
> +{
> +	int ret;
> +
> +	do {
> +		ret = __nfs_pageio_add_request(desc, req);
> +		if (ret)
> +			break;
> +		if (desc->pg_error < 0)
> +			break;
> +		ret = nfs_do_recoalesce(desc);
> +	} while (ret);
> +	return ret;
> +}
> +
>  /**
>   * nfs_pageio_complete - Complete I/O on an nfs_pageio_descriptor
>   * @desc: pointer to io descriptor
>   */
>  void nfs_pageio_complete(struct nfs_pageio_descriptor *desc)
>  {
> -	nfs_pageio_doio(desc);
> +	for (;;) {
> +		nfs_pageio_doio(desc);
> +		if (!desc->pg_recoalesce)
> +			break;
> +		if (!nfs_do_recoalesce(desc))
> +			break;
> +	}

nit: how about the following?

	do
		nfs_pageio_doio(desc);
	while (desc->pg_recoalesce && nfs_do_recoalesce(desc));

Benny

>  }
>  
>  /**
> @@ -369,7 +420,7 @@ void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index)
>  	if (!list_empty(&desc->pg_list)) {
>  		struct nfs_page *prev = nfs_list_entry(desc->pg_list.prev);
>  		if (index != prev->wb_index + 1)
> -			nfs_pageio_doio(desc);
> +			nfs_pageio_complete(desc);
>  	}
>  }
>  
> diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h
> index db3194f..7241b2a 100644
> --- a/include/linux/nfs_page.h
> +++ b/include/linux/nfs_page.h
> @@ -68,7 +68,8 @@ struct nfs_pageio_descriptor {
>  	size_t			pg_count;
>  	size_t			pg_bsize;
>  	unsigned int		pg_base;
> -	char			pg_moreio;
> +	unsigned char		pg_moreio : 1,
> +				pg_recoalesce : 1;
>  
>  	struct inode		*pg_inode;
>  	const struct nfs_pageio_ops *pg_ops;

      parent reply	other threads:[~2011-07-13 13:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-12 19:29 [PATCH 0/8] pNFS read/write cleanup Trond Myklebust
2011-07-12 19:29 ` [PATCH 1/8] NFS: Clean up nfs_read_rpcsetup and nfs_write_rpcsetup Trond Myklebust
2011-07-12 19:29   ` [PATCH 2/8] NFS: Clean up: split out the RPC transmission from nfs_pagein_multi/one Trond Myklebust
2011-07-12 19:29     ` [PATCH 3/8] NFS: Cache rpc_ops in struct nfs_pageio_descriptor Trond Myklebust
2011-07-12 19:29       ` [PATCH 4/8] NFS: Use the nfs_pageio_descriptor->pg_bsize in the read/write request Trond Myklebust
2011-07-12 19:29         ` [PATCH 5/8] NFS: Allow the nfs_pageio_descriptor to signal that a re-coalesce is needed Trond Myklebust
2011-07-12 19:29           ` [PATCH 6/8] NFS: Move the pnfs read code into pnfs.c Trond Myklebust
2011-07-12 19:29             ` [PATCH 7/8] NFS: Move the pnfs write " Trond Myklebust
2011-07-12 19:29               ` [PATCH 8/8] NFS: Clean up - simplify the switch to read/write-through-MDS Trond Myklebust
2011-07-13 13:40             ` [PATCH 6/8] NFS: Move the pnfs read code into pnfs.c Benny Halevy
2011-07-13 14:08               ` Myklebust, Trond
2011-07-13 13:22           ` Benny Halevy [this message]

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=4E1D9BFA.1050000@tonian.com \
    --to=bhalevy@tonian.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.