]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: rename free_space_set_bits() and make it less confusing
authorFilipe Manana <fdmanana@suse.com>
Wed, 11 Jun 2025 16:48:28 +0000 (17:48 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:02 +0000 (23:58 +0200)
The free_space_set_bits() is used both to set a range of bits or to clear
range of bits, depending on the 'bit' argument value. So the name is very
misleading since it's not used only to set bits. Furthermore the 'bit'
argument is an integer when a boolean is all that is needed plus its name
is singular, which gives the idea the function operates on a single bit
and not on a range of bits.

So rename the function to free_space_modify_bits(), rename the 'bit'
argument to 'set_bits' and turn the argument to bool instead of int.

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 1794fdf06586046e19d91e45e486b6dbcdc2710a..a0b51543e83e842c74dd009f1ab7849696699387 100644 (file)
@@ -535,10 +535,10 @@ bool btrfs_free_space_test_bit(struct btrfs_block_group *block_group,
        return extent_buffer_test_bit(leaf, ptr, i);
 }
 
-static void free_space_set_bits(struct btrfs_trans_handle *trans,
-                               struct btrfs_block_group *block_group,
-                               struct btrfs_path *path, u64 *start, u64 *size,
-                               int bit)
+static void free_space_modify_bits(struct btrfs_trans_handle *trans,
+                                  struct btrfs_block_group *block_group,
+                                  struct btrfs_path *path, u64 *start, u64 *size,
+                                  bool set_bits)
 {
        struct btrfs_fs_info *fs_info = block_group->fs_info;
        struct extent_buffer *leaf;
@@ -562,7 +562,7 @@ static void free_space_set_bits(struct btrfs_trans_handle *trans,
        ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
        first = (*start - found_start) >> fs_info->sectorsize_bits;
        last = (end - found_start) >> fs_info->sectorsize_bits;
-       if (bit)
+       if (set_bits)
                extent_buffer_bitmap_set(leaf, ptr, first, last - first);
        else
                extent_buffer_bitmap_clear(leaf, ptr, first, last - first);
@@ -658,8 +658,8 @@ static int modify_free_space_bitmap(struct btrfs_trans_handle *trans,
        cur_start = start;
        cur_size = size;
        while (1) {
-               free_space_set_bits(trans, block_group, path, &cur_start, &cur_size,
-                                   !remove);
+               free_space_modify_bits(trans, block_group, path, &cur_start,
+                                      &cur_size, !remove);
                if (cur_size == 0)
                        break;
                ret = free_space_next_bitmap(trans, root, path);