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

btrfs: Make btrfs_pin_extent take trans handle

Preparation for switching pinned extent tracking to 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 f603bb94
...@@ -2463,8 +2463,8 @@ int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len); ...@@ -2463,8 +2463,8 @@ int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len);
int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, u64 bytenr, struct btrfs_fs_info *fs_info, u64 bytenr,
u64 offset, int metadata, u64 *refs, u64 *flags); u64 offset, int metadata, u64 *refs, u64 *flags);
int btrfs_pin_extent(struct btrfs_fs_info *fs_info, int btrfs_pin_extent(struct btrfs_trans_handle *trans, u64 bytenr, u64 num,
u64 bytenr, u64 num, int reserved); int reserved);
int btrfs_pin_extent_for_log_replay(struct btrfs_fs_info *fs_info, int btrfs_pin_extent_for_log_replay(struct btrfs_fs_info *fs_info,
u64 bytenr, u64 num_bytes); u64 bytenr, u64 num_bytes);
int btrfs_exclude_logged_extents(struct extent_buffer *eb); int btrfs_exclude_logged_extents(struct extent_buffer *eb);
......
...@@ -1705,8 +1705,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans, ...@@ -1705,8 +1705,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
if (TRANS_ABORTED(trans)) { if (TRANS_ABORTED(trans)) {
if (insert_reserved) if (insert_reserved)
btrfs_pin_extent(trans->fs_info, node->bytenr, btrfs_pin_extent(trans, node->bytenr, node->num_bytes, 1);
node->num_bytes, 1);
return 0; return 0;
} }
...@@ -1721,8 +1720,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans, ...@@ -1721,8 +1720,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
else else
BUG(); BUG();
if (ret && insert_reserved) if (ret && insert_reserved)
btrfs_pin_extent(trans->fs_info, node->bytenr, btrfs_pin_extent(trans, node->bytenr, node->num_bytes, 1);
node->num_bytes, 1);
return ret; return ret;
} }
...@@ -1867,8 +1865,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, ...@@ -1867,8 +1865,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
spin_unlock(&delayed_refs->lock); spin_unlock(&delayed_refs->lock);
if (head->must_insert_reserved) { if (head->must_insert_reserved) {
btrfs_pin_extent(fs_info, head->bytenr, btrfs_pin_extent(trans, head->bytenr, head->num_bytes, 1);
head->num_bytes, 1);
if (head->is_data) { if (head->is_data) {
ret = btrfs_del_csums(trans, fs_info->csum_root, ret = btrfs_del_csums(trans, fs_info->csum_root,
head->bytenr, head->num_bytes); head->bytenr, head->num_bytes);
...@@ -2612,14 +2609,12 @@ static int pin_down_extent(struct btrfs_block_group *cache, ...@@ -2612,14 +2609,12 @@ static int pin_down_extent(struct btrfs_block_group *cache,
return 0; return 0;
} }
int btrfs_pin_extent(struct btrfs_fs_info *fs_info, int btrfs_pin_extent(struct btrfs_trans_handle *trans,
u64 bytenr, u64 num_bytes, int reserved) u64 bytenr, u64 num_bytes, int reserved)
{ {
struct btrfs_block_group *cache; struct btrfs_block_group *cache;
ASSERT(fs_info->running_transaction); cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
cache = btrfs_lookup_block_group(fs_info, bytenr);
BUG_ON(!cache); /* Logic error */ BUG_ON(!cache); /* Logic error */
pin_down_extent(cache, bytenr, num_bytes, reserved); pin_down_extent(cache, bytenr, num_bytes, reserved);
...@@ -3345,7 +3340,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref) ...@@ -3345,7 +3340,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
(ref->type == BTRFS_REF_DATA && (ref->type == BTRFS_REF_DATA &&
ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID)) { ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID)) {
/* unlocks the pinned mutex */ /* unlocks the pinned mutex */
btrfs_pin_extent(fs_info, ref->bytenr, ref->len, 1); btrfs_pin_extent(trans, ref->bytenr, ref->len, 1);
old_ref_mod = new_ref_mod = 0; old_ref_mod = new_ref_mod = 0;
ret = 0; ret = 0;
} else if (ref->type == BTRFS_REF_METADATA) { } else if (ref->type == BTRFS_REF_METADATA) {
......
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