]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: add btrfs prefix to is_fstree() and make it return bool
authorFilipe Manana <fdmanana@suse.com>
Mon, 23 Jun 2025 12:13:23 +0000 (13:13 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 21:58:04 +0000 (23:58 +0200)
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.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/delayed-ref.c
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/extent_map.c
fs/btrfs/ioctl.c
fs/btrfs/qgroup.c
fs/btrfs/relocation.c
fs/btrfs/tree-checker.c
fs/btrfs/tree-log.c

index 8a54a0b6e502bb59e285e59b56ae5cdfed35fc2a..d51cc692f2c56902ff6c4eb83bb0af87ce0c5c4b 100644 (file)
@@ -721,13 +721,13 @@ static inline int btrfs_next_item(struct btrfs_root *root, struct btrfs_path *p)
 }
 int btrfs_leaf_free_space(const struct extent_buffer *leaf);
 
-static inline int is_fstree(u64 rootid)
+static inline bool btrfs_is_fstree(u64 rootid)
 {
        if (rootid == BTRFS_FS_TREE_OBJECTID ||
            ((s64)rootid >= (s64)BTRFS_FIRST_FREE_OBJECTID &&
              !btrfs_qgroup_level(rootid)))
-               return 1;
-       return 0;
+               return true;
+       return false;
 }
 
 static inline bool btrfs_is_data_reloc_root(const struct btrfs_root *root)
index 739c9e29aaa389b91e4cf1edde3d4fd2bb1ef5e6..ca382c5b186f47701b6820fadc74dee97142aa99 100644 (file)
@@ -928,7 +928,7 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
        if (action == BTRFS_ADD_DELAYED_EXTENT)
                action = BTRFS_ADD_DELAYED_REF;
 
-       if (is_fstree(generic_ref->ref_root))
+       if (btrfs_is_fstree(generic_ref->ref_root))
                seq = atomic64_read(&fs_info->tree_mod_seq);
 
        refcount_set(&ref->refs, 1);
@@ -958,8 +958,8 @@ void btrfs_init_tree_ref(struct btrfs_ref *generic_ref, int level, u64 mod_root,
 #endif
        generic_ref->tree_ref.level = level;
        generic_ref->type = BTRFS_REF_METADATA;
-       if (skip_qgroup || !(is_fstree(generic_ref->ref_root) &&
-                            (!mod_root || is_fstree(mod_root))))
+       if (skip_qgroup || !(btrfs_is_fstree(generic_ref->ref_root) &&
+                            (!mod_root || btrfs_is_fstree(mod_root))))
                generic_ref->skip_qgroup = true;
        else
                generic_ref->skip_qgroup = false;
@@ -976,8 +976,8 @@ void btrfs_init_data_ref(struct btrfs_ref *generic_ref, u64 ino, u64 offset,
        generic_ref->data_ref.objectid = ino;
        generic_ref->data_ref.offset = offset;
        generic_ref->type = BTRFS_REF_DATA;
-       if (skip_qgroup || !(is_fstree(generic_ref->ref_root) &&
-                            (!mod_root || is_fstree(mod_root))))
+       if (skip_qgroup || !(btrfs_is_fstree(generic_ref->ref_root) &&
+                            (!mod_root || btrfs_is_fstree(mod_root))))
                generic_ref->skip_qgroup = true;
        else
                generic_ref->skip_qgroup = false;
index 6ac5be02dce7581d1e302b8576c6c8d074c91df8..f6fa951c6be9eb312c9b4eb25dd54ec8512c900f 100644 (file)
@@ -884,7 +884,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
        btrfs_set_root_used(&root->root_item, leaf->len);
        btrfs_set_root_last_snapshot(&root->root_item, 0);
        btrfs_set_root_dirid(&root->root_item, 0);
-       if (is_fstree(objectid))
+       if (btrfs_is_fstree(objectid))
                generate_random_guid(root->root_item.uuid);
        else
                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)
 
        if (btrfs_root_id(root) != BTRFS_TREE_LOG_OBJECTID &&
            !btrfs_is_data_reloc_root(root) &&
-           is_fstree(btrfs_root_id(root))) {
+           btrfs_is_fstree(btrfs_root_id(root))) {
                set_bit(BTRFS_ROOT_SHAREABLE, &root->state);
                btrfs_check_and_init_root_item(&root->root_item);
        }
@@ -1113,7 +1113,7 @@ static int btrfs_init_fs_root(struct btrfs_root *root, dev_t anon_dev)
         * Don't assign anonymous block device to roots that are not exposed to
         * userspace, the id pool is limited to 1M
         */
-       if (is_fstree(btrfs_root_id(root)) &&
+       if (btrfs_is_fstree(btrfs_root_id(root)) &&
            btrfs_root_refs(&root->root_item) > 0) {
                if (!anon_dev) {
                        ret = get_anon_bdev(&root->anon_dev);
@@ -1315,7 +1315,7 @@ static struct btrfs_root *btrfs_get_root_ref(struct btrfs_fs_info *fs_info,
         * This is namely for free-space-tree and quota tree, which can change
         * at runtime and should only be grabbed from fs_info.
         */
-       if (!is_fstree(objectid) && objectid != BTRFS_DATA_RELOC_TREE_OBJECTID)
+       if (!btrfs_is_fstree(objectid) && objectid != BTRFS_DATA_RELOC_TREE_OBJECTID)
                return ERR_PTR(-ENOENT);
 again:
        root = btrfs_lookup_fs_root(fs_info, objectid);
index 10f50c725313e996484195099906b7967850fe05..85833bf216ded285223d58335675f7119a512e2c 100644 (file)
@@ -1545,7 +1545,7 @@ static void free_head_ref_squota_rsv(struct btrfs_fs_info *fs_info,
         * where it has already been unset.
         */
        if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_SIMPLE ||
-           !href->is_data || !is_fstree(root))
+           !href->is_data || !btrfs_is_fstree(root))
                return;
 
        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,
 
        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) && btrfs_is_fstree(root->relocation_src_root))
                generic_ref.owning_root = root->relocation_src_root;
 
        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,
                                        return ret;
                                }
                        }
