Commit d44b72aa authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: export space_info_add_*_bytes

Prep work for consolidating all of the space_info code into one file.
We need to export these so multiple files can use them.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent fc471cb0
...@@ -75,12 +75,6 @@ static void dump_space_info(struct btrfs_fs_info *fs_info, ...@@ -75,12 +75,6 @@ static void dump_space_info(struct btrfs_fs_info *fs_info,
int dump_block_groups); int dump_block_groups);
static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv, static int block_rsv_use_bytes(struct btrfs_block_rsv *block_rsv,
u64 num_bytes); u64 num_bytes);
static void space_info_add_new_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info,
u64 num_bytes);
static void space_info_add_old_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info,
u64 num_bytes);
static noinline int static noinline int
block_group_cache_done(struct btrfs_block_group_cache *cache) block_group_cache_done(struct btrfs_block_group_cache *cache)
...@@ -3908,8 +3902,8 @@ static void update_space_info(struct btrfs_fs_info *info, u64 flags, ...@@ -3908,8 +3902,8 @@ static void update_space_info(struct btrfs_fs_info *info, u64 flags,
found->bytes_readonly += bytes_readonly; found->bytes_readonly += bytes_readonly;
if (total_bytes > 0) if (total_bytes > 0)
found->full = 0; found->full = 0;
space_info_add_new_bytes(info, found, total_bytes - btrfs_space_info_add_new_bytes(info, found, total_bytes -
bytes_used - bytes_readonly); bytes_used - bytes_readonly);
spin_unlock(&found->lock); spin_unlock(&found->lock);
*space_info = found; *space_info = found;
} }
...@@ -5108,7 +5102,8 @@ static int wait_reserve_ticket(struct btrfs_fs_info *fs_info, ...@@ -5108,7 +5102,8 @@ static int wait_reserve_ticket(struct btrfs_fs_info *fs_info,
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
if (reclaim_bytes) if (reclaim_bytes)
space_info_add_old_bytes(fs_info, space_info, reclaim_bytes); btrfs_space_info_add_old_bytes(fs_info, space_info,
reclaim_bytes);
return ret; return ret;
} }
...@@ -5225,7 +5220,8 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info, ...@@ -5225,7 +5220,8 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
if (reclaim_bytes) if (reclaim_bytes)
space_info_add_old_bytes(fs_info, space_info, reclaim_bytes); btrfs_space_info_add_old_bytes(fs_info, space_info,
reclaim_bytes);
ASSERT(list_empty(&ticket.list)); ASSERT(list_empty(&ticket.list));
return ret; return ret;
} }
...@@ -5391,8 +5387,8 @@ void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info, ...@@ -5391,8 +5387,8 @@ void btrfs_migrate_to_delayed_refs_rsv(struct btrfs_fs_info *fs_info,
trace_btrfs_space_reservation(fs_info, "delayed_refs_rsv", trace_btrfs_space_reservation(fs_info, "delayed_refs_rsv",
0, num_bytes, 1); 0, num_bytes, 1);
if (to_free) if (to_free)
space_info_add_old_bytes(fs_info, delayed_refs_rsv->space_info, btrfs_space_info_add_old_bytes(fs_info,
to_free); delayed_refs_rsv->space_info, to_free);
} }
/** /**
...@@ -5435,9 +5431,9 @@ int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info, ...@@ -5435,9 +5431,9 @@ int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info,
* This is for space we already have accounted in space_info->bytes_may_use, so * This is for space we already have accounted in space_info->bytes_may_use, so
* basically when we're returning space from block_rsv's. * basically when we're returning space from block_rsv's.
*/ */
static void space_info_add_old_bytes(struct btrfs_fs_info *fs_info, void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, struct btrfs_space_info *space_info,
u64 num_bytes) u64 num_bytes)
{ {
struct reserve_ticket *ticket; struct reserve_ticket *ticket;
struct list_head *head; struct list_head *head;
...@@ -5495,9 +5491,9 @@ static void space_info_add_old_bytes(struct btrfs_fs_info *fs_info, ...@@ -5495,9 +5491,9 @@ static void space_info_add_old_bytes(struct btrfs_fs_info *fs_info,
* space_info->bytes_may_use yet. So if we allocate a chunk or unpin an extent * space_info->bytes_may_use yet. So if we allocate a chunk or unpin an extent
* we use this helper. * we use this helper.
*/ */
static void space_info_add_new_bytes(struct btrfs_fs_info *fs_info, void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info, struct btrfs_space_info *space_info,
u64 num_bytes) u64 num_bytes)
{ {
struct reserve_ticket *ticket; struct reserve_ticket *ticket;
struct list_head *head = &space_info->priority_tickets; struct list_head *head = &space_info->priority_tickets;
...@@ -5581,8 +5577,8 @@ static u64 block_rsv_release_bytes(struct btrfs_fs_info *fs_info, ...@@ -5581,8 +5577,8 @@ static u64 block_rsv_release_bytes(struct btrfs_fs_info *fs_info,
spin_unlock(&dest->lock); spin_unlock(&dest->lock);
} }
if (num_bytes) if (num_bytes)
space_info_add_old_bytes(fs_info, space_info, btrfs_space_info_add_old_bytes(fs_info, space_info,
num_bytes); num_bytes);
} }
if (qgroup_to_release_ret) if (qgroup_to_release_ret)
*qgroup_to_release_ret = qgroup_to_release; *qgroup_to_release_ret = qgroup_to_release;
...@@ -6758,8 +6754,8 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info, ...@@ -6758,8 +6754,8 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
spin_unlock(&global_rsv->lock); spin_unlock(&global_rsv->lock);
/* Add to any tickets we may have */ /* Add to any tickets we may have */
if (len) if (len)
space_info_add_new_bytes(fs_info, space_info, btrfs_space_info_add_new_bytes(fs_info,
len); space_info, len);
} }
spin_unlock(&space_info->lock); spin_unlock(&space_info->lock);
} }
......
...@@ -75,4 +75,11 @@ static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info) ...@@ -75,4 +75,11 @@ static inline bool btrfs_mixed_space_info(struct btrfs_space_info *space_info)
(space_info->flags & BTRFS_BLOCK_GROUP_DATA)); (space_info->flags & BTRFS_BLOCK_GROUP_DATA));
} }
void btrfs_space_info_add_new_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info,
u64 num_bytes);
void btrfs_space_info_add_old_bytes(struct btrfs_fs_info *fs_info,
struct btrfs_space_info *space_info,
u64 num_bytes);
#endif /* BTRFS_SPACE_INFO_H */ #endif /* BTRFS_SPACE_INFO_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment