Commit 92a7cc42 authored by Qu Wenruo's avatar Qu Wenruo Committed by David Sterba

btrfs: rename BTRFS_ROOT_REF_COWS to BTRFS_ROOT_SHAREABLE

The name BTRFS_ROOT_REF_COWS is not very clear about the meaning.

In fact, that bit can only be set to those trees:

- Subvolume roots
- Data reloc root
- Reloc roots for above roots

All other trees won't get this bit set.  So just by the result, it is
obvious that, roots with this bit set can have tree blocks shared with
other trees.  Either shared by snapshots, or by reloc roots (an special
snapshot created by relocation).

This patch will rename BTRFS_ROOT_REF_COWS to BTRFS_ROOT_SHAREABLE to
make it easier to understand, and update all comment mentioning
"reference counted" to follow the rename.
Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ae3e715f
...@@ -2702,7 +2702,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache, ...@@ -2702,7 +2702,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
root = btrfs_get_fs_root(fs_info, &root_key, false); root = btrfs_get_fs_root(fs_info, &root_key, false);
if (IS_ERR(root)) if (IS_ERR(root))
return PTR_ERR(root); return PTR_ERR(root);
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
cur->cowonly = 1; cur->cowonly = 1;
if (btrfs_root_level(&root->root_item) == cur->level) { if (btrfs_root_level(&root->root_item) == cur->level) {
...@@ -2789,7 +2789,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache, ...@@ -2789,7 +2789,7 @@ static int handle_indirect_tree_backref(struct btrfs_backref_cache *cache,
goto out; goto out;
} }
upper->owner = btrfs_header_owner(eb); upper->owner = btrfs_header_owner(eb);
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
upper->cowonly = 1; upper->cowonly = 1;
/* /*
......
...@@ -184,7 +184,7 @@ struct btrfs_backref_node { ...@@ -184,7 +184,7 @@ struct btrfs_backref_node {
struct extent_buffer *eb; struct extent_buffer *eb;
/* Level of the tree block */ /* Level of the tree block */
unsigned int level:8; unsigned int level:8;
/* Is the block in non-reference counted tree */ /* Is the block in a non-shareable tree */
unsigned int cowonly:1; unsigned int cowonly:1;
/* 1 if no child node is in the cache */ /* 1 if no child node is in the cache */
unsigned int lowest:1; unsigned int lowest:1;
......
...@@ -458,7 +458,7 @@ static struct btrfs_block_rsv *get_block_rsv( ...@@ -458,7 +458,7 @@ static struct btrfs_block_rsv *get_block_rsv(
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct btrfs_block_rsv *block_rsv = NULL; struct btrfs_block_rsv *block_rsv = NULL;
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) || if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
(root == fs_info->csum_root && trans->adding_csums) || (root == fs_info->csum_root && trans->adding_csums) ||
(root == fs_info->uuid_root)) (root == fs_info->uuid_root))
block_rsv = trans->block_rsv; block_rsv = trans->block_rsv;
......
...@@ -144,9 +144,10 @@ struct extent_buffer *btrfs_root_node(struct btrfs_root *root) ...@@ -144,9 +144,10 @@ struct extent_buffer *btrfs_root_node(struct btrfs_root *root)
return eb; return eb;
} }
/* cowonly root (everything not a reference counted cow subvolume), just get /*
* put onto a simple dirty list. transaction.c walks this to make sure they * Cowonly root (not-shareable trees, everything not subvolume or reloc roots),
* get properly updated on disk. * just get put onto a simple dirty list. Transaction walks this list to make
* sure they get properly updated on disk.
*/ */
static void add_root_to_dirty_list(struct btrfs_root *root) static void add_root_to_dirty_list(struct btrfs_root *root)
{ {
...@@ -185,9 +186,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, ...@@ -185,9 +186,9 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
int level; int level;
struct btrfs_disk_key disk_key; struct btrfs_disk_key disk_key;
WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
trans->transid != fs_info->running_transaction->transid); trans->transid != fs_info->running_transaction->transid);
WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
trans->transid != root->last_trans); trans->transid != root->last_trans);
level = btrfs_header_level(buf); level = btrfs_header_level(buf);
...@@ -826,12 +827,11 @@ int btrfs_block_can_be_shared(struct btrfs_root *root, ...@@ -826,12 +827,11 @@ int btrfs_block_can_be_shared(struct btrfs_root *root,
struct extent_buffer *buf) struct extent_buffer *buf)
{ {
/* /*
* Tree blocks not in reference counted trees and tree roots * Tree blocks not in shareable trees and tree roots are never shared.
* are never shared. If a block was allocated after the last * If a block was allocated after the last snapshot and the block was
* snapshot and the block was not allocated by tree relocation, * not allocated by tree relocation, we know the block is not shared.
* we know the block is not shared.
*/ */
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) && if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
buf != root->node && buf != root->commit_root && buf != root->node && buf != root->commit_root &&
(btrfs_header_generation(buf) <= (btrfs_header_generation(buf) <=
btrfs_root_last_snapshot(&root->root_item) || btrfs_root_last_snapshot(&root->root_item) ||
...@@ -1024,9 +1024,9 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, ...@@ -1024,9 +1024,9 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
btrfs_assert_tree_locked(buf); btrfs_assert_tree_locked(buf);
WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
trans->transid != fs_info->running_transaction->transid); trans->transid != fs_info->running_transaction->transid);
WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && WARN_ON(test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
trans->transid != root->last_trans); trans->transid != root->last_trans);
level = btrfs_header_level(buf); level = btrfs_header_level(buf);
...@@ -1065,7 +1065,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, ...@@ -1065,7 +1065,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) { if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) {
ret = btrfs_reloc_cow_block(trans, root, buf, cow); ret = btrfs_reloc_cow_block(trans, root, buf, cow);
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
......
...@@ -969,7 +969,28 @@ enum { ...@@ -969,7 +969,28 @@ enum {
* is used to tell us when more checks are required * is used to tell us when more checks are required
*/ */
BTRFS_ROOT_IN_TRANS_SETUP, BTRFS_ROOT_IN_TRANS_SETUP,
BTRFS_ROOT_REF_COWS,
/*
* Set if tree blocks of this root can be shared by other roots.
* Only subvolume trees and their reloc trees have this bit set.
* Conflicts with TRACK_DIRTY bit.
*
* This affects two things:
*
* - How balance works
* For shareable roots, we need to use reloc tree and do path
* replacement for balance, and need various pre/post hooks for
* snapshot creation to handle them.
*
* While for non-shareable trees, we just simply do a tree search
* with COW.
*
* - How dirty roots are tracked
* For shareable roots, btrfs_record_root_in_trans() is needed to
* track them, while non-subvolume roots have TRACK_DIRTY bit, they
* don't need to set this manually.
*/
BTRFS_ROOT_SHAREABLE,
BTRFS_ROOT_TRACK_DIRTY, BTRFS_ROOT_TRACK_DIRTY,
BTRFS_ROOT_IN_RADIX, BTRFS_ROOT_IN_RADIX,
BTRFS_ROOT_ORPHAN_ITEM_INSERTED, BTRFS_ROOT_ORPHAN_ITEM_INSERTED,
...@@ -1055,7 +1076,7 @@ struct btrfs_root { ...@@ -1055,7 +1076,7 @@ struct btrfs_root {
struct btrfs_key defrag_progress; struct btrfs_key defrag_progress;
struct btrfs_key defrag_max; struct btrfs_key defrag_max;
/* the dirty list is only used by non-reference counted roots */ /* The dirty list is only used by non-shareable roots */
struct list_head dirty_list; struct list_head dirty_list;
struct list_head root_list; struct list_head root_list;
......
...@@ -1273,12 +1273,13 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, ...@@ -1273,12 +1273,13 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
root->root_key.offset = BTRFS_TREE_LOG_OBJECTID; root->root_key.offset = BTRFS_TREE_LOG_OBJECTID;
/* /*
* DON'T set REF_COWS for log trees * DON'T set SHAREABLE bit for log trees.
* *
* log trees do not get reference counted because they go away * Log trees are not exposed to user space thus can't be snapshotted,
* before a real commit is actually done. They do store pointers * and they go away before a real commit is actually done.
* to file data extents, and those reference counts still get *
* updated (along with back refs to the log tree). * They do store pointers to file data extents, and those reference
* counts still get updated (along with back refs to the log tree).
*/ */
leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID,
...@@ -1417,7 +1418,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root) ...@@ -1417,7 +1418,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root)
goto fail; goto fail;
if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) { if (root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
set_bit(BTRFS_ROOT_REF_COWS, &root->state); set_bit(BTRFS_ROOT_SHAREABLE, &root->state);
btrfs_check_and_init_root_item(&root->root_item); btrfs_check_and_init_root_item(&root->root_item);
} }
......
...@@ -2426,7 +2426,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, ...@@ -2426,7 +2426,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
nritems = btrfs_header_nritems(buf); nritems = btrfs_header_nritems(buf);
level = btrfs_header_level(buf); level = btrfs_header_level(buf);
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state) && level == 0) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state) && level == 0)
return 0; return 0;
if (full_backref) if (full_backref)
......
...@@ -775,7 +775,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans, ...@@ -775,7 +775,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent) if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent)
modify_tree = 0; modify_tree = 0;
update_refs = (test_bit(BTRFS_ROOT_REF_COWS, &root->state) || update_refs = (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
root == fs_info->tree_root); root == fs_info->tree_root);
while (1) { while (1) {
recow = 0; recow = 0;
......
...@@ -4100,11 +4100,12 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4100,11 +4100,12 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY);
/* /*
* for non-free space inodes and ref cows, we want to back off from * For non-free space inodes and non-shareable roots, we want to back
* time to time * off from time to time. This means all inodes in subvolume roots,
* reloc roots, and data reloc roots.
*/ */
if (!btrfs_is_free_space_inode(BTRFS_I(inode)) && if (!btrfs_is_free_space_inode(BTRFS_I(inode)) &&
test_bit(BTRFS_ROOT_REF_COWS, &root->state)) test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
be_nice = true; be_nice = true;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
...@@ -4121,7 +4122,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4121,7 +4122,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
* not block aligned since we will be keeping the last block of the * not block aligned since we will be keeping the last block of the
* extent just the way it is. * extent just the way it is.
*/ */
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) || if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
root == fs_info->tree_root) root == fs_info->tree_root)
btrfs_drop_extent_cache(BTRFS_I(inode), ALIGN(new_size, btrfs_drop_extent_cache(BTRFS_I(inode), ALIGN(new_size,
fs_info->sectorsize), fs_info->sectorsize),
...@@ -4233,7 +4234,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4233,7 +4234,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
extent_num_bytes); extent_num_bytes);
num_dec = (orig_num_bytes - num_dec = (orig_num_bytes -
extent_num_bytes); extent_num_bytes);
if (test_bit(BTRFS_ROOT_REF_COWS, if (test_bit(BTRFS_ROOT_SHAREABLE,
&root->state) && &root->state) &&
extent_start != 0) extent_start != 0)
inode_sub_bytes(inode, num_dec); inode_sub_bytes(inode, num_dec);
...@@ -4249,7 +4250,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4249,7 +4250,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
num_dec = btrfs_file_extent_num_bytes(leaf, fi); num_dec = btrfs_file_extent_num_bytes(leaf, fi);
if (extent_start != 0) { if (extent_start != 0) {
found_extent = 1; found_extent = 1;
if (test_bit(BTRFS_ROOT_REF_COWS, if (test_bit(BTRFS_ROOT_SHAREABLE,
&root->state)) &root->state))
inode_sub_bytes(inode, num_dec); inode_sub_bytes(inode, num_dec);
} }
...@@ -4285,7 +4286,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4285,7 +4286,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
clear_len = fs_info->sectorsize; clear_len = fs_info->sectorsize;
} }
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
inode_sub_bytes(inode, item_end + 1 - new_size); inode_sub_bytes(inode, item_end + 1 - new_size);
} }
delete: delete:
...@@ -4326,7 +4327,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, ...@@ -4326,7 +4327,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
should_throttle = false; should_throttle = false;
if (found_extent && if (found_extent &&
(test_bit(BTRFS_ROOT_REF_COWS, &root->state) || (test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
root == fs_info->tree_root)) { root == fs_info->tree_root)) {
struct btrfs_ref ref = { 0 }; struct btrfs_ref ref = { 0 };
......
...@@ -750,7 +750,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir, ...@@ -750,7 +750,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
int ret; int ret;
bool snapshot_force_cow = false; bool snapshot_force_cow = false;
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
return -EINVAL; return -EINVAL;
if (atomic_read(&root->nr_swapfiles)) { if (atomic_read(&root->nr_swapfiles)) {
......
...@@ -321,7 +321,7 @@ int btrfs_should_ignore_reloc_root(struct btrfs_root *root) ...@@ -321,7 +321,7 @@ int btrfs_should_ignore_reloc_root(struct btrfs_root *root)
{ {
struct btrfs_root *reloc_root; struct btrfs_root *reloc_root;
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
return 0; return 0;
/* This root has been merged with its reloc tree, we can ignore it */ /* This root has been merged with its reloc tree, we can ignore it */
...@@ -808,7 +808,7 @@ static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans, ...@@ -808,7 +808,7 @@ static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans,
reloc_root = btrfs_read_tree_root(fs_info->tree_root, &root_key); reloc_root = btrfs_read_tree_root(fs_info->tree_root, &root_key);
BUG_ON(IS_ERR(reloc_root)); BUG_ON(IS_ERR(reloc_root));
set_bit(BTRFS_ROOT_REF_COWS, &reloc_root->state); set_bit(BTRFS_ROOT_SHAREABLE, &reloc_root->state);
reloc_root->last_trans = trans->transid; reloc_root->last_trans = trans->transid;
return reloc_root; return reloc_root;
} }
...@@ -2018,7 +2018,7 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans, ...@@ -2018,7 +2018,7 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
next = walk_up_backref(next, edges, &index); next = walk_up_backref(next, edges, &index);
root = next->root; root = next->root;
BUG_ON(!root); BUG_ON(!root);
BUG_ON(!test_bit(BTRFS_ROOT_REF_COWS, &root->state)); BUG_ON(!test_bit(BTRFS_ROOT_SHAREABLE, &root->state));
if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) { if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
record_reloc_root_in_trans(trans, root); record_reloc_root_in_trans(trans, root);
...@@ -2062,10 +2062,13 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans, ...@@ -2062,10 +2062,13 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
} }
/* /*
* select a tree root for relocation. return NULL if the block * Select a tree root for relocation.
* is reference counted. we should use do_relocation() in this *
* case. return a tree root pointer if the block isn't reference * Return NULL if the block is not shareable. We should use do_relocation() in
* counted. return -ENOENT if the block is root of reloc tree. * this case.
*
* Return a tree root pointer if the block is shareable.
* Return -ENOENT if the block is root of reloc tree.
*/ */
static noinline_for_stack static noinline_for_stack
struct btrfs_root *select_one_root(struct btrfs_backref_node *node) struct btrfs_root *select_one_root(struct btrfs_backref_node *node)
...@@ -2083,8 +2086,8 @@ struct btrfs_root *select_one_root(struct btrfs_backref_node *node) ...@@ -2083,8 +2086,8 @@ struct btrfs_root *select_one_root(struct btrfs_backref_node *node)
root = next->root; root = next->root;
BUG_ON(!root); BUG_ON(!root);
/* no other choice for non-references counted tree */ /* No other choice for non-shareable tree */
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
return root; return root;
if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID)
...@@ -2480,7 +2483,7 @@ static int relocate_tree_block(struct btrfs_trans_handle *trans, ...@@ -2480,7 +2483,7 @@ static int relocate_tree_block(struct btrfs_trans_handle *trans,
} }
if (root) { if (root) {
if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) { if (test_bit(BTRFS_ROOT_SHAREABLE, &root->state)) {
BUG_ON(node->new_bytenr); BUG_ON(node->new_bytenr);
BUG_ON(!list_empty(&node->list)); BUG_ON(!list_empty(&node->list));
btrfs_record_root_in_trans(trans, root); btrfs_record_root_in_trans(trans, root);
...@@ -3765,7 +3768,7 @@ int btrfs_recover_relocation(struct btrfs_root *root) ...@@ -3765,7 +3768,7 @@ int btrfs_recover_relocation(struct btrfs_root *root)
goto out; goto out;
} }
set_bit(BTRFS_ROOT_REF_COWS, &reloc_root->state); set_bit(BTRFS_ROOT_SHAREABLE, &reloc_root->state);
list_add(&reloc_root->root_list, &reloc_roots); list_add(&reloc_root->root_list, &reloc_roots);
if (btrfs_root_refs(&reloc_root->root_item) > 0) { if (btrfs_root_refs(&reloc_root->root_item) > 0) {
......
...@@ -349,10 +349,10 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info, ...@@ -349,10 +349,10 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
} }
/* /*
* this does all the record keeping required to make sure that a reference * This does all the record keeping required to make sure that a shareable root
* counted root is properly recorded in a given transaction. This is required * is properly recorded in a given transaction. This is required to make sure
* to make sure the old root from before we joined the transaction is deleted * the old root from before we joined the transaction is deleted when the
* when the transaction commits * transaction commits.
*/ */
static int record_root_in_trans(struct btrfs_trans_handle *trans, static int record_root_in_trans(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_root *root,
...@@ -360,7 +360,7 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans, ...@@ -360,7 +360,7 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans,
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
if ((test_bit(BTRFS_ROOT_REF_COWS, &root->state) && if ((test_bit(BTRFS_ROOT_SHAREABLE, &root->state) &&
root->last_trans < trans->transid) || force) { root->last_trans < trans->transid) || force) {
WARN_ON(root == fs_info->extent_root); WARN_ON(root == fs_info->extent_root);
WARN_ON(!force && root->commit_root != root->node); WARN_ON(!force && root->commit_root != root->node);
...@@ -439,7 +439,7 @@ int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans, ...@@ -439,7 +439,7 @@ int btrfs_record_root_in_trans(struct btrfs_trans_handle *trans,
{ {
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
return 0; return 0;
/* /*
...@@ -504,7 +504,7 @@ static inline bool need_reserve_reloc_root(struct btrfs_root *root) ...@@ -504,7 +504,7 @@ static inline bool need_reserve_reloc_root(struct btrfs_root *root)
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
if (!fs_info->reloc_ctl || if (!fs_info->reloc_ctl ||
!test_bit(BTRFS_ROOT_REF_COWS, &root->state) || !test_bit(BTRFS_ROOT_SHAREABLE, &root->state) ||
root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID || root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID ||
root->reloc_root) root->reloc_root)
return false; return false;
......
...@@ -35,7 +35,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, ...@@ -35,7 +35,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
goto out; goto out;
} }
if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) if (!test_bit(BTRFS_ROOT_SHAREABLE, &root->state))
goto out; goto out;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
......
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