All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 6/5 V2] iomap: readpages doesn't zero page tail beyond EOF properly
Date: Wed, 21 Nov 2018 08:34:22 -0800	[thread overview]
Message-ID: <20181121163422.GB27540@infradead.org> (raw)
In-Reply-To: <20181121082736.GT19305@dastard>

On Wed, Nov 21, 2018 at 07:27:36PM +1100, Dave Chinner wrote:
> index d51e7a2ae641..b95110867eee 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -142,13 +142,14 @@ static void
>  iomap_adjust_read_range(struct inode *inode, struct iomap_page *iop,
>  		loff_t *pos, loff_t length, unsigned *offp, unsigned *lenp)
>  {
> +	loff_t orig_pos = *pos;
> +	loff_t isize = i_size_read(inode);
>  	unsigned block_bits = inode->i_blkbits;
>  	unsigned block_size = (1 << block_bits);
>  	unsigned poff = offset_in_page(*pos);
>  	unsigned plen = min_t(loff_t, PAGE_SIZE - poff, length);
>  	unsigned first = poff >> block_bits;
>  	unsigned last = (poff + plen - 1) >> block_bits;
> -	unsigned end = offset_in_page(i_size_read(inode)) >> block_bits;
>  
>  	/*
>  	 * If the block size is smaller than the page size we need to check the
> @@ -183,8 +184,11 @@ iomap_adjust_read_range(struct inode *inode, struct iomap_page *iop,
>  	 * handle both halves separately so that we properly zero data in the
>  	 * page cache for blocks that are entirely outside of i_size.
>  	 */
> -	if (first <= end && last > end)
> -		plen -= (last - end) * block_size;
> +	if (orig_pos <= isize && orig_pos + length > isize) {
> +		unsigned end = offset_in_page(isize - 1) >> block_bits;
> +		if (first <= end && last > end)
> +			plen -= (last - end) * block_size;

Please add an empty line afte the variable declaration.

Otherwise this looks good to me:

Reviewed-by: Christoph Hellwig <hch@lst.de>

      parent reply	other threads:[~2018-11-22  3:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-19 21:17 [PATCH 0/5] iomap: data corruption fixes and more Dave Chinner
2018-11-19 21:17 ` [PATCH 1/5] iomap: FUA is wrong for DIO O_DSYNC writes into unwritten extents Dave Chinner
2018-11-20  7:48   ` Christoph Hellwig
2018-11-20 23:00   ` Darrick J. Wong
2018-11-19 21:17 ` [PATCH 2/5] iomap: sub-block dio needs to zeroout beyond EOF Dave Chinner
2018-11-20 23:01   ` Darrick J. Wong
2018-11-19 21:17 ` [PATCH 3/5] iomap: dio data corruption and spurious errors when pipes fill Dave Chinner
2018-11-19 21:17 ` [PATCH 4/5] splice: increase pipe size in splice_direct_to_actor() Dave Chinner
2018-11-20  7:49   ` Christoph Hellwig
2018-11-20 23:02   ` Darrick J. Wong
2018-11-19 21:17 ` [PATCH 5/5] vfs: vfs_dedupe_file_range() doesn't return EOPNOTSUPP Dave Chinner
2018-11-20  7:49   ` Christoph Hellwig
2018-11-21  6:50 ` [PATCH 6/5] iomap: readpages doesn't zero page tail beyond EOF properly Dave Chinner
2018-11-21  8:27   ` [PATCH 6/5 V2] " Dave Chinner
2018-11-21 16:20     ` Darrick J. Wong
2018-11-21 16:34     ` Christoph Hellwig [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=20181121163422.GB27540@infradead.org \
    --to=hch@infradead.org \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@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.