Message ID | 9d2b4cb00e01eb1f42ebf0590d2367d9bd224b7a.1743493507.git.wqu@suse.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs: two small and safe fixes for large folios | expand |
On Tue, Apr 1, 2025 at 8:51 AM Qu Wenruo <wqu@suse.com> wrote: > > 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 to to change to to -> change it to > "ASSERT(blocks_per_folio <= BITS_PER_LONG)" to avoid the false alert. > > Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Thanks. > --- > fs/btrfs/subpage.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c > index 5fbdd977121e..d4f019233493 100644 > --- a/fs/btrfs/subpage.c > +++ b/fs/btrfs/subpage.c > @@ -664,7 +664,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); \ > -- > 2.49.0 > >
diff --git a/fs/btrfs/subpage.c b/fs/btrfs/subpage.c index 5fbdd977121e..d4f019233493 100644 --- a/fs/btrfs/subpage.c +++ b/fs/btrfs/subpage.c @@ -664,7 +664,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); \
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 to to "ASSERT(blocks_per_folio <= BITS_PER_LONG)" to avoid the false alert. Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/subpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)