-                       if (is_fstree(btrfs_root_id(root))) {
+                       if (btrfs_is_fstree(btrfs_root_id(root))) {
                                ret = btrfs_qgroup_trace_leaf_items(trans, eb);
                                if (ret) {
                                        btrfs_err_rl(fs_info,
index 02bfdb976e40ce0111bf73a5b228642b754410f9..57f52585a6dde9074b97cc52ae304ea9581cb55c 100644 (file)
@@ -84,7 +84,7 @@ static void remove_em(struct btrfs_inode *inode, struct extent_map *em)
        rb_erase(&em->rb_node, &inode->extent_tree.root);
        RB_CLEAR_NODE(&em->rb_node);
 
-       if (!btrfs_is_testing(fs_info) && is_fstree(btrfs_root_id(inode->root)))
+       if (!btrfs_is_testing(fs_info) && btrfs_is_fstree(btrfs_root_id(inode->root)))
                percpu_counter_dec(&fs_info->evictable_extent_maps);
 }
 
@@ -502,7 +502,7 @@ static int add_extent_mapping(struct btrfs_inode *inode,
 
        setup_extent_mapping(inode, em, modified);
 
-       if (!btrfs_is_testing(fs_info) && is_fstree(btrfs_root_id(root)))
+       if (!btrfs_is_testing(fs_info) && btrfs_is_fstree(btrfs_root_id(root)))
                percpu_counter_inc(&fs_info->evictable_extent_maps);
 
        return 0;
@@ -1337,7 +1337,7 @@ static void btrfs_extent_map_shrinker_worker(struct work_struct *work)
                if (!root)
                        continue;
 
-               if (is_fstree(btrfs_root_id(root)))
+               if (btrfs_is_fstree(btrfs_root_id(root)))
                        nr_dropped += btrfs_scan_root(root, &ctx);
 
                btrfs_put_root(root);
index aa8cefadf4239f07db4946d8323020446253efa1..c28db44cb5c4fc3a989e944670be93e93316f48a 100644 (file)
@@ -2889,7 +2889,7 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
                ret = PTR_ERR(new_root);
                goto out;
        }
-       if (!is_fstree(btrfs_root_id(new_root))) {
+       if (!btrfs_is_fstree(btrfs_root_id(new_root))) {
                ret = -ENOENT;
                goto out_free;
        }
@@ -3832,7 +3832,7 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg)
                goto out;
        }
 
-       if (sa->create && is_fstree(sa->qgroupid)) {
+       if (sa->create && btrfs_is_fstree(sa->qgroupid)) {
                ret = -EINVAL;
                goto out;
        }
index 7791000dcefcb74639569dfaf0920f5bfb7bac69..e38272ac808d9090c45c0cd8a943a602b42c6791 100644 (file)
@@ -482,7 +482,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
                         * during mount before we start doing things like creating
                         * subvolumes.
                         */
-                       if (is_fstree(qgroup->qgroupid) &&
+                       if (btrfs_is_fstree(qgroup->qgroupid) &&
                            qgroup->qgroupid > tree_root->free_objectid)
                                /*
                                 * 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
        struct btrfs_trans_handle *trans;
        int ret;
 
-       if (!is_fstree(subvolid) || !btrfs_qgroup_enabled(fs_info) || !fs_info->quota_root)
+       if (!btrfs_is_fstree(subvolid) || !btrfs_qgroup_enabled(fs_info) ||
+           !fs_info->quota_root)
                return 0;
 
        /*
@@ -2932,7 +2933,7 @@ static int maybe_fs_roots(struct ulist *roots)
         * trees.
         * If it contains a non-fs tree, it won't be shared with fs/subvol trees.
         */
-       return is_fstree(unode->val);
+       return btrfs_is_fstree(unode->val);
 }
 
 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,
        int ret = 0;
        LIST_HEAD(qgroup_list);
 
-       if (!is_fstree(ref_root))
+       if (!btrfs_is_fstree(ref_root))
                return 0;
 
        if (num_bytes == 0)
@@ -3651,7 +3652,7 @@ void btrfs_qgroup_free_refroot(struct btrfs_fs_info *fs_info,
        struct btrfs_qgroup *qgroup;
        LIST_HEAD(qgroup_list);
 
-       if (!is_fstree(ref_root))
+       if (!btrfs_is_fstree(ref_root))
                return;
 
        if (num_bytes == 0)
@@ -4219,7 +4220,7 @@ static int qgroup_reserve_data(struct btrfs_inode *inode,
        int ret;
 
        if (btrfs_qgroup_mode(root->fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
-           !is_fstree(btrfs_root_id(root)) || len == 0)
+           !btrfs_is_fstree(btrfs_root_id(root)) || len == 0)
                return 0;
 
        /* @reserved parameter is mandatory for qgroup */
@@ -4472,7 +4473,7 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
        int ret;
 
        if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
-           !is_fstree(btrfs_root_id(root)) || num_bytes == 0)
+           !btrfs_is_fstree(btrfs_root_id(root)) || num_bytes == 0)
                return 0;
 
        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)
        struct btrfs_fs_info *fs_info = root->fs_info;
 
        if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
-           !is_fstree(btrfs_root_id(root)))
+           !btrfs_is_fstree(btrfs_root_id(root)))
                return;
 
        /* TODO: Update trace point to handle such free */
