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

btrfs: move ref_root into btrfs_ref

We have this in both btrfs_tree_ref and btrfs_data_ref, which is just
wasting space and making the code more complicated.  Move this into
btrfs_ref proper and update all the call sites to do the assignment in
btrfs_ref.
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 4d09b4e9
...@@ -1007,17 +1007,16 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info, ...@@ -1007,17 +1007,16 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
INIT_LIST_HEAD(&ref->add_list); INIT_LIST_HEAD(&ref->add_list);
} }
void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 root, void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
u64 mod_root, bool skip_qgroup) bool skip_qgroup)
{ {
#ifdef CONFIG_BTRFS_FS_REF_VERIFY #ifdef CONFIG_BTRFS_FS_REF_VERIFY
/* If @real_root not set, use @root as fallback */ /* If @real_root not set, use @root as fallback */
generic_ref->real_root = mod_root ?: root; generic_ref->real_root = mod_root ?: generic_ref->ref_root;
#endif #endif
generic_ref->tree_ref.level = level; generic_ref->tree_ref.level = level;
generic_ref->tree_ref.ref_root = root;
generic_ref->type = BTRFS_REF_METADATA; generic_ref->type = BTRFS_REF_METADATA;
if (skip_qgroup || !(is_fstree(root) && if (skip_qgroup || !(is_fstree(generic_ref->ref_root) &&
(!mod_root || is_fstree(mod_root)))) (!mod_root || is_fstree(mod_root))))
generic_ref->skip_qgroup = true; generic_ref->skip_qgroup = true;
else else
...@@ -1025,18 +1024,17 @@ void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 root, ...@@ -1025,18 +1024,17 @@ void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 root,
} }
void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ref_root, u64 ino, void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ino, u64 offset,
u64 offset, u64 mod_root, bool skip_qgroup) u64 mod_root, bool skip_qgroup)
{ {
#ifdef CONFIG_BTRFS_FS_REF_VERIFY #ifdef CONFIG_BTRFS_FS_REF_VERIFY
/* If @real_root not set, use @root as fallback */ /* If @real_root not set, use @root as fallback */
generic_ref->real_root = mod_root ?: ref_root; generic_ref->real_root = mod_root ?: generic_ref->ref_root;
#endif #endif
generic_ref->data_ref.ref_root = ref_root;
generic_ref->data_ref.ino = ino; generic_ref->data_ref.ino = ino;
generic_ref->data_ref.offset = offset; generic_ref->data_ref.offset = offset;
generic_ref->type = BTRFS_REF_DATA; generic_ref->type = BTRFS_REF_DATA;
if (skip_qgroup || !(is_fstree(ref_root) && if (skip_qgroup || !(is_fstree(generic_ref->ref_root) &&
(!mod_root || is_fstree(mod_root)))) (!mod_root || is_fstree(mod_root))))
generic_ref->skip_qgroup = true; generic_ref->skip_qgroup = true;
else else
...@@ -1068,7 +1066,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ...@@ -1068,7 +1066,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
u64 parent = generic_ref->parent; u64 parent = generic_ref->parent;
u8 ref_type; u8 ref_type;
is_system = (generic_ref->tree_ref.ref_root == BTRFS_CHUNK_TREE_OBJECTID); is_system = (generic_ref->ref_root == BTRFS_CHUNK_TREE_OBJECTID);
ASSERT(generic_ref->type == BTRFS_REF_METADATA && generic_ref->action); ASSERT(generic_ref->type == BTRFS_REF_METADATA && generic_ref->action);
node = kmem_cache_alloc(btrfs_delayed_ref_node_cachep, GFP_NOFS); node = kmem_cache_alloc(btrfs_delayed_ref_node_cachep, GFP_NOFS);
...@@ -1098,14 +1096,13 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans, ...@@ -1098,14 +1096,13 @@ int btrfs_add_delayed_tree_ref(struct btrfs_trans_handle *trans,
ref_type = BTRFS_TREE_BLOCK_REF_KEY; ref_type = BTRFS_TREE_BLOCK_REF_KEY;
init_delayed_ref_common(fs_info, node, bytenr, num_bytes, init_delayed_ref_common(fs_info, node, bytenr, num_bytes,
generic_ref->tree_ref.ref_root, action, generic_ref->ref_root, action, ref_type);
ref_type); ref->root = generic_ref->ref_root;
ref->root = generic_ref->tree_ref.ref_root;
ref->parent = parent; ref->parent = parent;
ref->level = level; ref->level = level;
init_delayed_ref_head(head_ref, record, bytenr, num_bytes, init_delayed_ref_head(head_ref, record, bytenr, num_bytes,
generic_ref->tree_ref.ref_root, 0, action, generic_ref->ref_root, 0, action,
false, is_system, generic_ref->owning_root); false, is_system, generic_ref->owning_root);
head_ref->extent_op = extent_op; head_ref->extent_op = extent_op;
...@@ -1159,7 +1156,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans, ...@@ -1159,7 +1156,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_trans_handle *trans,
u64 bytenr = generic_ref->bytenr; u64 bytenr = generic_ref->bytenr;
u64 num_bytes = generic_ref->len; u64 num_bytes = generic_ref->len;
u64 parent = generic_ref->parent; u64 parent = generic_ref->parent;
u64 ref_root = generic_ref->data_ref.ref_root; u64 ref_root = generic_ref->ref_root;
u64 owner = generic_ref->data_ref.ino; u64 owner = generic_ref->data_ref.ino;
u64 offset = generic_ref->data_ref.offset; u64 offset = generic_ref->data_ref.offset;
u8 ref_type; u8 ref_type;
......
...@@ -220,9 +220,6 @@ enum btrfs_ref_type { ...@@ -220,9 +220,6 @@ enum btrfs_ref_type {
struct btrfs_data_ref { struct btrfs_data_ref {
/* For EXTENT_DATA_REF */ /* For EXTENT_DATA_REF */
/* Root which owns this data reference. */
u64 ref_root;
/* Inode which refers to this data extent */ /* Inode which refers to this data extent */
u64 ino; u64 ino;
...@@ -243,13 +240,6 @@ struct btrfs_tree_ref { ...@@ -243,13 +240,6 @@ struct btrfs_tree_ref {
*/ */
int level; int level;
/*
* Root which owns this tree block reference.
*
* For TREE_BLOCK_REF (skinny metadata, either inline or keyed)
*/
u64 ref_root;
/* For non-skinny metadata, no special member needed */ /* For non-skinny metadata, no special member needed */
}; };
...@@ -273,6 +263,12 @@ struct btrfs_ref { ...@@ -273,6 +263,12 @@ struct btrfs_ref {
u64 len; u64 len;
u64 owning_root; u64 owning_root;
/*
* The root that owns the reference for this reference, this will be set
* or ->parent will be set, depending on what type of reference this is.
*/
u64 ref_root;
/* Bytenr of the parent tree block */ /* Bytenr of the parent tree block */
u64 parent; u64 parent;
union { union {
...@@ -320,10 +316,10 @@ static inline u64 btrfs_calc_delayed_ref_csum_bytes(const struct btrfs_fs_info * ...@@ -320,10 +316,10 @@ static inline u64 btrfs_calc_delayed_ref_csum_bytes(const struct btrfs_fs_info *
return btrfs_calc_metadata_size(fs_info, num_csum_items); return btrfs_calc_metadata_size(fs_info, num_csum_items);
} }
void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 root, void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
bool skip_qgroup);
void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ino, u64 offset,
u64 mod_root, bool skip_qgroup); u64 mod_root, bool skip_qgroup);
void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ref_root, u64 ino,
u64 offset, u64 mod_root, bool skip_qgroup);
static inline struct btrfs_delayed_extent_op * static inline struct btrfs_delayed_extent_op *
btrfs_alloc_delayed_extent_op(void) btrfs_alloc_delayed_extent_op(void)
......
...@@ -1439,7 +1439,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, ...@@ -1439,7 +1439,7 @@ int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
ASSERT(generic_ref->type != BTRFS_REF_NOT_SET && ASSERT(generic_ref->type != BTRFS_REF_NOT_SET &&
generic_ref->action); generic_ref->action);
BUG_ON(generic_ref->type == BTRFS_REF_METADATA && BUG_ON(generic_ref->type == BTRFS_REF_METADATA &&
generic_ref->tree_ref.ref_root == BTRFS_TREE_LOG_OBJECTID); generic_ref->ref_root == BTRFS_TREE_LOG_OBJECTID);
if (generic_ref->type == BTRFS_REF_METADATA) if (generic_ref->type == BTRFS_REF_METADATA)
ret = btrfs_add_delayed_tree_ref(trans, generic_ref, NULL); ret = btrfs_add_delayed_tree_ref(trans, generic_ref, NULL);
...@@ -2526,6 +2526,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ...@@ -2526,6 +2526,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
struct btrfs_ref ref = { struct btrfs_ref ref = {
.action = action, .action = action,
.parent = parent, .parent = parent,
.ref_root = ref_root,
}; };
if (level == 0) { if (level == 0) {
...@@ -2545,9 +2546,8 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ...@@ -2545,9 +2546,8 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
ref.owning_root = ref_root; ref.owning_root = ref_root;
key.offset -= btrfs_file_extent_offset(buf, fi); key.offset -= btrfs_file_extent_offset(buf, fi);
btrfs_init_data_ref(&ref, ref_root, key.objectid, btrfs_init_data_ref(&ref, key.objectid, key.offset,
key.offset, root->root_key.objectid, root->root_key.objectid, for_reloc);
for_reloc);
if (inc) if (inc)
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
else else
...@@ -2559,7 +2559,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ...@@ -2559,7 +2559,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
ref.bytenr = btrfs_node_blockptr(buf, i); ref.bytenr = btrfs_node_blockptr(buf, i);
ref.len = fs_info->nodesize; ref.len = fs_info->nodesize;
btrfs_init_tree_ref(&ref, level - 1, ref_root, btrfs_init_tree_ref(&ref, level - 1,
root->root_key.objectid, for_reloc); root->root_key.objectid, for_reloc);
if (inc) if (inc)
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
...@@ -3469,6 +3469,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, ...@@ -3469,6 +3469,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
.len = buf->len, .len = buf->len,
.parent = parent, .parent = parent,
.owning_root = btrfs_header_owner(buf), .owning_root = btrfs_header_owner(buf),
.ref_root = root_id,
}; };
/* /*
...@@ -3479,8 +3480,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans, ...@@ -3479,8 +3480,7 @@ void btrfs_free_tree_block(struct btrfs_trans_handle *trans,
*/ */
ASSERT(btrfs_header_bytenr(buf) != 0); ASSERT(btrfs_header_bytenr(buf) != 0);
btrfs_init_tree_ref(&generic_ref, btrfs_header_level(buf), btrfs_init_tree_ref(&generic_ref, btrfs_header_level(buf), 0, false);
root_id, 0, false);
btrfs_ref_tree_mod(fs_info, &generic_ref); btrfs_ref_tree_mod(fs_info, &generic_ref);
ret = btrfs_add_delayed_tree_ref(trans, &generic_ref, NULL); ret = btrfs_add_delayed_tree_ref(trans, &generic_ref, NULL);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
...@@ -3559,10 +3559,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref) ...@@ -3559,10 +3559,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
* tree log blocks never actually go into the extent allocation * tree log blocks never actually go into the extent allocation
* tree, just update pinning info and exit early. * tree, just update pinning info and exit early.
*/ */
if ((ref->type == BTRFS_REF_METADATA && if (ref->ref_root == BTRFS_TREE_LOG_OBJECTID) {
ref->tree_ref.ref_root == BTRFS_TREE_LOG_OBJECTID) ||
(ref->type == BTRFS_REF_DATA &&
ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID)) {
btrfs_pin_extent(trans, ref->bytenr, ref->len, 1); btrfs_pin_extent(trans, ref->bytenr, ref->len, 1);
ret = 0; ret = 0;
} else if (ref->type == BTRFS_REF_METADATA) { } else if (ref->type == BTRFS_REF_METADATA) {
...@@ -3571,10 +3568,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref) ...@@ -3571,10 +3568,7 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref)
ret = btrfs_add_delayed_data_ref(trans, ref, 0); ret = btrfs_add_delayed_data_ref(trans, ref, 0);
} }
if (!((ref->type == BTRFS_REF_METADATA && if (ref->ref_root != BTRFS_TREE_LOG_OBJECTID)
ref->tree_ref.ref_root == BTRFS_TREE_LOG_OBJECTID) ||
(ref->type == BTRFS_REF_DATA &&
ref->data_ref.ref_root == BTRFS_TREE_LOG_OBJECTID)))
btrfs_ref_tree_mod(fs_info, ref); btrfs_ref_tree_mod(fs_info, ref);
return ret; return ret;
...@@ -4975,16 +4969,15 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, ...@@ -4975,16 +4969,15 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
.bytenr = ins->objectid, .bytenr = ins->objectid,
.len = ins->offset, .len = ins->offset,
.owning_root = root->root_key.objectid, .owning_root = root->root_key.objectid,
.ref_root = root->root_key.objectid,
}; };
u64 root_objectid = root->root_key.objectid;
ASSERT(root_objectid != BTRFS_TREE_LOG_OBJECTID); ASSERT(generic_ref.ref_root != BTRFS_TREE_LOG_OBJECTID);
if (btrfs_is_data_reloc_root(root) && is_fstree(root->relocation_src_root)) if (btrfs_is_data_reloc_root(root) && is_fstree(root->relocation_src_root))
generic_ref.owning_root = root->relocation_src_root; generic_ref.owning_root = root->relocation_src_root;
btrfs_init_data_ref(&generic_ref, root_objectid, owner, btrfs_init_data_ref(&generic_ref, owner, offset, 0, false);
offset, 0, false);
btrfs_ref_tree_mod(root->fs_info, &generic_ref); btrfs_ref_tree_mod(root->fs_info, &generic_ref);
return btrfs_add_delayed_data_ref(trans, &generic_ref, ram_bytes); return btrfs_add_delayed_data_ref(trans, &generic_ref, ram_bytes);
...@@ -5211,6 +5204,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, ...@@ -5211,6 +5204,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
.len = ins.offset, .len = ins.offset,
.parent = parent, .parent = parent,
.owning_root = owning_root, .owning_root = owning_root,
.ref_root = root_objectid,
}; };
extent_op = btrfs_alloc_delayed_extent_op(); extent_op = btrfs_alloc_delayed_extent_op();
if (!extent_op) { if (!extent_op) {
...@@ -5226,7 +5220,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, ...@@ -5226,7 +5220,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
extent_op->update_flags = true; extent_op->update_flags = true;
extent_op->level = level; extent_op->level = level;
btrfs_init_tree_ref(&generic_ref, level, root_objectid, btrfs_init_tree_ref(&generic_ref, level,
root->root_key.objectid, false); root->root_key.objectid, false);
btrfs_ref_tree_mod(fs_info, &generic_ref); btrfs_ref_tree_mod(fs_info, &generic_ref);
ret = btrfs_add_delayed_tree_ref(trans, &generic_ref, extent_op); ret = btrfs_add_delayed_tree_ref(trans, &generic_ref, extent_op);
...@@ -5594,6 +5588,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, ...@@ -5594,6 +5588,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
.bytenr = bytenr, .bytenr = bytenr,
.len = fs_info->nodesize, .len = fs_info->nodesize,
.owning_root = owner_root, .owning_root = owner_root,
.ref_root = root->root_key.objectid,
}; };
if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) { if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF) {
ref.parent = path->nodes[level]->start; ref.parent = path->nodes[level]->start;
...@@ -5651,8 +5646,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, ...@@ -5651,8 +5646,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
wc->drop_level = level; wc->drop_level = level;
find_next_key(path, level, &wc->drop_progress); find_next_key(path, level, &wc->drop_progress);
btrfs_init_tree_ref(&ref, level - 1, root->root_key.objectid, btrfs_init_tree_ref(&ref, level - 1, 0, false);
0, false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
......
...@@ -378,12 +378,11 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -378,12 +378,11 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
.len = num_bytes, .len = num_bytes,
.parent = 0, .parent = 0,
.owning_root = root->root_key.objectid, .owning_root = root->root_key.objectid,
.ref_root = root->root_key.objectid,
}; };
btrfs_init_data_ref(&ref, btrfs_init_data_ref(&ref, new_key.objectid,
root->root_key.objectid, args->start - extent_offset,
new_key.objectid, 0, false);
args->start - extent_offset,
0, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -472,12 +471,11 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -472,12 +471,11 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans,
.len = num_bytes, .len = num_bytes,
.parent = 0, .parent = 0,
.owning_root = root->root_key.objectid, .owning_root = root->root_key.objectid,
.ref_root = root->root_key.objectid,
}; };
btrfs_init_data_ref(&ref, btrfs_init_data_ref(&ref, key.objectid,
root->root_key.objectid, key.offset - extent_offset,
key.objectid, 0, false);
key.offset - extent_offset, 0,
false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -758,8 +756,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -758,8 +756,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
ref.len = num_bytes; ref.len = num_bytes;
ref.parent = 0; ref.parent = 0;
ref.owning_root = root->root_key.objectid; ref.owning_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, root->root_key.objectid, ino, ref.ref_root = root->root_key.objectid;
orig_offset, 0, false); btrfs_init_data_ref(&ref, ino, orig_offset, 0, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -788,8 +786,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, ...@@ -788,8 +786,8 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans,
ref.len = num_bytes; ref.len = num_bytes;
ref.parent = 0; ref.parent = 0;
ref.owning_root = root->root_key.objectid; ref.owning_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, root->root_key.objectid, ino, orig_offset, ref.ref_root = root->root_key.objectid;
0, false); btrfs_init_data_ref(&ref, ino, orig_offset, 0, false);
if (extent_mergeable(leaf, path->slots[0] + 1, if (extent_mergeable(leaf, path->slots[0] + 1,
ino, bytenr, orig_offset, ino, bytenr, orig_offset,
&other_start, &other_end)) { &other_start, &other_end)) {
...@@ -2496,12 +2494,12 @@ static int btrfs_insert_replace_extent(struct btrfs_trans_handle *trans, ...@@ -2496,12 +2494,12 @@ static int btrfs_insert_replace_extent(struct btrfs_trans_handle *trans,
.bytenr = extent_info->disk_offset, .bytenr = extent_info->disk_offset,
.len = extent_info->disk_len, .len = extent_info->disk_len,
.owning_root = root->root_key.objectid, .owning_root = root->root_key.objectid,
.ref_root = root->root_key.objectid,
}; };
u64 ref_offset; u64 ref_offset;
ref_offset = extent_info->file_offset - extent_info->data_offset; ref_offset = extent_info->file_offset - extent_info->data_offset;
btrfs_init_data_ref(&ref, root->root_key.objectid, btrfs_init_data_ref(&ref, btrfs_ino(inode), ref_offset, 0, false);
btrfs_ino(inode), ref_offset, 0, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
} }
......
...@@ -675,13 +675,13 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -675,13 +675,13 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
.bytenr = extent_start, .bytenr = extent_start,
.len = extent_num_bytes, .len = extent_num_bytes,
.owning_root = root->root_key.objectid, .owning_root = root->root_key.objectid,
.ref_root = btrfs_header_owner(leaf),
}; };
bytes_deleted += extent_num_bytes; bytes_deleted += extent_num_bytes;
btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), btrfs_init_data_ref(&ref, control->ino, extent_offset,
control->ino, extent_offset, root->root_key.objectid, false);
root->root_key.objectid, false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
......
...@@ -684,10 +684,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info, ...@@ -684,10 +684,10 @@ int btrfs_ref_tree_mod(struct btrfs_fs_info *fs_info,
if (generic_ref->type == BTRFS_REF_METADATA) { if (generic_ref->type == BTRFS_REF_METADATA) {
if (!parent) if (!parent)
ref_root = generic_ref->tree_ref.ref_root; ref_root = generic_ref->ref_root;
owner = generic_ref->tree_ref.level; owner = generic_ref->tree_ref.level;
} else if (!parent) { } else if (!parent) {
ref_root = generic_ref->data_ref.ref_root; ref_root = generic_ref->ref_root;
owner = generic_ref->data_ref.ino; owner = generic_ref->data_ref.ino;
offset = generic_ref->data_ref.offset; offset = generic_ref->data_ref.offset;
} }
......
...@@ -1109,8 +1109,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans, ...@@ -1109,8 +1109,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
ref.len = num_bytes; ref.len = num_bytes;
ref.parent = parent; ref.parent = parent;
ref.owning_root = root->root_key.objectid; ref.owning_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), ref.ref_root = btrfs_header_owner(leaf);
key.objectid, key.offset, btrfs_init_data_ref(&ref, key.objectid, key.offset,
root->root_key.objectid, false); root->root_key.objectid, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (ret) {
...@@ -1123,8 +1123,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans, ...@@ -1123,8 +1123,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
ref.len = num_bytes; ref.len = num_bytes;
ref.parent = parent; ref.parent = parent;
ref.owning_root = root->root_key.objectid; ref.owning_root = root->root_key.objectid;
btrfs_init_data_ref(&ref, btrfs_header_owner(leaf), ref.ref_root = btrfs_header_owner(leaf);
key.objectid, key.offset, btrfs_init_data_ref(&ref, key.objectid, key.offset,
root->root_key.objectid, false); root->root_key.objectid, false);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
...@@ -1339,8 +1339,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1339,8 +1339,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
ref.len = blocksize; ref.len = blocksize;
ref.parent = path->nodes[level]->start; ref.parent = path->nodes[level]->start;
ref.owning_root = src->root_key.objectid; ref.owning_root = src->root_key.objectid;
btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid, ref.ref_root = src->root_key.objectid;
0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -1352,8 +1352,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1352,8 +1352,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
ref.len = blocksize; ref.len = blocksize;
ref.parent = 0; ref.parent = 0;
ref.owning_root = dest->root_key.objectid; ref.owning_root = dest->root_key.objectid;
btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, 0, ref.ref_root = dest->root_key.objectid;
true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -1366,8 +1366,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1366,8 +1366,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
ref.len = blocksize; ref.len = blocksize;
ref.parent = path->nodes[level]->start; ref.parent = path->nodes[level]->start;
ref.owning_root = 0; ref.owning_root = 0;
btrfs_init_tree_ref(&ref, level - 1, src->root_key.objectid, ref.ref_root = src->root_key.objectid;
0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -1380,8 +1380,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, ...@@ -1380,8 +1380,8 @@ int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc,
ref.len = blocksize; ref.len = blocksize;
ref.parent = 0; ref.parent = 0;
ref.owning_root = 0; ref.owning_root = 0;
btrfs_init_tree_ref(&ref, level - 1, dest->root_key.objectid, ref.ref_root = dest->root_key.objectid;
0, true); btrfs_init_tree_ref(&ref, level - 1, 0, true);
ret = btrfs_free_extent(trans, &ref); ret = btrfs_free_extent(trans, &ref);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
...@@ -2485,6 +2485,7 @@ static int do_relocation(struct btrfs_trans_handle *trans, ...@@ -2485,6 +2485,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
.len = blocksize, .len = blocksize,
.parent = upper->eb->start, .parent = upper->eb->start,
.owning_root = btrfs_header_owner(upper->eb), .owning_root = btrfs_header_owner(upper->eb),
.ref_root = btrfs_header_owner(upper->eb),
}; };
btrfs_set_node_blockptr(upper->eb, slot, btrfs_set_node_blockptr(upper->eb, slot,
...@@ -2494,7 +2495,6 @@ static int do_relocation(struct btrfs_trans_handle *trans, ...@@ -2494,7 +2495,6 @@ static int do_relocation(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(trans, upper->eb); btrfs_mark_buffer_dirty(trans, upper->eb);
btrfs_init_tree_ref(&ref, node->level, btrfs_init_tree_ref(&ref, node->level,
btrfs_header_owner(upper->eb),
root->root_key.objectid, false); root->root_key.objectid, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
if (!ret) if (!ret)
......
...@@ -766,10 +766,10 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, ...@@ -766,10 +766,10 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
.bytenr = ins.objectid, .bytenr = ins.objectid,
.len = ins.offset, .len = ins.offset,
.owning_root = root->root_key.objectid, .owning_root = root->root_key.objectid,
.ref_root = root->root_key.objectid,
}; };
btrfs_init_data_ref(&ref, btrfs_init_data_ref(&ref, key->objectid, offset,
root->root_key.objectid, 0, false);
key->objectid, offset, 0, false);
ret = btrfs_inc_extent_ref(trans, &ref); ret = btrfs_inc_extent_ref(trans, &ref);
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