Commit 7bfc1007 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: Make btrfs_pin_reserved_extent take transaction handle

btrfs_pin_reserved_extent is now only called with a valid transaction so
exploit the fact to take a transaction. This is preparation for tracking
pinned extents on a per-transaction basis.
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 10e958d5
...@@ -2501,7 +2501,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref); ...@@ -2501,7 +2501,7 @@ 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_pin_reserved_extent(struct btrfs_fs_info *fs_info, u64 start, int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, 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);
......
...@@ -4184,14 +4184,16 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, ...@@ -4184,14 +4184,16 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
return 0; return 0;
} }
int btrfs_pin_reserved_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len) int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, u64 start,
u64 len)
{ {
struct btrfs_block_group *cache; struct btrfs_block_group *cache;
int ret = 0; int ret = 0;
cache = btrfs_lookup_block_group(fs_info, start); cache = btrfs_lookup_block_group(trans->fs_info, start);
if (!cache) { if (!cache) {
btrfs_err(fs_info, "unable to find block group for %llu", start); btrfs_err(trans->fs_info, "unable to find block group for %llu",
start);
return -ENOSPC; return -ENOSPC;
} }
......
...@@ -2745,7 +2745,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, ...@@ -2745,7 +2745,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
btrfs_clean_tree_block(next); btrfs_clean_tree_block(next);
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
ret = btrfs_pin_reserved_extent(fs_info, ret = btrfs_pin_reserved_extent(trans,
bytenr, blocksize); bytenr, blocksize);
if (ret) { if (ret) {
free_extent_buffer(next); free_extent_buffer(next);
...@@ -2814,7 +2814,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, ...@@ -2814,7 +2814,7 @@ static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans,
btrfs_clean_tree_block(next); btrfs_clean_tree_block(next);
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
ret = btrfs_pin_reserved_extent(fs_info, ret = btrfs_pin_reserved_extent(trans,
path->nodes[*level]->start, path->nodes[*level]->start,
path->nodes[*level]->len); path->nodes[*level]->len);
if (ret) if (ret)
...@@ -2896,7 +2896,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, ...@@ -2896,7 +2896,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
btrfs_clean_tree_block(next); btrfs_clean_tree_block(next);
btrfs_wait_tree_block_writeback(next); btrfs_wait_tree_block_writeback(next);
btrfs_tree_unlock(next); btrfs_tree_unlock(next);
ret = btrfs_pin_reserved_extent(fs_info, ret = btrfs_pin_reserved_extent(trans,
next->start, next->len); next->start, 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