]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: fix the ASSERT() inside GET_SUBPAGE_BITMAP()
authorQu Wenruo <wqu@suse.com>
Tue, 1 Apr 2025 07:50:28 +0000 (18:20 +1030)
committerDavid Sterba <dsterba@suse.com>
Thu, 17 Apr 2025 09:55:56 +0000 (11:55 +0200)
After enabling large data folios for tests, I hit the ASSERT() inside
GET_SUBPAGE_BITMAP() where blocks_per_folio matches BITS_PER_LONG.

The ASSERT() itself is only based on the original subpage fs block size,
where we have at most 16 blocks per page, thus
"ASSERT(blocks_per_folio < BITS_PER_LONG)".

However the experimental large data folio support will set the max folio
order according to the BITS_PER_LONG, so we can have a case where a large
folio contains exactly BITS_PER_LONG blocks.

So the ASSERT() is too strict, change it to
"ASSERT(blocks_per_folio <= BITS_PER_LONG)" to avoid the false alert.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/subpage.c

index bd252c78a261d407d5957f9d7984e1dfc169b90f..c0a0b8b063d08598f8f36b58f8f8d5182f7b803f 100644 (file)
@@ -666,7 +666,7 @@ IMPLEMENT_BTRFS_PAGE_OPS(checked, folio_set_checked, folio_clear_checked,
                                btrfs_blocks_per_folio(fs_info, folio); \
        const struct btrfs_subpage *subpage = folio_get_private(folio); \
                                                                        \
-       ASSERT(blocks_per_folio < BITS_PER_LONG);                       \
+       ASSERT(blocks_per_folio <= BITS_PER_LONG);                      \
        *dst = bitmap_read(subpage->bitmaps,                            \
                           blocks_per_folio * btrfs_bitmap_nr_##name,   \
                           blocks_per_folio);                           \