diff options
author | Filipe Manana <fdmanana@suse.com> | 2024-01-25 12:53:06 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2024-02-09 22:29:14 +0300 |
commit | 1693d5442c458ae8d5b0d58463b873cd879569ed (patch) | |
tree | a1730d989c2cb5c86f0ae9e144ac1dc5b5dfe8fe /fs/btrfs/block-group.h | |
parent | 5571e41ec6e56e35f34ae9f5b3a335ef510e0ade (diff) | |
download | linux-1693d5442c458ae8d5b0d58463b873cd879569ed.tar.xz |
btrfs: add and use helper to check if block group is used
Add a helper function to determine if a block group is being used and make
use of it at btrfs_delete_unused_bgs(). This helper will also be used in
future code changes.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
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>
Diffstat (limited to 'fs/btrfs/block-group.h')
-rw-r--r-- | fs/btrfs/block-group.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h index c4a1f01cc1c2..962b11983901 100644 --- a/fs/btrfs/block-group.h +++ b/fs/btrfs/block-group.h @@ -257,6 +257,13 @@ static inline u64 btrfs_block_group_end(struct btrfs_block_group *block_group) return (block_group->start + block_group->length); } +static inline bool btrfs_is_block_group_used(const struct btrfs_block_group *bg) +{ + lockdep_assert_held(&bg->lock); + + return (bg->used > 0 || bg->reserved > 0 || bg->pinned > 0); +} + static inline bool btrfs_is_block_group_data_only( struct btrfs_block_group *block_group) { |