From: Jan Kara <jack@suse.cz>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>
Cc: linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
Matthew Wilcox <willy@infradead.org>,
"Darrick J . Wong" <djwong@kernel.org>,
Ojaswin Mujoo <ojaswin@linux.ibm.com>, Jan Kara <jack@suse.cz>,
Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCHv2 1/2] iomap: Fix iomap_adjust_read_range for plen calculation
Date: Thu, 9 May 2024 12:33:01 +0200 [thread overview]
Message-ID: <20240509103301.6rievb5fx32iqcxk@quack3> (raw)
In-Reply-To: <a32e5f9a4fcfdb99077300c4020ed7ae61d6e0f9.1715067055.git.ritesh.list@gmail.com>
On Tue 07-05-24 14:25:42, Ritesh Harjani (IBM) wrote:
> If the extent spans the block that contains i_size, we need to handle
> both halves separately so that we properly zero data in the page cache
> for blocks that are entirely outside of i_size. But this is needed only
> when i_size is within the current folio under processing.
> "orig_pos + length > isize" can be true for all folios if the mapped
> extent length is greater than the folio size. That is making plen to
> break for every folio instead of only the last folio.
>
> So use orig_plen for checking if "orig_pos + orig_plen > isize".
>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> cc: Ojaswin Mujoo <ojaswin@linux.ibm.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/iomap/buffered-io.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 4e8e41c8b3c0..9f79c82d1f73 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -241,6 +241,7 @@ static void iomap_adjust_read_range(struct inode *inode, struct folio *folio,
> unsigned block_size = (1 << block_bits);
> size_t poff = offset_in_folio(folio, *pos);
> size_t plen = min_t(loff_t, folio_size(folio) - poff, length);
> + size_t orig_plen = plen;
> unsigned first = poff >> block_bits;
> unsigned last = (poff + plen - 1) >> block_bits;
>
> @@ -277,7 +278,7 @@ static void iomap_adjust_read_range(struct inode *inode, struct folio *folio,
> * handle both halves separately so that we properly zero data in the
> * page cache for blocks that are entirely outside of i_size.
> */
> - if (orig_pos <= isize && orig_pos + length > isize) {
> + if (orig_pos <= isize && orig_pos + orig_plen > isize) {
> unsigned end = offset_in_folio(folio, isize - 1) >> block_bits;
>
> if (first <= end && last > end)
> --
> 2.44.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2024-05-09 10:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 8:55 [PATCHv2 0/2] iomap: Optimize read_folio Ritesh Harjani (IBM)
2024-05-07 8:55 ` [PATCHv2 1/2] iomap: Fix iomap_adjust_read_range for plen calculation Ritesh Harjani (IBM)
2024-05-09 10:33 ` Jan Kara [this message]
2024-06-05 15:29 ` (subset) " Christian Brauner
2024-05-07 8:55 ` [PATCHv2 2/2] iomap: Optimize iomap_read_folio Ritesh Harjani (IBM)
2024-05-07 21:11 ` Darrick J. Wong
2024-05-09 4:55 ` Christoph Hellwig
2024-05-09 10:40 ` Jan Kara
2024-06-05 15:29 ` (subset) " Christian Brauner
2024-06-04 0:32 ` [PATCHv2 0/2] iomap: Optimize read_folio Ritesh Harjani
2024-06-04 4:11 ` Christoph Hellwig
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=20240509103301.6rievb5fx32iqcxk@quack3 \
--to=jack@suse.cz \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).