@@ -4533,7 +4534,7 @@ void __btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes,
        struct btrfs_fs_info *fs_info = root->fs_info;
 
        if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
-           !is_fstree(btrfs_root_id(root)))
+           !btrfs_is_fstree(btrfs_root_id(root)))
                return;
 
        /*
@@ -4592,7 +4593,7 @@ void btrfs_qgroup_convert_reserved_meta(struct btrfs_root *root, int num_bytes)
        struct btrfs_fs_info *fs_info = root->fs_info;
 
        if (btrfs_qgroup_mode(fs_info) == BTRFS_QGROUP_MODE_DISABLED ||
-           !is_fstree(btrfs_root_id(root)))
+           !btrfs_is_fstree(btrfs_root_id(root)))
                return;
        /* Same as btrfs_qgroup_free_meta_prealloc() */
        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,
 
        if (!btrfs_qgroup_full_accounting(fs_info))
                return 0;
-       if (!is_fstree(btrfs_root_id(root)) || !root->reloc_root)
+       if (!btrfs_is_fstree(btrfs_root_id(root)) || !root->reloc_root)
                return 0;
 
        spin_lock(&blocks->lock);
@@ -4902,7 +4903,7 @@ int btrfs_record_squota_delta(struct btrfs_fs_info *fs_info,
        if (btrfs_qgroup_mode(fs_info) != BTRFS_QGROUP_MODE_SIMPLE)
                return 0;
 
-       if (!is_fstree(root))
+       if (!btrfs_is_fstree(root))
                return 0;
 
        /* If the extent predates enabling quotas, don't count it. */
index d7ec1d72821c266e65c79642d47905df423ed960..2670c0eb3cdaf3b7cd369ac0794ffb143cb1db04 100644 (file)
@@ -2625,7 +2625,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
                 * tree.
                 */
                if (block->owner &&
-                   (!is_fstree(block->owner) ||
+                   (!btrfs_is_fstree(block->owner) ||
                     block->owner == BTRFS_DATA_RELOC_TREE_OBJECTID)) {
                        ret = relocate_cowonly_block(trans, rc, block, path);
                        if (ret)
index 8f4703b488b71d3a59687796896b95a0f23f70b5..0f556f4de3f924bfe41615e4f3a32ad0789a4a34 100644 (file)
@@ -191,7 +191,7 @@ static bool check_prev_ino(struct extent_buffer *leaf,
         * Only subvolume trees along with their reloc trees need this check.
         * Things like log tree doesn't follow this ino requirement.
         */
-       if (!is_fstree(btrfs_header_owner(leaf)))
+       if (!btrfs_is_fstree(btrfs_header_owner(leaf)))
                return true;
 
        if (key->objectid == prev_key->objectid)
@@ -475,7 +475,7 @@ static int check_root_key(struct extent_buffer *leaf, struct btrfs_key *key,
         * to be COWed to be relocated.
         */
        if (unlikely(is_root_item && key->objectid == BTRFS_TREE_RELOC_OBJECTID &&
-                    !is_fstree(key->offset))) {
+                    !btrfs_is_fstree(key->offset))) {
                generic_err(leaf, slot,
                "invalid reloc tree for root %lld, root id is not a subvolume tree",
                            key->offset);
@@ -493,7 +493,7 @@ static int check_root_key(struct extent_buffer *leaf, struct btrfs_key *key,
        }
 
        /* DIR_ITEM/INDEX/INODE_REF is not allowed to point to non-fs trees */
-       if (unlikely(!is_fstree(key->objectid) && !is_root_item)) {
+       if (unlikely(!btrfs_is_fstree(key->objectid) && !is_root_item)) {
                dir_item_err(leaf, slot,
                "invalid location key objectid, have %llu expect [%llu, %llu]",
                                key->objectid, BTRFS_FIRST_FREE_OBJECTID,
@@ -1311,7 +1311,7 @@ static bool is_valid_dref_root(u64 rootid)
         * - tree root
         *   For v1 space cache
         */
-       return is_fstree(rootid) || rootid == BTRFS_DATA_RELOC_TREE_OBJECTID ||
+       return btrfs_is_fstree(rootid) || rootid == BTRFS_DATA_RELOC_TREE_OBJECTID ||
               rootid == BTRFS_ROOT_TREE_OBJECTID;
 }
 
@@ -2167,7 +2167,7 @@ ALLOW_ERROR_INJECTION(btrfs_check_node, ERRNO);
 
 int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner)
 {
-       const bool is_subvol = is_fstree(root_owner);
+       const bool is_subvol = btrfs_is_fstree(root_owner);
        const u64 eb_owner = btrfs_header_owner(eb);
 
        /*
@@ -2209,7 +2209,7 @@ int btrfs_check_eb_owner(const struct extent_buffer *eb, u64 root_owner)
         * For subvolume trees, owners can mismatch, but they should all belong
         * to subvolume trees.
         */
-       if (unlikely(is_subvol != is_fstree(eb_owner))) {
+       if (unlikely(is_subvol != btrfs_is_fstree(eb_owner))) {
                btrfs_crit(eb->fs_info,
 "corrupted %s, root=%llu block=%llu owner mismatch, have %llu expect [%llu, %llu]",
                        btrfs_header_level(eb) == 0 ? "leaf" : "node",
index b8048613d41ebf55e1f199236804d5b663f02afd..0a0eb4ff2ebc8d96d0fd67ca19e2fe74094831e1 100644 (file)
@@ -144,7 +144,7 @@ static struct btrfs_inode *btrfs_iget_logging(u64 objectid, struct btrfs_root *r
        struct btrfs_inode *inode;
 
        /* Only meant to be called for subvolume roots and not for log roots. */
-       ASSERT(is_fstree(btrfs_root_id(root)));
+       ASSERT(btrfs_is_fstree(btrfs_root_id(root)));
 
        /*
         * We're holding a transaction handle whether we are logging or