Commit a0fbf736 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Rename __btrfs_free_reserved_extent to btrfs_pin_reserved_extent

__btrfs_free_reserved_extent now performs the actions of
btrfs_free_and_pin_reserved_extent. But this name is a bit of a
misnomer, since the extent is not really freed but just pinned. Reflect
this in the new name. No semantics changes.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 7ef54d54
...@@ -2449,8 +2449,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref); ...@@ -2449,8 +2449,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref);
int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
u64 start, u64 len, int delalloc); u64 start, u64 len, int delalloc);
int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info, int btrfs_pin_reserved_extent(struct btrfs_fs_info *fs_info, u64 start,
u64 start, u64 len); u64 len);
void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info); void btrfs_prepare_extent_commit(struct btrfs_fs_info *fs_info);
int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans); int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
......
...@@ -4165,12 +4165,10 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, ...@@ -4165,12 +4165,10 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes,
return ret; return ret;
} }
static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
u64 start, u64 len, u64 start, u64 len, int delalloc)
int pin, int delalloc)
{ {
struct btrfs_block_group *cache; struct btrfs_block_group *cache;
int ret = 0;
cache = btrfs_lookup_block_group(fs_info, start); cache = btrfs_lookup_block_group(fs_info, start);
if (!cache) { if (!cache) {
...@@ -4179,15 +4177,18 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, ...@@ -4179,15 +4177,18 @@ static int __btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
return -ENOSPC; return -ENOSPC;
} }
ret = pin_down_extent(cache, start, len, 1); btrfs_add_free_space(cache, start, len);
btrfs_free_reserved_bytes(cache, len, delalloc);
trace_btrfs_reserved_extent_free(fs_info, start, len);
btrfs_put_block_group(cache); btrfs_put_block_group(cache);
return ret; return 0;
} }
int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, int btrfs_pin_reserved_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len)
u64 start, u64 len, int delalloc)
{ {
struct btrfs_block_group *cache; struct btrfs_block_group *cache;
int ret = 0;
cache = btrfs_lookup_block_group(fs_info, start); cache = btrfs_lookup_block_group(fs_info, start);
if (!cache) { if (!cache) {
...@@ -4195,18 +4196,9 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, ...@@ -4195,18 +4196,9 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
return -ENOSPC; return -ENOSPC;
} }
btrfs_add_free_space(cache, start, len); ret = pin_down_extent(cache, start, len, 1);
btrfs_free_reserved_bytes(cache, len, delalloc);
trace_btrfs_reserved_extent_free(fs_info, start, len);
btrfs_put_block_group(cache); btrfs_put_block_group(cache);
return 0; return ret;
}
int btrfs_free_and_pin_reserved_extent(struct btrfs_fs_info *fs_info,
u64 start, u64 len)
{
return __btrfs_free_reserved_extent(fs_info, start, len, 1, 0);
} }
static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans, static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
......
...@@ -2732,9 +2732,8 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -2732,9 +2732,8 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
WARN_ON(root_owner != WARN_ON(root_owner !=
BTRFS_TREE_LOG_OBJECTID); BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_and_pin_reserved_extent( ret = btrfs_pin_reserved_extent(fs_info,
fs_info, bytenr, bytenr, blocksize);
blocksize);
if (ret) { if (ret) {
free_extent_buffer(next); free_extent_buffer(next);
return ret; return ret;
...@@ -2815,8 +2814,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, ...@@ -2815,8 +2814,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
} }
WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_and_pin_reserved_extent( ret = btrfs_pin_reserved_extent(fs_info,
fs_info,
path->nodes[*level]->start, path->nodes[*level]->start,
path->nodes[*level]->len); path->nodes[*level]->len);
if (ret) if (ret)
...@@ -2898,8 +2896,8 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, ...@@ -2898,8 +2896,8 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
WARN_ON(log->root_key.objectid != WARN_ON(log->root_key.objectid !=
BTRFS_TREE_LOG_OBJECTID); BTRFS_TREE_LOG_OBJECTID);
ret = btrfs_free_and_pin_reserved_extent(fs_info, ret = btrfs_pin_reserved_extent(fs_info, next->start,
next->start, next->len); next->len);
if (ret) if (ret)
goto out; goto out;
} }
......
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