From 208150ee4faea470f7b0d69be9f384bfd990c8c4 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Sat, 20 Apr 2024 01:27:41 +0200 Subject: [PATCH] btrfs-progs: reorder key initializations Use the objectid, type, offset natural order as it's more readable and we're used to read keys like that. Signed-off-by: David Sterba --- check/main.c | 10 +++++----- check/mode-common.c | 12 ++++++------ check/mode-lowmem.c | 8 ++++---- check/qgroup-verify.c | 2 +- check/repair.c | 2 +- cmds/filesystem-usage.c | 4 ++-- cmds/inspect-dump-tree.c | 2 +- cmds/inspect.c | 10 +++++----- cmds/qgroup.c | 7 ++++--- cmds/rescue-chunk-recover.c | 4 ++-- cmds/restore.c | 2 +- cmds/subvolume.c | 2 +- common/extent-tree-utils.c | 2 +- common/fsfeatures.c | 4 ++-- common/send-utils.c | 4 ++-- common/utils.c | 2 +- convert/main.c | 4 ++-- convert/source-fs.c | 2 +- kernel-shared/accessors.h | 8 ++++---- kernel-shared/backref.c | 4 ++-- kernel-shared/ctree.c | 2 +- kernel-shared/dir-item.c | 1 - kernel-shared/extent-tree.c | 21 ++++++++++----------- kernel-shared/file-item.c | 10 +++++----- kernel-shared/file.c | 4 ++-- kernel-shared/free-space-cache.c | 2 +- kernel-shared/inode-item.c | 4 ++-- kernel-shared/inode.c | 6 +++--- kernel-shared/uuid-tree.c | 4 ++-- kernel-shared/volumes.c | 10 +++++----- mkfs/rootdir.c | 4 ++-- 31 files changed, 81 insertions(+), 82 deletions(-) diff --git a/check/main.c b/check/main.c index 2cd24d4c64..93af325f25 100644 --- a/check/main.c +++ b/check/main.c @@ -2785,8 +2785,8 @@ static int repair_inline_ram_bytes(struct btrfs_trans_handle *trans, int ret; key.objectid = rec->ino; - key.offset = 0; key.type = BTRFS_EXTENT_DATA_KEY; + key.offset = 0; ret = btrfs_search_slot(trans, root, &key, path, 0, 1); if (ret > 0) @@ -3018,8 +3018,8 @@ static int repair_inode_gen_original(struct btrfs_trans_handle *trans, int ret; key.objectid = rec->ino; - key.offset = 0; key.type = BTRFS_INODE_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(trans, root, &key, path, 0, 1); if (ret > 0) { @@ -3920,12 +3920,12 @@ static int check_fs_roots(struct cache_tree *root_cache) cache_tree_init(&wc.shared); again: - key.offset = 0; if (skip_root) key.objectid = skip_root + 1; else key.objectid = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, tree_root, &key, &path, 0, 0); if (ret < 0) { err = 1; @@ -6937,8 +6937,8 @@ static int record_extent(struct btrfs_trans_handle *trans, item_size += sizeof(*bi); ins_key.objectid = rec->start; - ins_key.offset = rec->max_size; ins_key.type = BTRFS_EXTENT_ITEM_KEY; + ins_key.offset = rec->max_size; ret = btrfs_insert_empty_item(trans, extent_root, path, &ins_key, item_size); @@ -8935,9 +8935,9 @@ static int parse_tree_roots(struct list_head *normal_trees, int slot; int ret = 0; - key.offset = 0; key.objectid = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, gfs_info->tree_root, &key, &path, 0, 0); if (ret < 0) goto out; diff --git a/check/mode-common.c b/check/mode-common.c index 05a332acf8..8efa884be1 100644 --- a/check/mode-common.c +++ b/check/mode-common.c @@ -314,8 +314,8 @@ int count_csum_range(u64 start, u64 len, u64 *found) u16 csum_size = gfs_info->csum_size; key.objectid = BTRFS_EXTENT_CSUM_OBJECTID; - key.offset = start; key.type = BTRFS_EXTENT_CSUM_KEY; + key.offset = start; ret = btrfs_search_slot(NULL, csum_root, &key, &path, 0, 0); if (ret < 0) @@ -417,8 +417,8 @@ static int get_highest_inode(struct btrfs_trans_handle *trans, int ret; key.objectid = BTRFS_LAST_FREE_OBJECTID; - key.offset = -1; key.type = BTRFS_INODE_ITEM_KEY; + key.offset = -1; ret = btrfs_search_slot(trans, root, &key, path, -1, 1); if (ret == 1) { btrfs_item_key_to_cpu(path->nodes[0], &found_key, @@ -745,8 +745,8 @@ static int find_file_type_dir_index(struct btrfs_root *root, u64 ino, u64 dirid, int ret; key.objectid = dirid; - key.offset = index; key.type = BTRFS_DIR_INDEX_KEY; + key.offset = index; ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret > 0) { @@ -798,8 +798,8 @@ static int find_file_type_dir_item(struct btrfs_root *root, u64 ino, u64 dirid, int ret; key.objectid = dirid; - key.offset = btrfs_name_hash(name, name_len); key.type = BTRFS_DIR_INDEX_KEY; + key.offset = btrfs_name_hash(name, name_len); ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret > 0) { @@ -1255,8 +1255,8 @@ static int fill_csum_tree_from_one_fs_root(struct btrfs_trans_handle *trans, return -ENOMEM; key.objectid = 0; - key.offset = 0; key.type = 0; + key.offset = 0; ret = btrfs_search_slot(NULL, cur_root, &key, &path, 0, 0); if (ret < 0) goto out; @@ -1354,8 +1354,8 @@ static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans) int ret = 0; key.objectid = BTRFS_FS_TREE_OBJECTID; - key.offset = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, tree_root, &key, &path, 0, 0); if (ret < 0) goto out; diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index 789d569636..fd9b975c4e 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -865,8 +865,8 @@ static int find_dir_index(struct btrfs_root *root, u64 dirid, u64 location_id, /* search from the last index */ key.objectid = dirid; - key.offset = (u64)-1; key.type = BTRFS_DIR_INDEX_KEY; + key.offset = (u64)-1; ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) @@ -3935,8 +3935,8 @@ static int is_tree_reloc_root(struct extent_buffer *eb) int ret = 0; key.objectid = BTRFS_TREE_RELOC_OBJECTID; - key.offset = owner; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = owner; tree_reloc_root = btrfs_read_fs_root_no_cache(gfs_info, &key); if (IS_ERR(tree_reloc_root)) @@ -5556,8 +5556,8 @@ int check_fs_roots_lowmem(void) int err = 0; key.objectid = BTRFS_FS_TREE_OBJECTID; - key.offset = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, tree_root, &key, &path, 0, 0); if (ret < 0) { @@ -5670,8 +5670,8 @@ int check_chunks_and_extents_lowmem(void) err |= ret; key.objectid = BTRFS_EXTENT_TREE_OBJECTID; - key.offset = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, gfs_info->tree_root, &key, &path, 0, 0); if (ret) { diff --git a/check/qgroup-verify.c b/check/qgroup-verify.c index 890e541055..4fa51446a6 100644 --- a/check/qgroup-verify.c +++ b/check/qgroup-verify.c @@ -960,9 +960,9 @@ static int load_quota_info(struct btrfs_fs_info *info) * items. The 2nd pass picks up relation items and glues them to their * respective count structures. */ - key.offset = 0; key.objectid = search_relations ? 0 : BTRFS_QGROUP_RELATION_KEY; key.type = 0; + key.offset = 0; ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) { diff --git a/check/repair.c b/check/repair.c index c81f19bad2..e500c4fa0a 100644 --- a/check/repair.c +++ b/check/repair.c @@ -227,9 +227,9 @@ static int populate_used_from_extent_root(struct btrfs_root *root, int slot; int ret; - key.offset = 0; key.objectid = 0; key.type = BTRFS_EXTENT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) return ret; diff --git a/cmds/filesystem-usage.c b/cmds/filesystem-usage.c index 497a33bc56..473479a1d7 100644 --- a/cmds/filesystem-usage.c +++ b/cmds/filesystem-usage.c @@ -161,10 +161,10 @@ static int load_chunk_info(int fd, struct array *chunkinfos) sk->tree_id = BTRFS_CHUNK_TREE_OBJECTID; sk->min_objectid = 0; - sk->max_objectid = (u64)-1; - sk->max_type = 0; sk->min_type = (u8)-1; sk->min_offset = 0; + sk->max_objectid = (u64)-1; + sk->max_type = 0; sk->max_offset = (u64)-1; sk->min_transid = 0; sk->max_transid = (u64)-1; diff --git a/cmds/inspect-dump-tree.c b/cmds/inspect-dump-tree.c index de271fa643..127ebb82af 100644 --- a/cmds/inspect-dump-tree.c +++ b/cmds/inspect-dump-tree.c @@ -580,9 +580,9 @@ static int cmd_inspect_dump_tree(const struct cmd_struct *cmd, goto close_root; } - key.offset = 0; key.objectid = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, tree_root_scan, &key, &path, 0, 0); if (ret < 0) { errno = -ret; diff --git a/cmds/inspect.c b/cmds/inspect.c index d427de24fb..fd2fb59818 100644 --- a/cmds/inspect.c +++ b/cmds/inspect.c @@ -570,10 +570,10 @@ static int print_min_dev_size(int fd, u64 devid) sk = btrfs_tree_search_sk(&args); sk->tree_id = BTRFS_DEV_TREE_OBJECTID; sk->min_objectid = devid; - sk->max_objectid = devid; - sk->max_type = BTRFS_DEV_EXTENT_KEY; sk->min_type = BTRFS_DEV_EXTENT_KEY; sk->min_offset = 0; + sk->max_objectid = devid; + sk->max_type = BTRFS_DEV_EXTENT_KEY; sk->max_offset = (u64)-1; sk->min_transid = 0; sk->max_transid = (u64)-1; @@ -980,10 +980,10 @@ static u64 fill_usage(int fd, u64 lstart) sk = btrfs_tree_search_sk(&args); sk->tree_id = BTRFS_EXTENT_TREE_OBJECTID; sk->min_objectid = lstart; - sk->max_objectid = lstart; sk->min_type = BTRFS_BLOCK_GROUP_ITEM_KEY; - sk->max_type = BTRFS_BLOCK_GROUP_ITEM_KEY; sk->min_offset = 0; + sk->max_objectid = lstart; + sk->max_type = BTRFS_BLOCK_GROUP_ITEM_KEY; sk->max_offset = (u64)-1; sk->max_transid = (u64)-1; sk->nr_items = 1; @@ -1089,8 +1089,8 @@ static int cmd_inspect_list_chunks(const struct cmd_struct *cmd, sk = btrfs_tree_search_sk(&args); sk->tree_id = BTRFS_CHUNK_TREE_OBJECTID; sk->min_objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; - sk->max_objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; sk->min_type = BTRFS_CHUNK_ITEM_KEY; + sk->max_objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; sk->max_type = BTRFS_CHUNK_ITEM_KEY; sk->max_offset = (u64)-1; sk->max_transid = (u64)-1; diff --git a/cmds/qgroup.c b/cmds/qgroup.c index 83dc60ae07..6e88db5803 100644 --- a/cmds/qgroup.c +++ b/cmds/qgroup.c @@ -1354,9 +1354,9 @@ static int __qgroups_search(int fd, struct btrfs_tree_search_args *args, * record the mins in sk so we can make sure the * next search doesn't repeat this root */ + sk->min_objectid = key.objectid; sk->min_type = key.type; sk->min_offset = key.offset; - sk->min_objectid = key.objectid; } sk->nr_items = 4096; /* @@ -1410,10 +1410,11 @@ int btrfs_qgroup_query(int fd, u64 qgroupid, struct btrfs_qgroup_stats *stats) memset(&args, 0, sizeof(args)); sk = btrfs_tree_search_sk(&args); sk->tree_id = BTRFS_QUOTA_TREE_OBJECTID; + sk->min_objectid = 0; sk->min_type = BTRFS_QGROUP_INFO_KEY; - sk->max_type = BTRFS_QGROUP_LIMIT_KEY; - sk->max_objectid = 0; sk->min_offset = qgroupid; + sk->max_objectid = 0; + sk->max_type = BTRFS_QGROUP_LIMIT_KEY; sk->max_offset = qgroupid; sk->max_transid = (u64)-1; sk->nr_items = 4096; diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c index e40fd99032..60a705817c 100644 --- a/cmds/rescue-chunk-recover.c +++ b/cmds/rescue-chunk-recover.c @@ -592,8 +592,8 @@ static int check_chunk_by_metadata(struct recover_control *rc, stripe = &chunk->stripes[i]; key.objectid = stripe->devid; - key.offset = stripe->offset; key.type = BTRFS_DEV_EXTENT_KEY; + key.offset = stripe->offset; ret = btrfs_search_slot(NULL, dev_root, &key, &path, 0, 0); if (ret < 0) { @@ -1016,8 +1016,8 @@ static int block_group_remove_all_extent_items(struct btrfs_trans_handle *trans, root = btrfs_extent_root(fs_info, start); key.objectid = start; - key.offset = 0; key.type = BTRFS_EXTENT_ITEM_KEY; + key.offset = 0; again: ret = btrfs_search_slot(trans, root, &key, &path, -1, 1); if (ret < 0) diff --git a/cmds/restore.c b/cmds/restore.c index 4904e87b87..83b22d30b6 100644 --- a/cmds/restore.c +++ b/cmds/restore.c @@ -1167,9 +1167,9 @@ static int do_list_roots(struct btrfs_root *root) root = root->fs_info->tree_root; - key.offset = 0; key.objectid = 0; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) { error("failed search next root item: %d", ret); diff --git a/cmds/subvolume.c b/cmds/subvolume.c index 869d7077d2..319f595ca4 100644 --- a/cmds/subvolume.c +++ b/cmds/subvolume.c @@ -972,9 +972,9 @@ static u64 find_root_gen(int fd) * them. */ sk->min_objectid = ino_args.treeid; + sk->min_type = BTRFS_ROOT_ITEM_KEY; sk->max_objectid = ino_args.treeid; sk->max_type = BTRFS_ROOT_ITEM_KEY; - sk->min_type = BTRFS_ROOT_ITEM_KEY; sk->max_offset = (u64)-1; sk->max_transid = (u64)-1; sk->nr_items = 4096; diff --git a/common/extent-tree-utils.c b/common/extent-tree-utils.c index 34c7e50951..9f7e543f3b 100644 --- a/common/extent-tree-utils.c +++ b/common/extent-tree-utils.c @@ -221,8 +221,8 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, } btrfs_release_path(path); ins_key.objectid = objectid; - ins_key.offset = file_pos; ins_key.type = BTRFS_EXTENT_DATA_KEY; + ins_key.offset = file_pos; ret = btrfs_insert_empty_item(trans, root, path, &ins_key, sizeof(*fi)); if (ret) goto fail; diff --git a/common/fsfeatures.c b/common/fsfeatures.c index 02d13f60a6..c5e81629cc 100644 --- a/common/fsfeatures.c +++ b/common/fsfeatures.c @@ -730,10 +730,10 @@ int btrfs_tree_search2_ioctl_supported(int fd) */ sk->tree_id = BTRFS_ROOT_TREE_OBJECTID; sk->min_objectid = BTRFS_EXTENT_TREE_OBJECTID; - sk->max_objectid = BTRFS_EXTENT_TREE_OBJECTID; sk->min_type = BTRFS_ROOT_ITEM_KEY; - sk->max_type = BTRFS_ROOT_ITEM_KEY; sk->min_offset = 0; + sk->max_objectid = BTRFS_EXTENT_TREE_OBJECTID; + sk->max_type = BTRFS_ROOT_ITEM_KEY; sk->max_offset = (u64)-1; sk->min_transid = 0; sk->max_transid = (u64)-1; diff --git a/common/send-utils.c b/common/send-utils.c index cec1653e14..173333e30a 100644 --- a/common/send-utils.c +++ b/common/send-utils.c @@ -80,9 +80,9 @@ static int btrfs_read_root_item_raw(int mnt_fd, u64 root_id, size_t buf_len, * them. */ sk->min_objectid = root_id; + sk->min_type = BTRFS_ROOT_ITEM_KEY; sk->max_objectid = root_id; sk->max_type = BTRFS_ROOT_ITEM_KEY; - sk->min_type = BTRFS_ROOT_ITEM_KEY; sk->max_offset = (u64)-1; sk->max_transid = (u64)-1; sk->nr_items = 4096; @@ -210,8 +210,8 @@ static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len, sk = btrfs_tree_search_sk(&args); sk->tree_id = BTRFS_ROOT_TREE_OBJECTID; sk->min_objectid = subvol_id; - sk->max_objectid = subvol_id; sk->min_type = BTRFS_ROOT_BACKREF_KEY; + sk->max_objectid = subvol_id; sk->max_type = BTRFS_ROOT_BACKREF_KEY; sk->max_offset = (u64)-1; sk->max_transid = (u64)-1; diff --git a/common/utils.c b/common/utils.c index d3df9799cb..3ca7cff396 100644 --- a/common/utils.c +++ b/common/utils.c @@ -154,8 +154,8 @@ static int search_chunk_tree_for_fs_info(int fd, sk = btrfs_tree_search_sk(&args); sk->tree_id = BTRFS_CHUNK_TREE_OBJECTID; sk->min_objectid = BTRFS_DEV_ITEMS_OBJECTID; - sk->max_objectid = BTRFS_DEV_ITEMS_OBJECTID; sk->min_type = BTRFS_DEV_ITEM_KEY; + sk->max_objectid = BTRFS_DEV_ITEMS_OBJECTID; sk->max_type = BTRFS_DEV_ITEM_KEY; sk->min_transid = 0; sk->max_transid = (u64)-1; diff --git a/convert/main.c b/convert/main.c index f18fab4a23..139fc15be1 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1274,8 +1274,8 @@ static int do_convert(const char *devname, u32 convert_flags, u32 nodesize, snprintf(subvol_name, sizeof(subvol_name), "%s_saved", cctx.convert_ops->name); key.objectid = CONV_IMAGE_SUBVOL_OBJECTID; - key.offset = (u64)-1; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = (u64)-1; image_root = btrfs_read_fs_root(root->fs_info, &key); if (!image_root) { error("unable to create image subvolume"); @@ -1486,8 +1486,8 @@ static int check_convert_image(struct btrfs_root *image_root, u64 ino, int ret; key.objectid = ino; - key.offset = 0; key.type = BTRFS_EXTENT_DATA_KEY; + key.offset = 0; ret = btrfs_search_slot(NULL, image_root, &key, &path, 0, 0); /* diff --git a/convert/source-fs.c b/convert/source-fs.c index 6656143886..97c989d9ab 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -188,8 +188,8 @@ int convert_insert_dirent(struct btrfs_trans_handle *trans, struct btrfs_inode_item dummy_iitem = { 0 }; struct btrfs_key location = { .objectid = objectid, - .offset = 0, .type = BTRFS_INODE_ITEM_KEY, + .offset = 0, }; ret = btrfs_insert_dir_item(trans, root, name, name_len, diff --git a/kernel-shared/accessors.h b/kernel-shared/accessors.h index c949033055..b17c675c18 100644 --- a/kernel-shared/accessors.h +++ b/kernel-shared/accessors.h @@ -670,17 +670,17 @@ static inline void btrfs_dir_item_key_to_cpu(const struct extent_buffer *eb, static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, const struct btrfs_disk_key *disk) { - cpu->offset = le64_to_cpu(disk->offset); - cpu->type = disk->type; cpu->objectid = le64_to_cpu(disk->objectid); + cpu->type = disk->type; + cpu->offset = le64_to_cpu(disk->offset); } static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk, const struct btrfs_key *cpu) { - disk->offset = cpu_to_le64(cpu->offset); - disk->type = cpu->type; disk->objectid = cpu_to_le64(cpu->objectid); + disk->type = cpu->type; + disk->offset = cpu_to_le64(cpu->offset); } static inline void btrfs_node_key_to_cpu(const struct extent_buffer *eb, diff --git a/kernel-shared/backref.c b/kernel-shared/backref.c index d9e8d2f26f..89ccf073fc 100644 --- a/kernel-shared/backref.c +++ b/kernel-shared/backref.c @@ -770,11 +770,11 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans, init_pref_state(&prefstate); key.objectid = bytenr; - key.offset = (u64)-1; if (btrfs_fs_incompat(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) @@ -1172,11 +1172,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); diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c index d7bee0b476..b92294509d 100644 --- a/kernel-shared/ctree.c +++ b/kernel-shared/ctree.c @@ -1250,8 +1250,8 @@ int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *found_path, struct extent_buffer *eb; struct btrfs_path *path; - key.type = key_type; key.objectid = iobjectid; + key.type = key_type; key.offset = ioff; if (found_path == NULL) { diff --git a/kernel-shared/dir-item.c b/kernel-shared/dir-item.c index 2251de408b..4c62597b7b 100644 --- a/kernel-shared/dir-item.c +++ b/kernel-shared/dir-item.c @@ -229,7 +229,6 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, key.objectid = dir; key.type = BTRFS_DIR_ITEM_KEY; - key.offset = btrfs_name_hash(name, name_len); ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow); diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c index c2ccb8aa4d..af04b9eadc 100644 --- a/kernel-shared/extent-tree.c +++ b/kernel-shared/extent-tree.c @@ -123,8 +123,8 @@ static int cache_block_group(struct btrfs_root *root, path->reada = READA_FORWARD; last = max_t(u64, block_group->start, BTRFS_SUPER_INFO_OFFSET); key.objectid = last; - key.offset = 0; key.type = 0; + key.offset = 0; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); if (ret < 0) @@ -1325,11 +1325,11 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, return -ENOMEM; key.objectid = bytenr; - key.offset = offset; if (metadata) key.type = BTRFS_METADATA_ITEM_KEY; else key.type = BTRFS_EXTENT_ITEM_KEY; + key.offset = offset; again: ret = btrfs_search_slot(trans, extent_root, &key, path, 0, 0); @@ -1409,11 +1409,11 @@ int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, key.objectid = bytenr; if (skinny_metadata) { - key.offset = btrfs_header_level(eb); key.type = BTRFS_METADATA_ITEM_KEY; + key.offset = btrfs_header_level(eb); } else { - key.offset = fs_info->nodesize; key.type = BTRFS_EXTENT_ITEM_KEY; + key.offset = fs_info->nodesize; } again: @@ -2420,12 +2420,11 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, ins.objectid = node->bytenr; if (skinny_metadata) { - ins.offset = ref->level; ins.type = BTRFS_METADATA_ITEM_KEY; + ins.offset = ref->level; } else { - ins.offset = node->num_bytes; ins.type = BTRFS_EXTENT_ITEM_KEY; - + ins.offset = node->num_bytes; size += sizeof(struct btrfs_tree_block_info); } @@ -3217,8 +3216,8 @@ static int remove_block_group_item(struct btrfs_trans_handle *trans, int ret = 0; key.objectid = block_group->start; - key.offset = block_group->length; key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; + key.offset = block_group->length; /* * If we're doing convert and the bg is beyond our last converted bg, @@ -3348,8 +3347,8 @@ static int free_system_chunk_item(struct btrfs_super_block *super, sizeof(*disk_key); if (key->objectid == cpu_key.objectid && - key->offset == cpu_key.offset && - key->type == cpu_key.type) { + key->type == cpu_key.type && + key->offset == cpu_key.offset) { memmove(ptr + cur, ptr + cur + chunk_len, array_size - cur - chunk_len); array_size -= chunk_len; @@ -3376,8 +3375,8 @@ static int free_chunk_item(struct btrfs_trans_handle *trans, int ret; key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; - key.offset = bytenr; key.type = BTRFS_CHUNK_ITEM_KEY; + key.offset = bytenr; path = btrfs_alloc_path(); if (!path) diff --git a/kernel-shared/file-item.c b/kernel-shared/file-item.c index 34d8059e7e..d2da56e1f5 100644 --- a/kernel-shared/file-item.c +++ b/kernel-shared/file-item.c @@ -57,8 +57,8 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, 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)); @@ -102,8 +102,8 @@ int btrfs_insert_inline_extent(struct btrfs_trans_handle *trans, return -ENOMEM; key.objectid = objectid; - key.offset = offset; key.type = BTRFS_EXTENT_DATA_KEY; + key.offset = offset; datasize = btrfs_file_extent_calc_inline_size(size); ret = btrfs_insert_empty_item(trans, root, path, &key, datasize); @@ -146,8 +146,8 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans, int csums_in_item; file_key.objectid = 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; @@ -207,8 +207,8 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans, u64 logical, return -ENOMEM; file_key.objectid = csum_objectid; - file_key.offset = logical; file_key.type = BTRFS_EXTENT_CSUM_KEY; + file_key.offset = logical; item = btrfs_lookup_csum(trans, root, path, logical, csum_objectid, csum_type, 1); @@ -406,8 +406,8 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans, struct btrfs_root *root, 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) { diff --git a/kernel-shared/file.c b/kernel-shared/file.c index c51019b240..414a01b3ec 100644 --- a/kernel-shared/file.c +++ b/kernel-shared/file.c @@ -211,8 +211,8 @@ int btrfs_read_file(struct btrfs_root *root, u64 ino, u64 start, int len, } key.objectid = ino; - key.offset = start; key.type = BTRFS_EXTENT_DATA_KEY; + key.offset = start; ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0); if (ret < 0) @@ -317,8 +317,8 @@ int btrfs_read_file(struct btrfs_root *root, u64 ino, u64 start, int len, if (no_holes) { btrfs_release_path(&path); key.objectid = ino; - key.offset = 0; key.type = BTRFS_INODE_ITEM_KEY; + key.offset = 0; ret = btrfs_lookup_inode(NULL, root, &path, &key, 0); if (ret < 0) goto out; diff --git a/kernel-shared/free-space-cache.c b/kernel-shared/free-space-cache.c index c2d5d25834..d80fe5707e 100644 --- a/kernel-shared/free-space-cache.c +++ b/kernel-shared/free-space-cache.c @@ -306,8 +306,8 @@ static int __load_free_space_cache(struct btrfs_root *root, INIT_LIST_HEAD(&bitmaps); 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) { diff --git a/kernel-shared/inode-item.c b/kernel-shared/inode-item.c index f3f7286bea..34fe5bffc4 100644 --- a/kernel-shared/inode-item.c +++ b/kernel-shared/inode-item.c @@ -69,8 +69,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) @@ -398,8 +398,8 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, int del_len = name_len + sizeof(*ref); key.objectid = ino; - key.offset = parent_ino; key.type = BTRFS_INODE_REF_KEY; + key.offset = parent_ino; path = btrfs_alloc_path(); if (!path) diff --git a/kernel-shared/inode.c b/kernel-shared/inode.c index 3d420787c8..91b4f629f3 100644 --- a/kernel-shared/inode.c +++ b/kernel-shared/inode.c @@ -633,8 +633,8 @@ struct btrfs_root *btrfs_mksubvol(struct btrfs_root *root, } key.objectid = dirid; - key.offset = 0; key.type = BTRFS_INODE_ITEM_KEY; + key.offset = 0; ret = btrfs_lookup_inode(trans, root, &path, &key, 1); if (ret) { @@ -647,8 +647,8 @@ struct btrfs_root *btrfs_mksubvol(struct btrfs_root *root, struct btrfs_inode_item); key.objectid = root_objectid; - key.offset = (u64)-1; key.type = BTRFS_ROOT_ITEM_KEY; + key.offset = (u64)-1; memcpy(buf, base, len); if (convert) { @@ -737,8 +737,8 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, search_start = max((unsigned long long)search_start, BTRFS_FIRST_FREE_OBJECTID); search_key.objectid = search_start; - search_key.offset = 0; search_key.type = 0; + search_key.offset = 0; start_found = 0; ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0); diff --git a/kernel-shared/uuid-tree.c b/kernel-shared/uuid-tree.c index 7adbc11ee4..766cd31e42 100644 --- a/kernel-shared/uuid-tree.c +++ b/kernel-shared/uuid-tree.c @@ -63,10 +63,10 @@ static int btrfs_uuid_tree_lookup_any(int fd, const u8 *uuid, u8 type, memset(&search_arg, 0, sizeof(search_arg)); search_arg.key.tree_id = BTRFS_UUID_TREE_OBJECTID; search_arg.key.min_objectid = key.objectid; - search_arg.key.max_objectid = key.objectid; search_arg.key.min_type = type; - search_arg.key.max_type = type; search_arg.key.min_offset = key.offset; + search_arg.key.max_objectid = key.objectid; + search_arg.key.max_type = type; search_arg.key.max_offset = key.offset; search_arg.key.max_transid = (u64)-1; search_arg.key.nr_items = 1; diff --git a/kernel-shared/volumes.c b/kernel-shared/volumes.c index a9da39dcec..b21231efe8 100644 --- a/kernel-shared/volumes.c +++ b/kernel-shared/volumes.c @@ -871,8 +871,8 @@ static int find_free_dev_extent_start(struct btrfs_device *device, path->reada = READA_FORWARD; key.objectid = device->devid; - key.offset = search_start; key.type = BTRFS_DEV_EXTENT_KEY; + key.offset = search_start; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); if (ret < 0) @@ -1006,8 +1006,8 @@ int btrfs_insert_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; ret = btrfs_insert_empty_item(trans, root, path, &key, sizeof(*extent)); if (ret < 0) @@ -1062,8 +1062,8 @@ static int find_next_chunk(struct btrfs_fs_info *fs_info, u64 *offset) return -ENOMEM; key.objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID; - key.offset = (u64)-1; key.type = BTRFS_CHUNK_ITEM_KEY; + key.offset = (u64)-1; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); if (ret < 0) @@ -1302,8 +1302,8 @@ static int btrfs_device_avail_bytes(struct btrfs_trans_handle *trans, return -ENOMEM; key.objectid = device->devid; - key.offset = search_start; key.type = BTRFS_DEV_EXTENT_KEY; + key.offset = search_start; path->reada = READA_FORWARD; ret = btrfs_search_slot(trans, root, &key, path, 0, 0); @@ -2663,8 +2663,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; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); if (ret < 0) goto error; diff --git a/mkfs/rootdir.c b/mkfs/rootdir.c index 4ae9f435a7..617a7efdf7 100644 --- a/mkfs/rootdir.c +++ b/mkfs/rootdir.c @@ -76,8 +76,8 @@ static int add_directory_items(struct btrfs_trans_handle *trans, name_len = strlen(name); location.objectid = objectid; - location.offset = 0; location.type = BTRFS_INODE_ITEM_KEY; + location.offset = 0; if (S_ISDIR(st->st_mode)) filetype = BTRFS_FT_DIR; @@ -455,8 +455,8 @@ static int copy_rootdir_inode(struct btrfs_trans_handle *trans, } key.objectid = btrfs_root_dirid(&root->root_item); - key.offset = 0; key.type = BTRFS_INODE_ITEM_KEY; + key.offset = 0; ret = btrfs_lookup_inode(trans, root, &path, &key, 1); if (ret > 0) ret = -ENOENT;