]> git.hungrycats.org Git - linux/commit
btrfs: simplify heuristic_collect_sample() to handle large folios better
authorQu Wenruo <wqu@suse.com>
Thu, 10 Sep 2026 02:05:53 +0000 (11:35 +0930)
committerDavid Sterba <dsterba@suse.com>
Wed, 16 Sep 2026 13:29:26 +0000 (15:29 +0200)
commite894e7cf00f7cf62252645bb907d5172cca8fede
treefe41e1f8948b239fa7a59c9d3460a345344c5848
parent9dc38f249a02e99124058caf6d4926fa0e0032fe
btrfs: simplify heuristic_collect_sample() to handle large folios better

Currently heuristic_collect_sample() is purely page size based, and it
has a lot of extra handling just inside the page.

However we already have large folio support, there is no need to look up
the same folio repeatedly.

Simplify the handling by:

- Use @cur as the iterator instead of page index

- Handle the sample copying on a per-folio basis
  Although kmap_local_folio() requires an offset to handle HIGHMEM
  page mapping, we have rejected large folios for HIGHMEM systems
  completely.

  So we can safely handle all sample copying inside the folio in one
  go.

- Remove unnecessary unaligned range handling
  All the range passed in should be block aligned, thus there is no need
  to handle cases where sample crosses the block boundary.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c