• Qu Wenruo's avatar
    btrfs: migrate eb_bitmap_offset() to folio interfaces · f4521b01
    Qu Wenruo authored
    [BUG]
    Test case btrfs/002 would fail if larger folios are enabled for
    metadata:
    
     assertion failed: folio, in fs/btrfs/extent_io.c:4358
     ------------[ cut here ]------------
     kernel BUG at fs/btrfs/extent_io.c:4358!
     invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
     CPU: 1 PID: 30916 Comm: fsstress Tainted: G           OE      6.7.0-rc3-custom+ #128
     Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 2/2/2022
     RIP: 0010:assert_eb_folio_uptodate+0x98/0xe0 [btrfs]
     Call Trace:
      <TASK>
      extent_buffer_test_bit+0x3c/0x70 [btrfs]
      free_space_test_bit+0xcd/0x140 [btrfs]
      modify_free_space_bitmap+0x27a/0x430 [btrfs]
      add_to_free_space_tree+0x8d/0x160 [btrfs]
      __btrfs_free_extent.isra.0+0xef1/0x13c0 [btrfs]
      __btrfs_run_delayed_refs+0x786/0x13c0 [btrfs]
      btrfs_run_delayed_refs+0x33/0x120 [btrfs]
      btrfs_commit_transaction+0xa2/0x1350 [btrfs]
      iterate_supers+0x77/0xe0
      ksys_sync+0x60/0xa0
      __do_sys_sync+0xa/0x20
      do_syscall_64+0x3f/0xf0
      entry_SYSCALL_64_after_hwframe+0x6e/0x76
      </TASK>
    
    [CAUSE]
    The function extent_buffer_test_bit() is not folio compatible.
    
    It still assumes the old fixed page size, when an extent buffer with
    large folio passed in, only eb->folios[0] is populated.
    
    Then if the target bit range falls in the 2nd page of the folio, then we
    would check eb->folios[1], and trigger the ASSERT().
    
    [FIX]
    Just migrate eb_bitmap_offset() to folio interfaces, using the
    folio_size() to replace PAGE_SIZE.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    f4521b01
extent_io.c 136 KB