diff options
author | David Sterba <dsterba@suse.cz> | 2014-09-29 17:53:21 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-10-02 11:30:33 -0400 |
commit | fccb84c94a9755f48668e43d0a44d6ecc750900f (patch) | |
tree | 7758746761316e21fca9c7c189f7082ff0866294 | |
parent | 7ec20afbcb7b257aec82ea5d66e6b0b7499abaca (diff) |
btrfs: move checks for DUMMY_ROOT into a helper
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r-- | fs/btrfs/ctree.c | 5 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 9 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 4 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 16 | ||||
-rw-r--r-- | fs/btrfs/qgroup.c | 10 |
5 files changed, 23 insertions, 21 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 533657c508e2..ce1d71d171bb 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -1506,10 +1506,9 @@ static inline int should_cow_block(struct btrfs_trans_handle *trans, | |||
1506 | struct btrfs_root *root, | 1506 | struct btrfs_root *root, |
1507 | struct extent_buffer *buf) | 1507 | struct extent_buffer *buf) |
1508 | { | 1508 | { |
1509 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 1509 | if (btrfs_test_is_dummy_root(root)) |
1510 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) | ||
1511 | return 0; | 1510 | return 0; |
1512 | #endif | 1511 | |
1513 | /* ensure we can see the force_cow */ | 1512 | /* ensure we can see the force_cow */ |
1514 | smp_rmb(); | 1513 | smp_rmb(); |
1515 | 1514 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index bae025a20e63..557fd9520607 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -4131,4 +4131,13 @@ int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid, | |||
4131 | u64 rfer, u64 excl); | 4131 | u64 rfer, u64 excl); |
4132 | #endif | 4132 | #endif |
4133 | 4133 | ||
4134 | static inline int btrfs_test_is_dummy_root(struct btrfs_root *root) | ||
4135 | { | ||
4136 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | ||
4137 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) | ||
4138 | return 1; | ||
4139 | #endif | ||
4140 | return 0; | ||
4141 | } | ||
4142 | |||
4134 | #endif | 4143 | #endif |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 0abf4b0a9010..14117f85b545 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1130,11 +1130,9 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | |||
1130 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, | 1130 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, |
1131 | u64 bytenr, u32 blocksize) | 1131 | u64 bytenr, u32 blocksize) |
1132 | { | 1132 | { |
1133 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 1133 | if (btrfs_test_is_dummy_root(root)) |
1134 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) | ||
1135 | return alloc_test_extent_buffer(root->fs_info, bytenr, | 1134 | return alloc_test_extent_buffer(root->fs_info, bytenr, |
1136 | blocksize); | 1135 | blocksize); |
1137 | #endif | ||
1138 | return alloc_extent_buffer(root->fs_info, bytenr, blocksize); | 1136 | return alloc_extent_buffer(root->fs_info, bytenr, blocksize); |
1139 | } | 1137 | } |
1140 | 1138 | ||
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 44d04979f071..7895db9c6bdc 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3073,10 +3073,10 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, | |||
3073 | int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *, | 3073 | int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *, |
3074 | u64, u64, u64, u64, u64, u64, int); | 3074 | u64, u64, u64, u64, u64, u64, int); |
3075 | 3075 | ||
3076 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 3076 | |
3077 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) | 3077 | if (btrfs_test_is_dummy_root(root)) |
3078 | return 0; | 3078 | return 0; |
3079 | #endif | 3079 | |
3080 | ref_root = btrfs_header_owner(buf); | 3080 | ref_root = btrfs_header_owner(buf); |
3081 | nritems = btrfs_header_nritems(buf); | 3081 | nritems = btrfs_header_nritems(buf); |
3082 | level = btrfs_header_level(buf); | 3082 | level = btrfs_header_level(buf); |
@@ -6264,10 +6264,9 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, | |||
6264 | int ret; | 6264 | int ret; |
6265 | struct btrfs_fs_info *fs_info = root->fs_info; | 6265 | struct btrfs_fs_info *fs_info = root->fs_info; |
6266 | 6266 | ||
6267 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 6267 | if (btrfs_test_is_dummy_root(root)) |
6268 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) | ||
6269 | return 0; | 6268 | return 0; |
6270 | #endif | 6269 | |
6271 | add_pinned_bytes(root->fs_info, num_bytes, owner, root_objectid); | 6270 | add_pinned_bytes(root->fs_info, num_bytes, owner, root_objectid); |
6272 | 6271 | ||
6273 | /* | 6272 | /* |
@@ -7336,15 +7335,14 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
7336 | bool skinny_metadata = btrfs_fs_incompat(root->fs_info, | 7335 | bool skinny_metadata = btrfs_fs_incompat(root->fs_info, |
7337 | SKINNY_METADATA); | 7336 | SKINNY_METADATA); |
7338 | 7337 | ||
7339 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 7338 | if (btrfs_test_is_dummy_root(root)) { |
7340 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) { | ||
7341 | buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr, | 7339 | buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr, |
7342 | blocksize, level); | 7340 | blocksize, level); |
7343 | if (!IS_ERR(buf)) | 7341 | if (!IS_ERR(buf)) |
7344 | root->alloc_bytenr += blocksize; | 7342 | root->alloc_bytenr += blocksize; |
7345 | return buf; | 7343 | return buf; |
7346 | } | 7344 | } |
7347 | #endif | 7345 | |
7348 | block_rsv = use_block_rsv(trans, root, blocksize); | 7346 | block_rsv = use_block_rsv(trans, root, blocksize); |
7349 | if (IS_ERR(block_rsv)) | 7347 | if (IS_ERR(block_rsv)) |
7350 | return ERR_CAST(block_rsv); | 7348 | return ERR_CAST(block_rsv); |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index cd9717ea8c9d..48b60dbf807f 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -539,10 +539,9 @@ static int add_qgroup_item(struct btrfs_trans_handle *trans, | |||
539 | struct extent_buffer *leaf; | 539 | struct extent_buffer *leaf; |
540 | struct btrfs_key key; | 540 | struct btrfs_key key; |
541 | 541 | ||
542 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 542 | if (btrfs_test_is_dummy_root(quota_root)) |
543 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, "a_root->state))) | ||
544 | return 0; | 543 | return 0; |
545 | #endif | 544 | |
546 | path = btrfs_alloc_path(); | 545 | path = btrfs_alloc_path(); |
547 | if (!path) | 546 | if (!path) |
548 | return -ENOMEM; | 547 | return -ENOMEM; |
@@ -698,10 +697,9 @@ static int update_qgroup_info_item(struct btrfs_trans_handle *trans, | |||
698 | int ret; | 697 | int ret; |
699 | int slot; | 698 | int slot; |
700 | 699 | ||
701 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 700 | if (btrfs_test_is_dummy_root(root)) |
702 | if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) | ||
703 | return 0; | 701 | return 0; |
704 | #endif | 702 | |
705 | key.objectid = 0; | 703 | key.objectid = 0; |
706 | key.type = BTRFS_QGROUP_INFO_KEY; | 704 | key.type = BTRFS_QGROUP_INFO_KEY; |
707 | key.offset = qgroup->qgroupid; | 705 | key.offset = qgroup->qgroupid; |