]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: unify ordering of btrfs_key initializations
authorDavid Sterba <dsterba@suse.com>
Wed, 12 Feb 2025 20:22:07 +0000 (21:22 +0100)
committerDavid Sterba <dsterba@suse.com>
Tue, 18 Mar 2025 19:35:42 +0000 (20:35 +0100)
The btrfs_key is defined as objectid/type/offset and the keys are also
printed like that. For better readability, update all key
initializations to match this order.

Signed-off-by: David Sterba <dsterba@suse.com>
14 files changed:
fs/btrfs/backref.c
fs/btrfs/block-group.c
fs/btrfs/export.c
fs/btrfs/extent-tree.c
fs/btrfs/file-item.c
fs/btrfs/free-space-cache.c
fs/btrfs/inode-item.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/qgroup.c
fs/btrfs/scrub.c
fs/btrfs/transaction.c
fs/btrfs/tree-log.c
fs/btrfs/volumes.c

index 3d3923cfc35746c04f9aa2318b108de23718e891..5936cff80ff3d30b10aac0ccbc6d6f5d2d5d5dce 100644 (file)
@@ -1399,11 +1399,11 @@ static int find_parent_nodes(struct btrfs_backref_walk_ctx *ctx,
                ASSERT(ctx->roots == NULL);
 
        key.objectid = ctx->bytenr;
-       key.offset = (u64)-1;
        if (btrfs_fs_incompat(ctx->fs_info, SKINNY_METADATA))
                key.type = BTRFS_METADATA_ITEM_KEY;
        else
                key.type = BTRFS_EXTENT_ITEM_KEY;
+       key.offset = (u64)-1;
 
        path = btrfs_alloc_path();
        if (!path)
@@ -2206,11 +2206,11 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
        struct btrfs_extent_item *ei;
        struct btrfs_key key;
 
+       key.objectid = logical;
        if (btrfs_fs_incompat(fs_info, SKINNY_METADATA))
                key.type = BTRFS_METADATA_ITEM_KEY;
        else
                key.type = BTRFS_EXTENT_ITEM_KEY;
-       key.objectid = logical;
        key.offset = (u64)-1;
 
        ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
index c0a8f7d92acc5c9b796da79200b65b056f7d78d9..18f58674a16c2dc7d76ba2ee8c97798dce7f546c 100644 (file)
@@ -738,8 +738,8 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl)
        path->reada = READA_FORWARD;
 
        key.objectid = last;
-       key.offset = 0;
        key.type = BTRFS_EXTENT_ITEM_KEY;
+       key.offset = 0;
 
 next:
        ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
@@ -785,8 +785,8 @@ next:
 
                if (key.objectid < last) {
                        key.objectid = last;
-                       key.offset = 0;
                        key.type = BTRFS_EXTENT_ITEM_KEY;
+                       key.offset = 0;
                        btrfs_release_path(path);
                        goto next;
                }
@@ -2509,8 +2509,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info)
                return fill_dummy_bgs(info);
 
        key.objectid = 0;
-       key.offset = 0;
        key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
+       key.offset = 0;
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;
index e2b22bea348a350e9efc0c8af83f18f5da9ae38e..c087424ac0677e893ae6c0a6bbf33708dd570289 100644 (file)
@@ -249,8 +249,8 @@ static int btrfs_get_name(struct dentry *parent, char *name,
                root = fs_info->tree_root;
        } else {
                key.objectid = ino;
-               key.offset = btrfs_ino(BTRFS_I(dir));
                key.type = BTRFS_INODE_REF_KEY;
+               key.offset = btrfs_ino(BTRFS_I(dir));
        }
 
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
index 3014a1a23efdbfbe3107a447cb4ef2238c67da95..4a6036e7fa83f6ce05d86cf7276bf7a8992467b4 100644 (file)
@@ -79,8 +79,8 @@ int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len)
                return -ENOMEM;
 
        key.objectid = start;
-       key.offset = len;
        key.type = BTRFS_EXTENT_ITEM_KEY;
+       key.offset = len;
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        btrfs_free_path(path);
        return ret;
@@ -125,11 +125,11 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 
 search_again:
        key.objectid = bytenr;
-       key.offset = offset;
        if (metadata)
                key.type = BTRFS_METADATA_ITEM_KEY;
        else
                key.type = BTRFS_EXTENT_ITEM_KEY;
+       key.offset = offset;
 
        extent_root = btrfs_extent_root(fs_info, bytenr);
        ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
@@ -1679,8 +1679,8 @@ again:
                                metadata = 0;
 
                                key.objectid = head->bytenr;
-                               key.offset = head->num_bytes;
                                key.type = BTRFS_EXTENT_ITEM_KEY;
