From 555743075b5cc924021dd1e1a4a4697ee91441d8 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 13 Sep 2016 11:58:21 +0200 Subject: [PATCH] btrfs-progs: cleanup, kill trivial btrfs_set_key_type helper Signed-off-by: David Sterba --- backref.c | 2 +- btrfs-convert.c | 2 +- cmds-check.c | 4 ++-- cmds-inspect-dump-tree.c | 2 +- ctree.h | 5 ----- dir-item.c | 8 ++++---- dir-test.c | 6 +++--- extent-tree.c | 12 ++++++------ file-item.c | 6 +++--- inode-item.c | 2 +- mkfs.c | 6 +++--- quick-test.c | 2 +- random-test.c | 6 +++--- 13 files changed, 29 insertions(+), 34 deletions(-) diff --git a/backref.c b/backref.c index 7b3b5925..55be719b 100644 --- a/backref.c +++ b/backref.c @@ -990,7 +990,7 @@ int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid, unsigned long ptr; key.objectid = inode_objectid; - btrfs_set_key_type(&key, BTRFS_INODE_EXTREF_KEY); + key.type = BTRFS_INODE_EXTREF_KEY; key.offset = start_off; ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); diff --git a/btrfs-convert.c b/btrfs-convert.c index 936d4682..e1e0038e 100644 --- a/btrfs-convert.c +++ b/btrfs-convert.c @@ -2739,7 +2739,7 @@ static int do_rollback(const char *devname) key.objectid = objectid; key.offset = 0; - btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); + key.type = BTRFS_EXTENT_DATA_KEY; ret = btrfs_search_slot(NULL, image_root, &key, &path, 0, 0); if (ret != 0) { error("unable to find first file extent: %d", ret); diff --git a/cmds-check.c b/cmds-check.c index e53751c5..48fc82c4 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -8509,7 +8509,7 @@ again: btrfs_init_path(&path); key.offset = 0; key.objectid = 0; - btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); + key.type = BTRFS_ROOT_ITEM_KEY; ret = btrfs_search_slot(NULL, root->fs_info->tree_root, &key, &path, 0, 0); if (ret < 0) @@ -9207,7 +9207,7 @@ static int check_extent_data_backref(struct btrfs_fs_info *fs_info, btrfs_release_path(&path); } key.objectid = root_id; - btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); + key.type = BTRFS_ROOT_ITEM_KEY; key.offset = (u64)-1; btrfs_init_path(&path); diff --git a/cmds-inspect-dump-tree.c b/cmds-inspect-dump-tree.c index fcc56343..4bf14b7c 100644 --- a/cmds-inspect-dump-tree.c +++ b/cmds-inspect-dump-tree.c @@ -388,7 +388,7 @@ again: key.offset = 0; key.objectid = 0; - btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); + key.type = BTRFS_ROOT_ITEM_KEY; ret = btrfs_search_slot(NULL, tree_root_scan, &key, &path, 0, 0); if (ret < 0) { error("cannot read ROOT_ITEM from tree %llu: %s", diff --git a/ctree.h b/ctree.h index 297a98c5..44d62490 100644 --- a/ctree.h +++ b/ctree.h @@ -1840,11 +1840,6 @@ static inline u8 btrfs_key_type(struct btrfs_key *key) return key->type; } -static inline void btrfs_set_key_type(struct btrfs_key *key, u8 val) -{ - key->type = val; -} - /* struct btrfs_header */ BTRFS_SETGET_HEADER_FUNCS(header_bytenr, struct btrfs_header, bytenr, 64); BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header, diff --git a/dir-item.c b/dir-item.c index c2ae953e..68fc9e76 100644 --- a/dir-item.c +++ b/dir-item.c @@ -75,7 +75,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans, u32 data_size; key.objectid = dir; - btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); + key.type = BTRFS_XATTR_ITEM_KEY; key.offset = btrfs_name_hash(name, name_len); path = btrfs_alloc_path(); if (!path) @@ -125,7 +125,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root u32 data_size; key.objectid = dir; - btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); + key.type = BTRFS_DIR_ITEM_KEY; key.offset = btrfs_name_hash(name, name_len); path = btrfs_alloc_path(); if (!path) @@ -156,7 +156,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root } btrfs_release_path(path); - btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); + key.type = BTRFS_DIR_INDEX_KEY; key.offset = index; dir_item = insert_with_overflow(trans, root, path, &key, data_size, name, name_len); @@ -196,7 +196,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans, struct extent_buffer *leaf; key.objectid = dir; - btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); + key.type = BTRFS_DIR_ITEM_KEY; key.offset = btrfs_name_hash(name, name_len); diff --git a/dir-test.c b/dir-test.c index a54b7773..24f2c2e3 100644 --- a/dir-test.c +++ b/dir-test.c @@ -87,7 +87,7 @@ static int ins_one(struct btrfs_trans_handle *trans, struct btrfs_root *root, inode_map.objectid = objectid; inode_map.flags = 0; - btrfs_set_key_type(&inode_map, BTRFS_INODE_ITEM_KEY); + inode_map.type = BTRFS_INODE_ITEM_KEY; inode_map.offset = 0; initial_inode_init(root, &inode_item); @@ -158,7 +158,7 @@ static int insert_dup(struct btrfs_trans_handle *trans, struct btrfs_root key.objectid = file_oid; key.flags = 0; - btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); + key.type = BTRFS_INODE_ITEM_KEY; key.offset = 0; ret = btrfs_insert_dir_item(trans, root, buf, strlen(buf), dir_oid, &key, BTRFS_FT_UNKNOWN); @@ -312,7 +312,7 @@ static int empty_tree(struct btrfs_trans_handle *trans, struct btrfs_root key.offset = (u64)-1; key.flags = 0; - btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY); + key.type = BTRFS_DIR_ITEM_KEY; key.objectid = dir_oid; while(nr-- >= 0) { btrfs_init_path(&path); diff --git a/extent-tree.c b/extent-tree.c index fb627940..2cdf3c27 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -2538,7 +2538,7 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, int wrapped = 0; WARN_ON(num_bytes < root->sectorsize); - btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY); + ins->type = BTRFS_EXTENT_ITEM_KEY; search_start = stripe_align(root, search_start); @@ -3231,7 +3231,7 @@ int btrfs_read_block_groups(struct btrfs_root *root) root = info->extent_root; key.objectid = 0; key.offset = 0; - btrfs_set_key_type(&key, BTRFS_BLOCK_GROUP_ITEM_KEY); + key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; path = btrfs_alloc_path(); if (!path) return -ENOMEM; @@ -3313,7 +3313,7 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, cache->key.objectid = chunk_offset; cache->key.offset = size; - btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY); + cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; btrfs_set_block_group_used(&cache->item, bytes_used); btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid); cache->flags = type; @@ -3425,7 +3425,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, cache->key.objectid = cur_start; cache->key.offset = group_size; - btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY); + cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; btrfs_set_block_group_used(&cache->item, 0); btrfs_set_block_group_chunk_objectid(&cache->item, @@ -3869,7 +3869,7 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans, btrfs_init_path(&path); key.offset = 0; key.objectid = 0; - btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); + key.type = BTRFS_EXTENT_ITEM_KEY; ret = btrfs_search_slot(trans, root->fs_info->extent_root, &key, &path, 0, 0); if (ret < 0) @@ -4061,7 +4061,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, btrfs_release_path(path); ins_key.objectid = objectid; ins_key.offset = file_pos; - btrfs_set_key_type(&ins_key, BTRFS_EXTENT_DATA_KEY); + ins_key.type = BTRFS_EXTENT_DATA_KEY; ret = btrfs_insert_empty_item(trans, root, path, &ins_key, sizeof(*fi)); if (ret) diff --git a/file-item.c b/file-item.c index 55d2d475..3d57c6bd 100644 --- a/file-item.c +++ b/file-item.c @@ -47,7 +47,7 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans, file_key.objectid = objectid; file_key.offset = pos; - btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY); + file_key.type = BTRFS_EXTENT_DATA_KEY; ret = btrfs_insert_empty_item(trans, root, path, &file_key, sizeof(*item)); @@ -92,7 +92,7 @@ int btrfs_insert_inline_extent(struct btrfs_trans_handle *trans, key.objectid = objectid; key.offset = offset; - btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); + key.type = BTRFS_EXTENT_DATA_KEY; datasize = btrfs_file_extent_calc_inline_size(size); ret = btrfs_insert_empty_item(trans, root, path, &key, datasize); @@ -137,7 +137,7 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans, file_key.objectid = BTRFS_EXTENT_CSUM_OBJECTID; file_key.offset = bytenr; - btrfs_set_key_type(&file_key, BTRFS_EXTENT_CSUM_KEY); + file_key.type = BTRFS_EXTENT_CSUM_KEY; ret = btrfs_search_slot(trans, root, &file_key, path, 0, cow); if (ret < 0) goto fail; diff --git a/inode-item.c b/inode-item.c index 522d25a4..d563d4ee 100644 --- a/inode-item.c +++ b/inode-item.c @@ -64,7 +64,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, key.objectid = inode_objectid; key.offset = ref_objectid; - btrfs_set_key_type(&key, BTRFS_INODE_REF_KEY); + key.type = BTRFS_INODE_REF_KEY; path = btrfs_alloc_path(); if (!path) diff --git a/mkfs.c b/mkfs.c index a4b0ce7c..15704f9b 100644 --- a/mkfs.c +++ b/mkfs.c @@ -415,7 +415,7 @@ static int add_directory_items(struct btrfs_trans_handle *trans, location.objectid = objectid; location.offset = 0; - btrfs_set_key_type(&location, BTRFS_INODE_ITEM_KEY); + location.type = BTRFS_INODE_ITEM_KEY; if (S_ISDIR(st->st_mode)) filetype = BTRFS_FT_DIR; @@ -554,7 +554,7 @@ static int add_inode_items(struct btrfs_trans_handle *trans, inode_key.objectid = objectid; inode_key.offset = 0; - btrfs_set_key_type(&inode_key, BTRFS_INODE_ITEM_KEY); + inode_key.type = BTRFS_INODE_ITEM_KEY; ret = btrfs_insert_inode(trans, root, objectid, &btrfs_inode); @@ -835,7 +835,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans, root_dir_key.objectid = btrfs_root_dirid(&root->root_item); root_dir_key.offset = 0; - btrfs_set_key_type(&root_dir_key, BTRFS_INODE_ITEM_KEY); + root_dir_key.type = BTRFS_INODE_ITEM_KEY; ret = btrfs_lookup_inode(trans, root, &path, &root_dir_key, 1); if (ret) { error("failed to lookup root dir: %d", ret); diff --git a/quick-test.c b/quick-test.c index ffde85d9..f99ecc38 100644 --- a/quick-test.c +++ b/quick-test.c @@ -57,7 +57,7 @@ int main(int ac, char **av) { } trans = btrfs_start_transaction(root, 1); srand(55); - btrfs_set_key_type(&ins, BTRFS_STRING_ITEM_KEY); + ins.type = BTRFS_STRING_ITEM_KEY; for (i = 0; i < run_size; i++) { num = next_key(i, max_key); // num = i; diff --git a/random-test.c b/random-test.c index b7c6cdb3..410a110b 100644 --- a/random-test.c +++ b/random-test.c @@ -37,7 +37,7 @@ static int setup_key(struct radix_tree_root *root, struct btrfs_key *key, int ret; key->flags = 0; - btrfs_set_key_type(key, BTRFS_STRING_ITEM_KEY); + key->type = BTRFS_STRING_ITEM_KEY; key->offset = 0; again: ret = radix_tree_gang_lookup(root, (void **)res, num, 2); @@ -184,7 +184,7 @@ static int empty_tree(struct btrfs_trans_handle *trans, struct btrfs_root key.offset = 0; key.flags = 0; - btrfs_set_key_type(&key, BTRFS_STRING_ITEM_KEY); + key.type = BTRFS_STRING_ITEM_KEY; key.objectid = (unsigned long)-1; while(nr-- >= 0) { btrfs_init_path(&path); @@ -288,7 +288,7 @@ static int fill_radix(struct btrfs_root *root, struct radix_tree_root *radix) key.offset = 0; key.flags = 0; - btrfs_set_key_type(&key, BTRFS_STRING_ITEM_KEY); + key.type = BTRFS_STRING_ITEM_KEY; key.objectid = (unsigned long)-1; while(1) { btrfs_init_path(&path); -- 2.34.1