Skip to content

Commit fc64e7b

Browse files
fdmananakdave
authored andcommitted
btrfs: add btrfs prefix to is_fsstree() and make it return bool
This is an exported function and therefore it should have a 'btrfs_' prefix, to make it clear it's btrfs specific, avoid future name collisions with code outside btrfs, and make its naming consistent with most other btrfs exported functions. So add a 'btrfs_' prefix to it and make it return bool instead of int, since all we need is to return true or false. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent d488cf1 commit fc64e7b

File tree

10 files changed

+41
-40
lines changed

10 files changed

+41
-40
lines changed

fs/btrfs/ctree.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,13 +721,13 @@ static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p)
721721
}
722722
int btrfs_leaf_free_space(const struct extent_buffer *leaf);
723723

724-
static inline int is_fstree(u64 rootid)
724+
static inline bool btrfs_is_fstree(u64 rootid)
725725
{
726726
if (rootid == BTRFS_FS_TREE_OBJECTID ||
727727
((s64)rootid >= (s64)BTRFS_FIRST_FREE_OBJECTID &&
728728
!btrfs_qgroup_level(rootid)))
729-
return 1;
730-
return 0;
729+
return true;
730+
return false;
731731
}
732732

733733
static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root)

fs/btrfs/delayed-ref.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
928928
if (action == BTRFS_ADD_DELAYED_EXTENT)
929929
action = BTRFS_ADD_DELAYED_REF;
930930

931-
if (is_fstree(generic_ref->ref_root))
931+
if (btrfs_is_fstree(generic_ref->ref_root))
932932
seq = atomic64_read(&fs_info->tree_mod_seq);
933933

934934
refcount_set(&ref->refs, 1);
@@ -958,8 +958,8 @@ void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
958958
#endif
959959
generic_ref->tree_ref.level = level;
960960
generic_ref->type = BTRFS_REF_METADATA;
961-
if (skip_qgroup || !(is_fstree(generic_ref->ref_root) &&
962-
(!mod_root || is_fstree(mod_root))))
961+
if (skip_qgroup || !(btrfs_is_fstree(generic_ref->ref_root) &&
962+
(!mod_root || btrfs_is_fstree(mod_root))))
963963
generic_ref->skip_qgroup = true;
964964
else
965965
generic_ref->skip_qgroup = false;
@@ -976,8 +976,8 @@ void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ino, u64 offset,
976976
generic_ref->data_ref.objectid = ino;
977977
generic_ref->data_ref.offset = offset;
978978
generic_ref->type = BTRFS_REF_DATA;
979-
if (skip_qgroup || !(is_fstree(generic_ref->ref_root) &&
980-
(!mod_root || is_fstree(mod_root))))
979+
if (skip_qgroup || !(btrfs_is_fstree(generic_ref->ref_root) &&
980+
(!mod_root || btrfs_is_fstree(mod_root))))
981981
generic_ref->skip_qgroup = true;
982982
else
983983
generic_ref->skip_qgroup = false;

fs/btrfs/disk-io.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
884884
btrfs_set_root_used(&root->root_item, leaf->len);
885885
btrfs_set_root_last_snapshot(&root->root_item, 0);
886886
btrfs_set_root_dirid(&root->root_item, 0);
887-
if (is_fstree(objectid))
887+
if (btrfs_is_fstree(objectid))
888888
generate_random_guid(root->root_item.uuid);
889889
else
890890
export_guid(root->root_item.uuid, &guid_null);
@@ -1104,7 +1104,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)
11041104