+                               key.offset = head->num_bytes;
                                goto again;
                        }
                } else {
@@ -2348,8 +2348,8 @@ static noinline int check_committed_ref(struct btrfs_inode *inode,
        int ret;
 
        key.objectid = bytenr;
-       key.offset = (u64)-1;
        key.type = BTRFS_EXTENT_ITEM_KEY;
+       key.offset = (u64)-1;
 
        ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
        if (ret < 0)
index d04a3b47b1fb20a3e606f66f599b506910afa3f7..5083025d28b2276a5041a9eb52a3ef8411a125ad 100644 (file)
@@ -169,9 +169,10 @@ int btrfs_insert_hole_extent(struct btrfs_trans_handle *trans,
        path = btrfs_alloc_path();
        if (!path)
                return -ENOMEM;
+
        file_key.objectid = objectid;
-       file_key.offset = pos;
        file_key.type = BTRFS_EXTENT_DATA_KEY;
+       file_key.offset = pos;
 
        ret = btrfs_insert_empty_item(trans, root, path, &file_key,
                                      sizeof(*item));
@@ -212,8 +213,8 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans,
        int csums_in_item;
 
        file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
-       file_key.offset = bytenr;
        file_key.type = BTRFS_EXTENT_CSUM_KEY;
+       file_key.offset = bytenr;
        ret = btrfs_search_slot(trans, root, &file_key, path, 0, cow);
        if (ret < 0)
                goto fail;
@@ -259,8 +260,8 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,
        int cow = mod != 0;
 
        file_key.objectid = objectid;
-       file_key.offset = offset;
        file_key.type = BTRFS_EXTENT_DATA_KEY;
+       file_key.offset = offset;
 
        return btrfs_search_slot(trans, root, &file_key, path, ins_len, cow);
 }
@@ -484,8 +485,8 @@ int btrfs_lookup_csums_list(struct btrfs_root *root, u64 start, u64 end,
        path->nowait = nowait;
 
        key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
-       key.offset = start;
        key.type = BTRFS_EXTENT_CSUM_KEY;
+       key.offset = start;
 
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        if (ret < 0)
@@ -892,8 +893,8 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
 
        while (1) {
                key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
-               key.offset = end_byte - 1;
                key.type = BTRFS_EXTENT_CSUM_KEY;
+               key.offset = end_byte - 1;
 
                ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
                if (ret > 0) {
@@ -1074,8 +1075,8 @@ again:
        found_next = 0;
        bytenr = sums->logical + total_bytes;
        file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID;
-       file_key.offset = bytenr;
        file_key.type = BTRFS_EXTENT_CSUM_KEY;
+       file_key.offset = bytenr;
 
        item = btrfs_lookup_csum(trans, root, path, bytenr, 1);
        if (!IS_ERR(item)) {
index 7054b4c88f99425595079942973abcada003f535..056546bf9abdb26daa8ffb4efa5184acf789b80f 100644 (file)
@@ -93,8 +93,8 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
        int ret;
 
        key.objectid = BTRFS_FREE_SPACE_OBJECTID;
-       key.offset = offset;
        key.type = 0;
+       key.offset = offset;
 
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        if (ret < 0)
@@ -201,8 +201,8 @@ static int __create_free_space_inode(struct btrfs_root *root,
        btrfs_release_path(path);
 
        key.objectid = BTRFS_FREE_SPACE_OBJECTID;
-       key.offset = offset;
        key.type = 0;
+       key.offset = offset;
        ret = btrfs_insert_empty_item(trans, root, path, &key,
                                      sizeof(struct btrfs_free_space_header));
        if (ret < 0) {
@@ -755,8 +755,8 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
                return 0;
 
        key.objectid = BTRFS_FREE_SPACE_OBJECTID;
-       key.offset = offset;
        key.type = 0;
+       key.offset = offset;
 
        ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
        if (ret < 0)
@@ -1158,8 +1158,8 @@ update_cache_item(struct btrfs_trans_handle *trans,
        int ret;
 
        key.objectid = BTRFS_FREE_SPACE_OBJECTID;
-       key.offset = offset;
        key.type = 0;
+       key.offset = offset;
 
        ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
        if (ret < 0) {
index 448aa1a682d6019a85e1ddc7c158ba1e5b2cd3eb..3530de0618c8be40381ac159ea259b13bf6d7266 100644 (file)
@@ -191,8 +191,8 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
        int del_len = name->len + sizeof(*ref);
 
        key.objectid = inode_objectid;
-       key.offset = ref_objectid;
        key.type = BTRFS_INODE_REF_KEY;
+       key.offset = ref_objectid;
 
        path = btrfs_alloc_path();
        if (!path)
@@ -317,8 +317,8 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
        int ins_len = name->len + sizeof(*ref);
 
        key.objectid = inode_objectid;
-       key.offset = ref_objectid;
        key.type = BTRFS_INODE_REF_KEY;
+       key.offset = ref_objectid;
 
        path = btrfs_alloc_path();
        if (!path)
@@ -493,8 +493,8 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
        path->reada = READA_BACK;
 
        key.objectid = control->ino;
-       key.offset = (u64)-1;
        key.type = (u8)-1;
+       key.offset = (u64)-1;
 
 search_again:
        /*
index bdf9cb93be2def73dba6e527555e664c4aae0b66..a7fa63fef85fc0d8fcf2014b43998ace8be097fe 100644 (file)
@@ -489,8 +489,8 @@ static int insert_inline_extent(struct btrfs_trans_handle *trans,
                size_t datasize;
 
                key.objectid = btrfs_ino(inode);
-               key.offset = 0;
                key.type = BTRFS_EXTENT_DATA_KEY;
+               key.offset = 0;
 
                datasize = btrfs_file_extent_calc_inline_size(cur_size);
                ret = btrfs_insert_empty_item(trans, root, path, &key,
@@ -2963,8 +2963,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
 
        if (!drop_args.extent_inserted) {
                ins.objectid = btrfs_ino(inode);
-               ins.offset = file_pos;
                ins.type = BTRFS_EXTENT_DATA_KEY;
+               ins.offset = file_pos;
 
                ret = btrfs_insert_empty_item(trans, root, path, &ins,
                                              sizeof(*stack_fi));
@@ -2999,8 +2999,8 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
                btrfs_update_inode_bytes(inode, num_bytes, drop_args.bytes_found);
 
        ins.objectid = disk_bytenr;
-       ins.offset = disk_num_bytes;
        ins.type = BTRFS_EXTENT_ITEM_KEY;
+       ins.offset = disk_num_bytes;
 
        ret = btrfs_inode_set_file_extent_range(inode, file_pos, ram_bytes);
        if (ret)
@@ -8712,8 +8712,8 @@ static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
                goto out;
        }
        key.objectid = btrfs_ino(BTRFS_I(inode));
-       key.offset = 0;
        key.type = BTRFS_EXTENT_DATA_KEY;
+       key.offset = 0;
        datasize = btrfs_file_extent_calc_inline_size(name_len);
        err = btrfs_insert_empty_item(trans, root, path, &key,
                                      datasize);
index 8fff7ddf6409f7350d2c11da73af5576e67b472a..45b0870113244d0418523fac40f4f795acd165d6 100644 (file)
@@ -618,8 +618,8 @@ static noinline int create_subvol(struct mnt_idmap *idmap,
        btrfs_set_root_dirid(root_item, BTRFS_FIRST_FREE_OBJECTID);
 
        key.objectid = objectid;
-       key.offset = 0;
        key.type = BTRFS_ROOT_ITEM_KEY;
+       key.offset = 0;
        ret = btrfs_insert_root(trans, fs_info->tree_root, &key,
                                root_item);
        if (ret) {
@@ -1531,8 +1531,8 @@ static noinline int copy_to_sk(struct btrfs_path *path,
                }
 
                sh.objectid = key->objectid;
-               sh.offset = key->offset;
                sh.type = key->type;
+               sh.offset = key->offset;
                sh.len = item_len;
                sh.transid = found_transid;
 
index f9d3766c809b4edd5d6266be7e93f2442448403d..d6fa36674270f78cf16e0af6db666d5a0693ff3a 100644 (file)
@@ -956,8 +956,8 @@ static int btrfs_clean_quota_tree(struct btrfs_trans_handle *trans,
                return -ENOMEM;
 
        key.objectid = 0;
-       key.offset = 0;
        key.type = 0;
+       key.offset = 0;
 
        while (1) {
                ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
index 531312efee8df6512b5fbb1582e601a07818f705..2c5edcee94502b0625671137f856e385eb1aa26f 100644 (file)
@@ -1380,11 +1380,11 @@ static int find_first_extent_item(struct btrfs_root *extent_root,
        if (path->nodes[0])
                goto search_forward;
 
+       key.objectid = search_start;
        if (btrfs_fs_incompat(fs_info, SKINNY_METADATA))
                key.type = BTRFS_METADATA_ITEM_KEY;
        else
                key.type = BTRFS_EXTENT_ITEM_KEY;
-       key.objectid = search_start;
        key.offset = (u64)-1;
 
        ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
@@ -2497,8 +2497,8 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
        path->skip_locking = 1;
 
        key.objectid = scrub_dev->devid;
-       key.offset = 0ull;
        key.type = BTRFS_DEV_EXTENT_KEY;
+       key.offset = 0ull;
 
        while (1) {
                u64 dev_extent_len;
index aca83a98b75a24c452735a79fbfae0a9e7de13fa..47b2f7172374529ef92c7d2ee73d919d2d348ca8 100644 (file)
@@ -1690,8 +1690,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        }
 
        key.objectid = objectid;
-       key.offset = (u64)-1;
        key.type = BTRFS_ROOT_ITEM_KEY;
+       key.offset = (u64)-1;
 
        rsv = trans->block_rsv;
        trans->block_rsv = &pending->block_rsv;
index 955d1677e8653f33bb28b65ef9f6900df7b087fc..fc5c761181eb747d04a76e2b0c7f147399875ac0 100644 (file)
@@ -747,8 +747,8 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
                                (unsigned long)item,  sizeof(*item));
 
                ins.objectid = btrfs_file_extent_disk_bytenr(eb, item);
-               ins.offset = btrfs_file_extent_disk_num_bytes(eb, item);
                ins.type = BTRFS_EXTENT_ITEM_KEY;
+               ins.offset = btrfs_file_extent_disk_num_bytes(eb, item);
                offset = key->offset - btrfs_file_extent_offset(eb, item);
 
                /*
@@ -3560,8 +3560,8 @@ static noinline int insert_dir_log_key(struct btrfs_trans_handle *trans,
        struct btrfs_dir_log_item *item;
 
        key.objectid = dirid;
-       key.offset = first_offset;
        key.type = BTRFS_DIR_LOG_INDEX_KEY;
+       key.offset = first_offset;
        ret = btrfs_insert_empty_item(trans, log, path, &key, sizeof(*item));
        /*
         * -EEXIST is fine and can happen sporadically when we are logging a
@@ -7247,8 +7247,8 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
 
 again:
        key.objectid = BTRFS_TREE_LOG_OBJECTID;
-       key.offset = (u64)-1;
        key.type = BTRFS_ROOT_ITEM_KEY;
+       key.offset = (u64)-1;
 
        while (1) {
                ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0);
index 3f8afbd1ebb552b8d8907813b4a101840e000fd1..c8c21c55be53bdc5127f593b849f423b4e65917a 100644 (file)
@@ -1798,8 +1798,8 @@ again:
        path->skip_locking = 1;
 
        key.objectid = device->devid;
-       key.offset = search_start;
        key.type = BTRFS_DEV_EXTENT_KEY;
+       key.offset = search_start;
 
        ret = btrfs_search_backwards(root, &key, path);
        if (ret < 0)
@@ -1918,8 +1918,8 @@ static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans,
                return -ENOMEM;
 
        key.objectid = device->devid;
-       key.offset = start;
        key.type = BTRFS_DEV_EXTENT_KEY;
+       key.offset = start;
 again:
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
        if (ret > 0) {
@@ -2721,8 +2721,8 @@ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans)
                return -ENOMEM;
 
        key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
-       key.offset = 0;
        key.type = BTRFS_DEV_ITEM_KEY;
+       key.offset = 0;
 
        while (1) {
                btrfs_reserve_chunk_metadata(trans, false);
@@ -3119,8 +3119,8 @@ static int btrfs_free_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
                return -ENOMEM;
 
        key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
-       key.offset = chunk_offset;
        key.type = BTRFS_CHUNK_ITEM_KEY;
+       key.offset = chunk_offset;
 
        ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
        if (ret < 0)
@@ -3577,8 +3577,8 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)
 
 again:
        key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
-       key.offset = (u64)-1;
        key.type = BTRFS_CHUNK_ITEM_KEY;
+       key.offset = (u64)-1;
 
        while (1) {
                mutex_lock(&fs_info->reclaim_bgs_lock);
@@ -4184,8 +4184,8 @@ again:
                bctl->sys.limit = limit_sys;
        }
        key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
-       key.offset = (u64)-1;
        key.type = BTRFS_CHUNK_ITEM_KEY;
+       key.offset = (u64)-1;
 
        while (1) {
                if ((!counting && atomic_read(&fs_info->balance_pause_req)) ||
@@ -5001,8 +5001,8 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
 
 again:
        key.objectid = device->devid;
-       key.offset = (u64)-1;
        key.type = BTRFS_DEV_EXTENT_KEY;
+       key.offset = (u64)-1;
 
        do {
                mutex_lock(&fs_info->reclaim_bgs_lock);
@@ -7539,8 +7539,8 @@ int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info)
         * item - BTRFS_FIRST_CHUNK_TREE_OBJECTID).
         */
        key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
-       key.offset = 0;
        key.type = 0;
+       key.offset = 0;
        btrfs_for_each_slot(root, &key, &found_key, path, iter_ret) {
                struct extent_buffer *node = path->nodes[1];