mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 09:59:32 +00:00
btrfs: consolidate bitmap_clear_bits/__bitmap_clear_bits
The only difference is the former adjusts btrfs_free_space::bytes member. Consolidate the two function into 1 and add a bool parameter which controls whether the adjustment is made or not. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
abed4aaae4
commit
f594f13c19
1 changed files with 13 additions and 24 deletions
|
@ -45,7 +45,7 @@ static void free_bitmap(struct btrfs_free_space_ctl *ctl,
|
||||||
struct btrfs_free_space *bitmap_info);
|
struct btrfs_free_space *bitmap_info);
|
||||||
static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
||||||
struct btrfs_free_space *info, u64 offset,
|
struct btrfs_free_space *info, u64 offset,
|
||||||
u64 bytes);
|
u64 bytes, bool update_stats);
|
||||||
|
|
||||||
static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
|
static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
|
||||||
struct btrfs_path *path,
|
struct btrfs_path *path,
|
||||||
|
@ -886,7 +886,7 @@ static int copy_free_space_cache(struct btrfs_block_group *block_group,
|
||||||
bytes);
|
bytes);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
bitmap_clear_bits(ctl, info, offset, bytes);
|
bitmap_clear_bits(ctl, info, offset, bytes, true);
|
||||||
offset = info->offset;
|
offset = info->offset;
|
||||||
bytes = ctl->unit;
|
bytes = ctl->unit;
|
||||||
}
|
}
|
||||||
|
@ -1803,9 +1803,9 @@ static void relink_bitmap_entry(struct btrfs_free_space_ctl *ctl,
|
||||||
rb_add_cached(&info->bytes_index, &ctl->free_space_bytes, entry_less);
|
rb_add_cached(&info->bytes_index, &ctl->free_space_bytes, entry_less);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
static inline void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
||||||
struct btrfs_free_space *info,
|
struct btrfs_free_space *info,
|
||||||
u64 offset, u64 bytes)
|
u64 offset, u64 bytes, bool update_stat)
|
||||||
{
|
{
|
||||||
unsigned long start, count, end;
|
unsigned long start, count, end;
|
||||||
int extent_delta = -1;
|
int extent_delta = -1;
|
||||||
|
@ -1834,14 +1834,9 @@ static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
||||||
ctl->discardable_extents[BTRFS_STAT_CURR] += extent_delta;
|
ctl->discardable_extents[BTRFS_STAT_CURR] += extent_delta;
|
||||||
ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
|
ctl->discardable_bytes[BTRFS_STAT_CURR] -= bytes;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
if (update_stat)
|
||||||
struct btrfs_free_space *info, u64 offset,
|
ctl->free_space -= bytes;
|
||||||
u64 bytes)
|
|
||||||
{
|
|
||||||
__bitmap_clear_bits(ctl, info, offset, bytes);
|
|
||||||
ctl->free_space -= bytes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl,
|
static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl,
|
||||||
|
@ -2112,7 +2107,7 @@ static noinline int remove_from_bitmap(struct btrfs_free_space_ctl *ctl,
|
||||||
/* Cannot clear past the end of the bitmap */
|
/* Cannot clear past the end of the bitmap */
|
||||||
search_bytes = min(search_bytes, end - search_start + 1);
|
search_bytes = min(search_bytes, end - search_start + 1);
|
||||||
|
|
||||||
bitmap_clear_bits(ctl, bitmap_info, search_start, search_bytes);
|
bitmap_clear_bits(ctl, bitmap_info, search_start, search_bytes, true);
|
||||||
*offset += search_bytes;
|
*offset += search_bytes;
|
||||||
*bytes -= search_bytes;
|
*bytes -= search_bytes;
|
||||||
|
|
||||||
|
@ -2457,10 +2452,7 @@ static bool steal_from_bitmap_to_end(struct btrfs_free_space_ctl *ctl,
|
||||||
if (!btrfs_free_space_trimmed(bitmap))
|
if (!btrfs_free_space_trimmed(bitmap))
|
||||||
info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
|
info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
|
||||||
|
|
||||||
if (update_stat)
|
bitmap_clear_bits(ctl, bitmap, end, bytes, update_stat);
|
||||||
bitmap_clear_bits(ctl, bitmap, end, bytes);
|
|
||||||
else
|
|
||||||
__bitmap_clear_bits(ctl, bitmap, end, bytes);
|
|
||||||
|
|
||||||
if (!bitmap->bytes)
|
if (!bitmap->bytes)
|
||||||
free_bitmap(ctl, bitmap);
|
free_bitmap(ctl, bitmap);
|
||||||
|
@ -2514,10 +2506,7 @@ static bool steal_from_bitmap_to_front(struct btrfs_free_space_ctl *ctl,
|
||||||
if (!btrfs_free_space_trimmed(bitmap))
|
if (!btrfs_free_space_trimmed(bitmap))
|
||||||
info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
|
info->trim_state = BTRFS_TRIM_STATE_UNTRIMMED;
|
||||||
|
|
||||||
if (update_stat)
|
bitmap_clear_bits(ctl, bitmap, info->offset, bytes, update_stat);
|
||||||
bitmap_clear_bits(ctl, bitmap, info->offset, bytes);
|
|
||||||
else
|
|
||||||
__bitmap_clear_bits(ctl, bitmap, info->offset, bytes);
|
|
||||||
|
|
||||||
if (!bitmap->bytes)
|
if (!bitmap->bytes)
|
||||||
free_bitmap(ctl, bitmap);
|
free_bitmap(ctl, bitmap);
|
||||||
|
@ -3077,7 +3066,7 @@ u64 btrfs_find_space_for_alloc(struct btrfs_block_group *block_group,
|
||||||
|
|
||||||
ret = offset;
|
ret = offset;
|
||||||
if (entry->bitmap) {
|
if (entry->bitmap) {
|
||||||
bitmap_clear_bits(ctl, entry, offset, bytes);
|
bitmap_clear_bits(ctl, entry, offset, bytes, true);
|
||||||
|
|
||||||
if (!btrfs_free_space_trimmed(entry))
|
if (!btrfs_free_space_trimmed(entry))
|
||||||
atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
|
atomic64_add(bytes, &discard_ctl->discard_bytes_saved);
|
||||||
|
@ -3179,7 +3168,7 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group *block_group,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = search_start;
|
ret = search_start;
|
||||||
__bitmap_clear_bits(ctl, entry, ret, bytes);
|
bitmap_clear_bits(ctl, entry, ret, bytes, false);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3941,7 +3930,7 @@ static int trim_bitmaps(struct btrfs_block_group *block_group,
|
||||||
bytes > (max_discard_size + minlen))
|
bytes > (max_discard_size + minlen))
|
||||||
bytes = max_discard_size;
|
bytes = max_discard_size;
|
||||||
|
|
||||||
bitmap_clear_bits(ctl, entry, start, bytes);
|
bitmap_clear_bits(ctl, entry, start, bytes, true);
|
||||||
if (entry->bytes == 0)
|
if (entry->bytes == 0)
|
||||||
free_bitmap(ctl, entry);
|
free_bitmap(ctl, entry);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue