Re: [PATCH-v2 1/3] pnfsblock: bail out partial block direct write

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

 



On Tue, 2012-05-29 at 12:38 +0800, Peng Tao wrote:
> Signed-off-by: Peng Tao <tao.peng@xxxxxxx>
> ---
>  fs/nfs/blocklayout/blocklayout.c |   15 +++++++++++++--
>  1 files changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
> index dd392ed..bab432f 100644
> --- a/fs/nfs/blocklayout/blocklayout.c
> +++ b/fs/nfs/blocklayout/blocklayout.c
> @@ -572,10 +572,13 @@ bl_write_pagelist(struct nfs_write_data *wdata, int sync)
>  	u64 temp;
>  	int npg_per_block =
>  	    NFS_SERVER(header->inode)->pnfs_blksize >> PAGE_CACHE_SHIFT;
> +	unsigned long blkmask = PAGE_CACHE_MASK;
>  
>  	dprintk("%s enter, %Zu@%lld\n", __func__, count, offset);
>  	/* Check for alignment first */
> -	if (!bl_check_alignment(offset, count, PAGE_CACHE_MASK))
> +	if (header->dreq)
> +		blkmask = NFS_SERVER(header->inode)->pnfs_blksize - 1;
> +	if (!bl_check_alignment(offset, count, blkmask))
>  		goto out_mds;
>  
>  	/* At this point, wdata->pages is a (sequential) list of nfs_pages.
> @@ -1023,7 +1026,15 @@ bl_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
>  static void
>  bl_pg_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
>  {
> -	if (!bl_check_alignment(req->wb_offset, req->wb_bytes, PAGE_CACHE_MASK))
> +	if (pgio->pg_dreq) {
> +		/* Direct write should be blksize aligned */
> +		unsigned blkmask = NFS_SERVER(pgio->pg_inode)->pnfs_blksize - 1;
> +		u64 pos = (req->wb_index << PAGE_CACHE_SHIFT) + req->wb_bytes;

Please use the req_offset() helper for this calculation: the line above
fails to cast req->wb_index correctly.

> +		if (!bl_check_alignment(pos, 0, blkmask) ||
> +		    req->wb_bytes != PAGE_CACHE_SIZE)
> +			nfs_pageio_reset_write_mds(pgio);
> +	} else if (!bl_check_alignment(req->wb_offset, req->wb_bytes,
> +				       PAGE_CACHE_MASK))
>  		nfs_pageio_reset_write_mds(pgio);
>  	else
>  		pnfs_generic_pg_init_write(pgio, req);

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