mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-08 12:55:43 -04:00
btrfs: inline btrfs_space_info_used()
The function is simple enough to be inlined and in fact doing it even
reduces the object code. In x86_64 with gcc 14.2.0-19 from Debian the
results were the following:
Before this change
$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1919410 161703 15592 2096705 1ffe41 fs/btrfs/btrfs.ko
After this change
$ size fs/btrfs/btrfs.ko
text data bss dec hex filename
1918991 161675 15592 2096258 1ffc82 fs/btrfs/btrfs.ko
Also remove the ASSERT() that checks the space_info argument is not NULL,
as it's odd to be there since it can never be NULL and in case that ever
happens during development, a stack trace from a NULL pointer dereference
will be obvious. It was originally added when btrfs_space_info_used() was
introduced in commit 4136135b08 ("Btrfs: use helper to get used bytes
of space_info").
Also add a lockdep assertion to check the space_info's lock is being held
by the calling task.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
0ce6300fec
commit
6f4779faa0
@@ -172,16 +172,6 @@
|
||||
* thing with or without extra unallocated space.
|
||||
*/
|
||||
|
||||
u64 __pure btrfs_space_info_used(const struct btrfs_space_info *s_info,
|
||||
bool may_use_included)
|
||||
{
|
||||
ASSERT(s_info);
|
||||
return s_info->bytes_used + s_info->bytes_reserved +
|
||||
s_info->bytes_pinned + s_info->bytes_readonly +
|
||||
s_info->bytes_zone_unusable +
|
||||
(may_use_included ? s_info->bytes_may_use : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* after adding space to the filesystem, we need to clear the full flags
|
||||
* on all the space infos.
|
||||
|
||||
@@ -266,6 +266,17 @@ DECLARE_SPACE_INFO_UPDATE(bytes_may_use, "space_info");
|
||||
DECLARE_SPACE_INFO_UPDATE(bytes_pinned, "pinned");
|
||||
DECLARE_SPACE_INFO_UPDATE(bytes_zone_unusable, "zone_unusable");
|
||||
|
||||
static inline u64 btrfs_space_info_used(const struct btrfs_space_info *s_info,
|
||||
bool may_use_included)
|
||||
{
|
||||
lockdep_assert_held(&s_info->lock);
|
||||
|
||||
return s_info->bytes_used + s_info->bytes_reserved +
|
||||
s_info->bytes_pinned + s_info->bytes_readonly +
|
||||
s_info->bytes_zone_unusable +
|
||||
(may_use_included ? s_info->bytes_may_use : 0);
|
||||
}
|
||||
|
||||
int btrfs_init_space_info(struct btrfs_fs_info *fs_info);
|
||||
void btrfs_add_bg_to_space_info(struct btrfs_fs_info *info,
|
||||
struct btrfs_block_group *block_group);
|
||||
@@ -273,8 +284,6 @@ void btrfs_update_space_info_chunk_size(struct btrfs_space_info *space_info,
|
||||
u64 chunk_size);
|
||||
struct btrfs_space_info *btrfs_find_space_info(struct btrfs_fs_info *info,
|
||||
u64 flags);
|
||||
u64 __pure btrfs_space_info_used(const struct btrfs_space_info *s_info,
|
||||
bool may_use_included);
|
||||
void btrfs_clear_space_info_full(struct btrfs_fs_info *info);
|
||||
void btrfs_dump_space_info(struct btrfs_space_info *info, u64 bytes,
|
||||
bool dump_block_groups);
|
||||
|
||||
Reference in New Issue
Block a user