diff options
author | Miao Xie <miaox@cn.fujitsu.com> | 2014-04-02 07:51:05 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-06-09 20:20:40 -0400 |
commit | 27cdeb7096b86f05ad018a24cdb63acdf0850a5d (patch) | |
tree | 1e795214fd0456f83c85843bea354d7331328bd1 /fs/btrfs/ctree.c | |
parent | f959492fc15b60d874a9cbf55ae4760f2ef261ed (diff) |
Btrfs: use bitfield instead of integer data type for the some variants in btrfs_root
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 1bcfcdb23cf4..2f10e12ae94c 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -224,7 +224,8 @@ static struct extent_buffer *btrfs_read_lock_root_node(struct btrfs_root *root) | |||
224 | static void add_root_to_dirty_list(struct btrfs_root *root) | 224 | static void add_root_to_dirty_list(struct btrfs_root *root) |
225 | { | 225 | { |
226 | spin_lock(&root->fs_info->trans_lock); | 226 | spin_lock(&root->fs_info->trans_lock); |
227 | if (root->track_dirty && list_empty(&root->dirty_list)) { | 227 | if (test_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state) && |
228 | list_empty(&root->dirty_list)) { | ||
228 | list_add(&root->dirty_list, | 229 | list_add(&root->dirty_list, |
229 | &root->fs_info->dirty_cowonly_roots); | 230 | &root->fs_info->dirty_cowonly_roots); |
230 | } | 231 | } |
@@ -246,9 +247,10 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, | |||
246 | int level; | 247 | int level; |
247 | struct btrfs_disk_key disk_key; | 248 | struct btrfs_disk_key disk_key; |
248 | 249 | ||
249 | WARN_ON(root->ref_cows && trans->transid != | 250 | WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && |
250 | root->fs_info->running_transaction->transid); | 251 | trans->transid != root->fs_info->running_transaction->transid); |
251 | WARN_ON(root->ref_cows && trans->transid != root->last_trans); | 252 | WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && |
253 | trans->transid != root->last_trans); | ||
252 | 254 | ||
253 | level = btrfs_header_level(buf); | 255 | level = btrfs_header_level(buf); |
254 | if (level == 0) | 256 | if (level == 0) |
@@ -997,14 +999,14 @@ int btrfs_block_can_be_shared(struct btrfs_root *root, | |||
997 | * snapshot and the block was not allocated by tree relocation, | 999 | * snapshot and the block was not allocated by tree relocation, |
998 | * we know the block is not shared. | 1000 | * we know the block is not shared. |
999 | */ | 1001 | */ |
1000 | if (root->ref_cows && | 1002 | if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) && |
1001 | buf != root->node && buf != root->commit_root && | 1003 | buf != root->node && buf != root->commit_root && |
1002 | (btrfs_header_generation(buf) <= | 1004 | (btrfs_header_generation(buf) <= |
1003 | btrfs_root_last_snapshot(&root->root_item) || | 1005 | btrfs_root_last_snapshot(&root->root_item) || |
1004 | btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC))) | 1006 | btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC))) |
1005 | return 1; | 1007 | return 1; |
1006 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 | 1008 | #ifdef BTRFS_COMPAT_EXTENT_TREE_V0 |
1007 | if (root->ref_cows && | 1009 | if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) && |
1008 | btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) | 1010 | btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) |
1009 | return 1; | 1011 | return 1; |
1010 | #endif | 1012 | #endif |
@@ -1146,9 +1148,10 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
1146 | 1148 | ||
1147 | btrfs_assert_tree_locked(buf); | 1149 | btrfs_assert_tree_locked(buf); |
1148 | 1150 | ||
1149 | WARN_ON(root->ref_cows && trans->transid != | 1151 | WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && |
1150 | root->fs_info->running_transaction->transid); | 1152 | trans->transid != root->fs_info->running_transaction->transid); |
1151 | WARN_ON(root->ref_cows && trans->transid != root->last_trans); | 1153 | WARN_ON(test_bit(BTRFS_ROOT_REF_COWS, &root->state) && |
1154 | trans->transid != root->last_trans); | ||
1152 | 1155 | ||
1153 | level = btrfs_header_level(buf); | 1156 | level = btrfs_header_level(buf); |
1154 | 1157 | ||
@@ -1193,7 +1196,7 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
1193 | return ret; | 1196 | return ret; |
1194 | } | 1197 | } |
1195 | 1198 | ||
1196 | if (root->ref_cows) { | 1199 | if (test_bit(BTRFS_ROOT_REF_COWS, &root->state)) { |
1197 | ret = btrfs_reloc_cow_block(trans, root, buf, cow); | 1200 | ret = btrfs_reloc_cow_block(trans, root, buf, cow); |
1198 | if (ret) | 1201 | if (ret) |
1199 | return ret; | 1202 | return ret; |
@@ -1556,7 +1559,7 @@ static inline int should_cow_block(struct btrfs_trans_handle *trans, | |||
1556 | !btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN) && | 1559 | !btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN) && |
1557 | !(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID && | 1560 | !(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID && |
1558 | btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)) && | 1561 | btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)) && |
1559 | !root->force_cow) | 1562 | !test_bit(BTRFS_ROOT_FORCE_COW, &root->state)) |
1560 | return 0; | 1563 | return 0; |
1561 | return 1; | 1564 | return 1; |
1562 | } | 1565 | } |