diff mbox series

btrfs: fix the uptodate assert in btree_csum_one_bio

Message ID 20230526090109.1982022-1-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series btrfs: fix the uptodate assert in btree_csum_one_bio | expand

Commit Message

Christoph Hellwig May 26, 2023, 9:01 a.m. UTC
btree_csum_one_bio needs to use the btrfs_page_test_uptodate helper
to check for uptodate status as the page might not be marked uptodate
for a sub-page size buffer.

Fixes: 5067444c99c3 ("btrfs: remove the extent_buffer lookup in btree block checksumming")
Reported-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
---
 fs/btrfs/disk-io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Qu Wenruo May 26, 2023, 9:05 a.m. UTC | #1
On 2023/5/26 17:01, Christoph Hellwig wrote:
> btree_csum_one_bio needs to use the btrfs_page_test_uptodate helper
> to check for uptodate status as the page might not be marked uptodate
> for a sub-page size buffer.
>
> Fixes: 5067444c99c3 ("btrfs: remove the extent_buffer lookup in btree block checksumming")
> Reported-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Tested-by: Qu Wenruo <quwenruo.btrfs@gmx.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   fs/btrfs/disk-io.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index c461a46ac6f207..36d6b8d4b2c1fa 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -269,7 +269,8 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)
>
>   	if (WARN_ON_ONCE(found_start != eb->start))
>   		return BLK_STS_IOERR;
> -	if (WARN_ON_ONCE(!PageUptodate(eb->pages[0])))
> +	if (WARN_ON(!btrfs_page_test_uptodate(fs_info, eb->pages[0],
> +					      eb->start, eb->len)))
>   		return BLK_STS_IOERR;
>
>   	ASSERT(memcmp_extent_buffer(eb, fs_info->fs_devices->metadata_uuid,
David Sterba May 26, 2023, 2:03 p.m. UTC | #2
On Fri, May 26, 2023 at 11:01:09AM +0200, Christoph Hellwig wrote:
> btree_csum_one_bio needs to use the btrfs_page_test_uptodate helper
> to check for uptodate status as the page might not be marked uptodate
> for a sub-page size buffer.
> 
> Fixes: 5067444c99c3 ("btrfs: remove the extent_buffer lookup in btree block checksumming")

Folded to the patch, thanks.

> Reported-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Tested-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
diff mbox series

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c461a46ac6f207..36d6b8d4b2c1fa 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -269,7 +269,8 @@  blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)
 
 	if (WARN_ON_ONCE(found_start != eb->start))
 		return BLK_STS_IOERR;
-	if (WARN_ON_ONCE(!PageUptodate(eb->pages[0])))
+	if (WARN_ON(!btrfs_page_test_uptodate(fs_info, eb->pages[0],
+					      eb->start, eb->len)))
 		return BLK_STS_IOERR;
 
 	ASSERT(memcmp_extent_buffer(eb, fs_info->fs_devices->metadata_uuid,