]> git.hungrycats.org Git - linux/commitdiff
btrfs: tests: use eb folio helpers in extent buffer memory checks
authorTal Zussman <tz2294@columbia.edu>
Mon, 7 Sep 2026 20:19:57 +0000 (16:19 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 14 Sep 2026 11:23:37 +0000 (13:23 +0200)
dump_eb_and_memory_contents() and verify_eb_and_memory() hardcode one
page per folio instead of using get_eb_folio_index() and
get_eb_offset_in_folio() like the rest of the extent buffer code. Use
the helpers and folio_address(). This removes the last struct page usage
in the file.

No functional change. The tests only run with sectorsize == PAGE_SIZE,
and the test extent buffers are backed by order-0 folios.

Assisted-by: Claude:claude-fable-5-1
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/tests/extent-io-tests.c

index ee8eabac47f110793aaf4941412add4076306033..cd045778400dc01b0f48da953239e31f6e1f1dde 100644 (file)
@@ -672,8 +672,9 @@ static void dump_eb_and_memory_contents(struct extent_buffer *eb, void *memory,
                                        const char *test_name)
 {
        for (int i = 0; i < eb->len; i++) {
-               struct page *page = folio_page(eb->folios[i >> PAGE_SHIFT], 0);
-               void *addr = page_address(page) + offset_in_page(i);
+               const unsigned long idx = get_eb_folio_index(eb, i);
+               void *addr = folio_address(eb->folios[idx]) +
+                            get_eb_offset_in_folio(eb, i);
 
                if (memcmp(addr, memory + i, 1) != 0) {
                        test_err("%s failed", test_name);
@@ -688,9 +689,12 @@ static int verify_eb_and_memory(struct extent_buffer *eb, void *memory,
                                const char *test_name)
 {
        for (int i = 0; i < (eb->len >> PAGE_SHIFT); i++) {
-               void *eb_addr = folio_address(eb->folios[i]);
+               const unsigned long offset = i << PAGE_SHIFT;
+               const unsigned long idx = get_eb_folio_index(eb, offset);
+               void *eb_addr = folio_address(eb->folios[idx]) +
+                               get_eb_offset_in_folio(eb, offset);
 
-               if (memcmp(memory + (i << PAGE_SHIFT), eb_addr, PAGE_SIZE) != 0) {
+               if (memcmp(memory + offset, eb_addr, PAGE_SIZE) != 0) {
                        dump_eb_and_memory_contents(eb, memory, test_name);
                        return -EUCLEAN;
                }