11051105
if (btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID &&
11061106
!btrfs_is_data_reloc_root(root) &&
1107-
is_fstree(btrfs_root_id(root))) {
1107+
btrfs_is_fstree(btrfs_root_id(root))) {
11081108
set_bit(BTRFS_ROOT_SHAREABLE, &root->state);
11091109
btrfs_check_and_init_root_item(&root->root_item);
11101110
}
@@ -1113,7 +1113,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)
11131113
* Don't assign anonymous block device to roots that are not exposed to
11141114
* userspace, the id pool is limited to 1M
11151115
*/
1116-
if (is_fstree(btrfs_root_id(root)) &&
1116+
if (btrfs_is_fstree(btrfs_root_id(root)) &&
11171117
btrfs_root_refs(&root->root_item) > 0) {
11181118
if (!anon_dev) {
11191119
ret = get_anon_bdev(&root->anon_dev);
@@ -1317,7 +1317,7 @@ static struct btrfs_root *btrfs_get_root_ref(struct btrfs_fs_info *fs_info,
13171317
* This is namely for free-space-tree and quota tree, which can change
13181318
* at runtime and should only be grabbed from fs_info.
13191319
*/
1320-
if (!is_fstree(objectid) && objectid != BTRFS_DATA_RELOC_TREE_OBJECTID)
1320+
if (!btrfs_is_fstree(objectid) && objectid != BTRFS_DATA_RELOC_TREE_OBJECTID)
13211321
return ERR_PTR(-ENOENT);
13221322
again:
13231323
root = btrfs_lookup_fs_root(fs_info, objectid);

fs/btrfs/extent-tree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,7 @@ static void free_head_ref_squota_rsv(struct btrfs_fs_info *fs_info,
15451545
* where it has already been unset.
15461546
*/
15471547
if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_SIMPLE ||
1548-
!href->is_data || !is_fstree(root))
1548+
!href->is_data || !btrfs_is_fstree(root))
15491549
return;
15501550

15511551
btrfs_qgroup_free_refroot(fs_info, root, href->reserved_bytes,
@@ -4963,7 +4963,7 @@ int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
49634963

49644964
ASSERT(generic_ref.ref_root != BTRFS_TREE_LOG_OBJECTID);
49654965

4966-
if (btrfs_is_data_reloc_root(root) && is_fstree(root->relocation_src_root))
4966+
if (btrfs_is_data_reloc_root(root) && btrfs_is_fstree(root->relocation_src_root))
49674967
generic_ref.owning_root = root->relocation_src_root;
49684968

49694969
btrfs_init_data_ref(&generic_ref, owner, offset, 0, false);
@@ -5887,7 +5887,7 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
58875887
return ret;
58885888
}
58895889
}
5890-
if (is_fstree(btrfs_root_id(root))) {
5890+
if (btrfs_is_fstree(btrfs_root_id(root))) {
58915891
ret = btrfs_qgroup_trace_leaf_items(trans, eb);
58925892
if (ret) {
58935893
btrfs_err_rl(fs_info,

fs/btrfs/extent_map.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static void remove_em(struct btrfs_inode *inode, struct extent_map *em)
8484
rb_erase(&em->rb_node, &inode->extent_tree.root);
8585
RB_CLEAR_NODE(&em->rb_node);
8686

87-
if (!btrfs_is_testing(fs_info) && is_fstree(btrfs_root_id(inode->root)))
87+
if (!btrfs_is_testing(fs_info) && btrfs_is_fstree(btrfs_root_id(inode->root)))
8888
percpu_counter_dec(&fs_info->evictable_extent_maps);
8989
}
9090

@@ -502,7 +502,7 @@ static int add_extent_mapping(struct btrfs_inode *inode,
502502

503503
setup_extent_mapping(inode, em, modified);
504504

505-
if (!btrfs_is_testing(fs_info) && is_fstree(btrfs_root_id(root)))
505+
if (!btrfs_is_testing(fs_info) && btrfs_is_fstree(btrfs_root_id(root)))
506506
percpu_counter_inc(&fs_info->evictable_extent_maps);
507507

508508
return 0;
@@ -1337,7 +1337,7 @@ static void btrfs_extent_map_shrinker_worker(struct work_struct *work)
13371337
if (!root)
13381338
continue;
13391339

1340-
if (is_fstree(btrfs_root_id(root)))
1340+
if (btrfs_is_fstree(btrfs_root_id(root)))
13411341
nr_dropped += btrfs_scan_root(root, &ctx);
13421342

13431343
btrfs_put_root(root);

fs/btrfs/ioctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,7 +2889,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
28892889
ret = PTR_ERR(new_root);
28902890
goto out;
28912891
}
2892-
if (!is_fstree(btrfs_root_id(new_root))) {
2892+
if (!btrfs_is_fstree(btrfs_root_id(new_root))) {
28932893
ret = -ENOENT;
28942894
goto out_free;
28952895
}
@@ -3832,7 +3832,7 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
38323832
goto out;
38333833
}
38343834

3835-
if (sa->create && is_fstree(sa->qgroupid)) {
3835+
if (sa->create && btrfs_is_fstree(sa->qgroupid)) {
38363836
ret = -EINVAL;
38373837
goto out;
38383838
}

fs/btrfs/qgroup.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
482482
* during mount before we start doing things like creating
483483
* subvolumes.
484484
*/
485-
if (is_fstree(qgroup->qgroupid) &&
485+
if (btrfs_is_fstree(qgroup->qgroupid) &&
486486
qgroup->qgroupid > tree_root->free_objectid)
487487
/*
488488
* Don't need to check against BTRFS_LAST_FREE_OBJECTID,
@@ -1878,7 +1878,8 @@ int btrfs_qgroup_cleanup_dropped_subvolume(struct btrfs_fs_info *fs_info, u64 su
18781878
struct btrfs_trans_handle *trans;
18791879
int ret;
18801880

1881-
if (!is_fstree(subvolid) || !btrfs_qgroup_enabled(fs_info) || !fs_info->quota_root)
1881+
if (!btrfs_is_fstree(subvolid) || !btrfs_qgroup_enabled(fs_info) ||
1882+
!fs_info->quota_root)
18821883
return 0;
18831884

18841885
/*
@@ -2932,7 +2933,7 @@ static int maybe_fs_roots(struct ulist *roots)
29322933
* trees.
29332934
* If it contains a non-fs tree, it won't be shared with fs/subvol trees.
29342935
*/
2935-
return is_fstree(unode->val);
2936+
return btrfs_is_fstree(unode->val);
29362937
}
29372938

29382939
int btrfs_qgroup_account_extent(struct btrfs_trans_handle *trans, u64 bytenr,
@@ -3591,7 +3592,7 @@ static int qgroup_reserve(struct btrfs_root *root, u64 num_bytes, bool enforce,
35913592
int ret = 0;
35923593
LIST_HEAD(qgroup_list);
35933594

3594-
if (!is_fstree(ref_root))
3595+
if (!btrfs_is_fstree(ref_root))
35953596
return 0;
35963597

35973598
if (num_bytes == 0)
@@ -3651,7 +3652,7 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
36513652
struct btrfs_qgroup *qgroup;
36523653
LIST_HEAD(qgroup_list);
36533654

3654-
if (!is_fstree(ref_root))
3655+
if (!btrfs_is_fstree(ref_root))
36553656
return;
36563657

36573658
if (num_bytes == 0)
@@ -4219,7 +4220,7 @@ static int qgroup_reserve_data(struct btrfs_inode *inode,
42194220
int ret;
42204221

42214222
if (btrfs_qgroup_mode(root->fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
4222-
!is_fstree(btrfs_root_id(root)) || len == 0)
4223+
!btrfs_is_fstree(btrfs_root_id(root)) || len == 0)
42234224
return 0;
42244225

42254226
/* @reserved parameter is mandatory for qgroup */
@@ -4472,7 +4473,7 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
44724473
int ret;
44734474

44744475
if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
4475-
!is_fstree(btrfs_root_id(root)) || num_bytes == 0)
4476+
!btrfs_is_fstree(btrfs_root_id(root)) || num_bytes == 0)
44764477
return 0;
44774478

44784479
BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
@@ -4517,7 +4518,7 @@ void btrfs_qgroup_free_meta_all_pertrans(struct btrfs_root *root)
45174518
struct btrfs_fs_info *fs_info = root->fs_info;
45184519

45194520
if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
4520-
!is_fstree(btrfs_root_id(root)))
4521+
!btrfs_is_fstree(btrfs_root_id(root)))
45214522
return;
45224523

45234524
/* TODO: Update trace point to handle such free */
@@ -4533,7 +4534,7 @@ void __btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes,
45334534
struct btrfs_fs_info *fs_info = root->fs_info;
45344535

45354536
if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
4536-
!is_fstree(btrfs_root_id(root)))
4537+
!btrfs_is_fstree(btrfs_root_id(root)))
45374538
return;
45384539

45394540
/*
@@ -4592,7 +4593,7 @@ void btrfs_qgroup_convert_reserved_meta(struct btrfs_root *root, int num_bytes)
45924593
struct btrfs_fs_info *fs_info = root->fs_info;
45934594

45944595
if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
4595-
!is_fstree(btrfs_root_id(root)))
4596+
!btrfs_is_fstree(btrfs_root_id(root)))
45964597
return;
45974598
/* Same as btrfs_qgroup_free_meta_prealloc() */
45984599
num_bytes = sub_root_meta_rsv(root, num_bytes,
@@ -4818,7 +4819,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,
48184819

48194820
if (!btrfs_qgroup_full_accounting(fs_info))
48204821
return 0;
4821-
if (!is_fstree(btrfs_root_id(root)) || !root->reloc_root)
4822+
if (!btrfs_is_fstree(btrfs_root_id(root)) || !root->reloc_root)
48224823
return 0;
48234824

48244825
spin_lock(&blocks->lock);
@@ -4902,7 +4903,7 @@ int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
49024903
if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_SIMPLE)
49034904
return 0;
49044905

4905-
if (!is_fstree(root))
4906+
if (!btrfs_is_fstree(root))
49064907
return 0;
49074908

49084909
/* If the extent predates enabling quotas, don't count it. */

fs/btrfs/relocation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2625,7 +2625,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
26252625
* tree.
26262626
*/
26272627
if (block->owner &&
2628-
(!is_fstree(block->owner) ||
2628+
(!btrfs_is_fstree(block->owner) ||
26292629
block->owner == BTRFS_DATA_RELOC_TREE_OBJECTID)) {
26302630
ret = relocate_cowonly_block(trans, rc, block, path);
26312631
if (ret)

fs/btrfs/tree-checker.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static bool check_prev_ino(struct extent_buffer *leaf,
191191
* Only subvolume trees along with their reloc trees need this check.
192192
* Things like log tree doesn't follow this ino requirement.
193193
*/
194-
if (!is_fstree(btrfs_header_owner(leaf)))
194+
if (!btrfs_is_fstree(btrfs_header_owner(leaf)))
195195
return true;
196196

197197
if (key->objectid == prev_key->objectid)
@@ -475,7 +475,7 @@ static int check_root_key(struct extent_buffer *leaf, struct btrfs_key *key,
475475
* to be COWed to be relocated.
476476
*/
477477
if (unlikely(is_root_item && key->objectid == BTRFS_TREE_RELOC_OBJECTID &&
478-
!is_fstree(key->offset))) {
478+
!btrfs_is_fstree(key->offset))) {
479479
generic_err(leaf, slot,
480480
"invalid reloc tree for root %lld, root id is not a subvolume tree",
481481
key->offset);
@@ -493,7 +493,7 @@ static int check_root_key(struct extent_buffer *leaf, struct btrfs_key *key,
493493
}
494494

495495
/* DIR_ITEM/INDEX/INODE_REF is not allowed to point to non-fs trees */
496-
if (unlikely(!is_fstree(key->objectid) && !is_root_item)) {
496+
if (unlikely(!btrfs_is_fstree(key->objectid) && !is_root_item)) {
497497
dir_item_err(leaf, slot,
498498
"invalid location key objectid, have %llu expect [%llu, %llu]",
499499
key->objectid, BTRFS_FIRST_FREE_OBJECTID,
@@ -1311,7 +1311,7 @@ static bool is_valid_dref_root(u64 rootid)
13111311
* - tree root
13121312
* For v1 space cache
13131313
*/
1314-
return is_fstree(rootid) || rootid == BTRFS_DATA_RELOC_TREE_OBJECTID ||
1314+
return btrfs_is_fstree(rootid) || rootid == BTRFS_DATA_RELOC_TREE_OBJECTID ||
13151315
rootid == BTRFS_ROOT_TREE_OBJECTID;
13161316
}
13171317

@@ -2167,7 +2167,7 @@ ALLOW_ERROR_INJECTION(btrfs_check_node, ERRNO);
21672167

21682168
int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner)
21692169
{
2170-
const bool is_subvol = is_fstree(root_owner);
2170+
const bool is_subvol = btrfs_is_fstree(root_owner);
21712171
const u64 eb_owner = btrfs_header_owner(eb);
21722172

21732173
/*
@@ -2209,7 +2209,7 @@ int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner)
22092209
* For subvolume trees, owners can mismatch, but they should all belong
22102210
* to subvolume trees.
22112211
*/
2212-
if (unlikely(is_subvol != is_fstree(eb_owner))) {
2212+
if (unlikely(is_subvol != btrfs_is_fstree(eb_owner))) {
22132213
btrfs_crit(eb->fs_info,
22142214
"corrupted %s, root=%llu block=%llu owner mismatch, have %llu expect [%llu, %llu]",
22152215
btrfs_header_level(eb) == 0 ? "leaf" : "node",

fs/btrfs/tree-log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static struct btrfs_inode *btrfs_iget_logging(u64 objectid, struct btrfs_root *r
144144
struct btrfs_inode *inode;
145145

146146
/* Only meant to be called for subvolume roots and not for log roots. */
147-
ASSERT(is_fstree(btrfs_root_id(root)));
147+
ASSERT(btrfs_is_fstree(btrfs_root_id(root)));
148148

149149
/*
150150
* We're holding a transaction handle whether we are logging or

0 commit comments

Comments
 (0)