Re: [PATCH 05/19] iomap: move the zeroing case out of iomap_read_page_sync

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

 



On Mon, Sep 09, 2019 at 08:27:08PM +0200, Christoph Hellwig wrote:
> That keeps the function a little easier to understand, and easier to
> modify for pending enhancements.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

--D

> ---
>  fs/iomap/buffered-io.c | 33 ++++++++++++++++-----------------
>  1 file changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 0b05551d9b5a..fe099faf540f 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -547,19 +547,12 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
>  }
>  
>  static int
> -iomap_read_page_sync(struct inode *inode, loff_t block_start, struct page *page,
> -		unsigned poff, unsigned plen, unsigned from, unsigned to,
> -		struct iomap *iomap)
> +iomap_read_page_sync(loff_t block_start, struct page *page, unsigned poff,
> +		unsigned plen, struct iomap *iomap)
>  {
>  	struct bio_vec bvec;
>  	struct bio bio;
>  
> -	if (iomap_block_needs_zeroing(inode, iomap, block_start)) {
> -		zero_user_segments(page, poff, from, to, poff + plen);
> -		iomap_set_range_uptodate(page, poff, plen);
> -		return 0;
> -	}
> -
>  	bio_init(&bio, &bvec, 1);
>  	bio.bi_opf = REQ_OP_READ;
>  	bio.bi_iter.bi_sector = iomap_sector(iomap, block_start);
> @@ -577,7 +570,7 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
>  	loff_t block_start = pos & ~(block_size - 1);
>  	loff_t block_end = (pos + len + block_size - 1) & ~(block_size - 1);
>  	unsigned from = offset_in_page(pos), to = from + len, poff, plen;
> -	int status = 0;
> +	int status;
>  
>  	if (PageUptodate(page))
>  		return 0;
> @@ -588,17 +581,23 @@ __iomap_write_begin(struct inode *inode, loff_t pos, unsigned len,
>  		if (plen == 0)
>  			break;
>  
> -		if ((from > poff && from < poff + plen) ||
> -		    (to > poff && to < poff + plen)) {
> -			status = iomap_read_page_sync(inode, block_start, page,
> -					poff, plen, from, to, iomap);
> -			if (status)
> -				break;
> +		if ((from <= poff || from >= poff + plen) &&
> +		    (to <= poff || to >= poff + plen))
> +			continue;
> +
> +		if (iomap_block_needs_zeroing(inode, iomap, block_start)) {
> +			zero_user_segments(page, poff, from, to, poff + plen);
> +			iomap_set_range_uptodate(page, poff, plen);
> +			continue;
>  		}
>  
> +		status = iomap_read_page_sync(block_start, page, poff, plen,
> +				iomap);
> +		if (status)
> +			return status;
>  	} while ((block_start += plen) < block_end);
>  
> -	return status;
> +	return 0;
>  }
>  
>  static int
> -- 
> 2.20.1
> 



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux