Re: [PATCH 1/3] NFS41: add pnfs_dio_begin/dio_end

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2012-05-27 at 13:32 +0800, Peng Tao wrote:
> To allow layout driver specific preparation for DIO.
> 
> Signed-off-by: Peng Tao <tao.peng@xxxxxxx>
> ---
>  fs/nfs/direct.c |   43 +++++++++++++++++++++++++++++++++++++++----
>  fs/nfs/pnfs.h   |   38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 77 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
> index ad2775d..8e9c8e1 100644
> --- a/fs/nfs/direct.c
> +++ b/fs/nfs/direct.c
> @@ -383,6 +383,37 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_pageio_descriptor *de
>  	return result < 0 ? (ssize_t) result : -EFAULT;
>  }
>  
> +static void nfs_direct_read_init(struct nfs_pageio_descriptor *pgio,
> +				 struct inode *inode, const struct iovec *iov,
> +				 unsigned long nr_segs, loff_t pos,
> +				 struct blk_plug *plug)
> +{
> +	if (pnfs_dio_begin(inode, iov, nr_segs, pos, plug))
> +		pnfs_pageio_init_read(pgio, inode,
> +				      &nfs_direct_read_completion_ops);
> +	else
> +		nfs_pageio_init_read_mds(pgio, inode,
> +					 &nfs_direct_read_completion_ops);
> +}
> +
> +static void nfs_direct_write_init(struct nfs_pageio_descriptor *pgio,
> +				  struct inode *inode, const struct iovec *iov,
> +				  unsigned long nr_segs, loff_t pos,
> +				  struct blk_plug *plug)
> +{
> +	if (pnfs_dio_begin(inode, iov, nr_segs, pos, plug))
> +		pnfs_pageio_init_write(pgio, inode, FLUSH_COND_STABLE,
> +				       &nfs_direct_write_completion_ops);
> +	else
> +		nfs_pageio_init_write_mds(pgio, inode, FLUSH_COND_STABLE,
> +					  &nfs_direct_write_completion_ops);
> +}
> +
> +static void nfs_dio_end(struct inode *inode, struct blk_plug *plug)
> +{
> +	pnfs_dio_end(inode, plug);
> +}
> +
>  static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
>  					      const struct iovec *iov,
>  					      unsigned long nr_segs,
> @@ -392,9 +423,10 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
>  	ssize_t result = -EINVAL;
>  	size_t requested_bytes = 0;
>  	unsigned long seg;
> +	struct blk_plug plug;
> +
> +	nfs_direct_read_init(&desc, dreq->inode, iov, nr_segs, pos, &plug);
>  
> -	nfs_pageio_init_read(&desc, dreq->inode,
> -			     &nfs_direct_read_completion_ops);
>  	get_dreq(dreq);
>  	desc.pg_dreq = dreq;
>  
> @@ -410,6 +442,7 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
>  	}
>  
>  	nfs_pageio_complete(&desc);
> +	nfs_dio_end(dreq->inode, &plug);

Why can't you just put this in pg_init/pg_doio? There is already a flag
in the nfs_pageio_descriptor that tells you if more i/o is due (see
pg_moreio).
There should be no need to add extra callbacks in the generic code for
any of this.

-- 
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�����٥



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux