]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: avoid double slot decrement at btrfs_convert_free_space_to_extents()
authorFilipe Manana <fdmanana@suse.com>
Wed, 11 Jun 2025 22:04:45 +0000 (23:04 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:02 +0000 (23:58 +0200)
There's no need to subtract 1 from path->slots[0] and then decrement the
slot, we can reduce the generated assembly code by decrementing the slot
and then use it.

Module size before:

  $ size fs/btrfs/btrfs.ko
     text    data     bss     dec     hex filename
  1846220  162998   16136 2025354  1ee78a fs/btrfs/btrfs.ko

Module size after:

  $ size fs/btrfs/btrfs.ko
     text    data     bss     dec     hex filename
  1846204  162998   16136 2025338  1ee77a fs/btrfs/btrfs.ko

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/free-space-tree.c

index b859272328607a6e2f1b6fd5bc3978d856f566a8..d5766e25f5dc324f5838f131fd0b4fbdfd4674d5 100644 (file)
@@ -406,12 +406,12 @@ int btrfs_convert_free_space_to_extents(struct btrfs_trans_handle *trans,
                                data_size = free_space_bitmap_size(fs_info,
                                                                found_key.offset);
 
-                               ptr = btrfs_item_ptr_offset(leaf, path->slots[0] - 1);
+                               path->slots[0]--;
+                               ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
                                read_extent_buffer(leaf, bitmap_cursor, ptr,
                                                   data_size);
 
                                nr++;
-                               path->slots[0]--;
                        } else {
                                ASSERT(0);
                        }