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/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;