Skip to content

Commit

Permalink
btrfs: kill the key type accessor helpers
Browse files Browse the repository at this point in the history
btrfs_set_key_type and btrfs_key_type are used inconsistently along with
open coded variants. Other members of btrfs_key are accessed directly
without any helpers anyway.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
kdave authored and masoncl committed Sep 17, 2014
1 parent 3abdbd7 commit 962a298
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions fs/btrfs/backref.c
Expand Up @@ -1193,7 +1193,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);
Expand Down Expand Up @@ -1233,7 +1233,7 @@ int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
ret = -ENOENT;
if (found_key.objectid != inode_objectid)
break;
if (btrfs_key_type(&found_key) != BTRFS_INODE_EXTREF_KEY)
if (found_key.type != BTRFS_INODE_EXTREF_KEY)
break;

ret = 0;
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/delayed-inode.c
Expand Up @@ -1042,7 +1042,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
int ret;

key.objectid = node->inode_id;
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;

if (test_bit(BTRFS_DELAYED_NODE_DEL_IREF, &node->flags))
Expand Down Expand Up @@ -1099,7 +1099,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
search:
btrfs_release_path(path);

btrfs_set_key_type(&key, BTRFS_INODE_EXTREF_KEY);
key.type = BTRFS_INODE_EXTREF_KEY;
key.offset = -1;
ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
if (ret < 0)
Expand Down Expand Up @@ -1473,7 +1473,7 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
}

delayed_item->key.objectid = btrfs_ino(dir);
btrfs_set_key_type(&delayed_item->key, BTRFS_DIR_INDEX_KEY);
delayed_item->key.type = BTRFS_DIR_INDEX_KEY;
delayed_item->key.offset = index;

dir_item = (struct btrfs_dir_item *)delayed_item->data;
Expand Down Expand Up @@ -1542,7 +1542,7 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
return PTR_ERR(node);

item_key.objectid = btrfs_ino(dir);
btrfs_set_key_type(&item_key, BTRFS_DIR_INDEX_KEY);
item_key.type = BTRFS_DIR_INDEX_KEY;
item_key.offset = index;

ret = btrfs_delete_delayed_insertion_item(root, node, &item_key);
Expand Down
12 changes: 6 additions & 6 deletions fs/btrfs/dir-item.c
Expand Up @@ -86,7 +86,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
BUG_ON(name_len + data_len > BTRFS_MAX_XATTR_SIZE(root));

key.objectid = objectid;
btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY);
key.type = BTRFS_XATTR_ITEM_KEY;
key.offset = btrfs_name_hash(name, name_len);

data_size = sizeof(*dir_item) + name_len + data_len;
Expand Down Expand Up @@ -137,7 +137,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
u32 data_size;

key.objectid = btrfs_ino(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();
Expand Down Expand Up @@ -204,7 +204,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
int cow = mod != 0;

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

Expand Down Expand Up @@ -234,7 +234,7 @@ int btrfs_check_dir_item_collision(struct btrfs_root *root, u64 dir,
return -ENOMEM;

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

ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
Expand Down Expand Up @@ -297,7 +297,7 @@ btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
int cow = mod != 0;

key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
key.type = BTRFS_DIR_INDEX_KEY;
key.offset = objectid;

ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
Expand Down Expand Up @@ -367,7 +367,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
int cow = mod != 0;

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);
ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
if (ret < 0)
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/export.c
Expand Up @@ -70,7 +70,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
return ERR_PTR(-ESTALE);

key.objectid = root_objectid;
btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
key.type = BTRFS_ROOT_ITEM_KEY;
key.offset = (u64)-1;

index = srcu_read_lock(&fs_info->subvol_srcu);
Expand All @@ -82,7 +82,7 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
}

key.objectid = objectid;
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;

inode = btrfs_iget(sb, &key, root, NULL);
Expand Down
6 changes: 3 additions & 3 deletions fs/btrfs/extent-tree.c
Expand Up @@ -3097,7 +3097,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
for (i = 0; i < nritems; i++) {
if (level == 0) {
btrfs_item_key_to_cpu(buf, &key, i);
if (btrfs_key_type(&key) != BTRFS_EXTENT_DATA_KEY)
if (key.type != BTRFS_EXTENT_DATA_KEY)
continue;
fi = btrfs_item_ptr(buf, i,
struct btrfs_file_extent_item);
Expand Down Expand Up @@ -6464,7 +6464,7 @@ static noinline int find_free_extent(struct btrfs_root *orig_root,
bool have_caching_bg = false;

WARN_ON(num_bytes < root->sectorsize);
btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY);
ins->type = BTRFS_EXTENT_ITEM_KEY;
ins->objectid = 0;
ins->offset = 0;

Expand Down Expand Up @@ -9009,7 +9009,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;
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/extent_io.c
Expand Up @@ -4224,7 +4224,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
WARN_ON(!ret);
path->slots[0]--;
btrfs_item_key_to_cpu(path->nodes[0], &found_key, path->slots[0]);
found_type = btrfs_key_type(&found_key);
found_type = found_key.type;

/* No extents, but there might be delalloc bits */
if (found_key.objectid != btrfs_ino(inode) ||
Expand Down
12 changes: 6 additions & 6 deletions fs/btrfs/file-item.c
Expand Up @@ -55,7 +55,7 @@ int btrfs_insert_file_extent(struct btrfs_trans_handle *trans,
return -ENOMEM;
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;

path->leave_spinning = 1;
ret = btrfs_insert_empty_item(trans, root, path, &file_key,
Expand Down Expand Up @@ -100,7 +100,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;
Expand All @@ -111,7 +111,7 @@ btrfs_lookup_csum(struct btrfs_trans_handle *trans,
goto fail;
path->slots[0]--;
btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
if (btrfs_key_type(&found_key) != BTRFS_EXTENT_CSUM_KEY)
if (found_key.type != BTRFS_EXTENT_CSUM_KEY)
goto fail;

csum_offset = (bytenr - found_key.offset) >>
Expand Down Expand Up @@ -148,7 +148,7 @@ int btrfs_lookup_file_extent(struct btrfs_trans_handle *trans,

file_key.objectid = objectid;
file_key.offset = offset;
btrfs_set_key_type(&file_key, BTRFS_EXTENT_DATA_KEY);
file_key.type = BTRFS_EXTENT_DATA_KEY;
ret = btrfs_search_slot(trans, root, &file_key, path, ins_len, cow);
return ret;
}
Expand Down Expand Up @@ -720,7 +720,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
bytenr = sums->bytenr + total_bytes;
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;

item = btrfs_lookup_csum(trans, root, path, bytenr, 1);
if (!IS_ERR(item)) {
Expand Down Expand Up @@ -790,7 +790,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
csum_offset = (bytenr - found_key.offset) >>
root->fs_info->sb->s_blocksize_bits;

if (btrfs_key_type(&found_key) != BTRFS_EXTENT_CSUM_KEY ||
if (found_key.type != BTRFS_EXTENT_CSUM_KEY ||
found_key.objectid != BTRFS_EXTENT_CSUM_OBJECTID ||
csum_offset >= MAX_CSUM_ITEMS(root, csum_size)) {
goto insert;
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/file.c
Expand Up @@ -299,7 +299,7 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,

/* get the inode */
key.objectid = defrag->root;
btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
key.type = BTRFS_ROOT_ITEM_KEY;
key.offset = (u64)-1;

index = srcu_read_lock(&fs_info->subvol_srcu);
Expand All @@ -311,7 +311,7 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
}

key.objectid = defrag->ino;
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;
inode = btrfs_iget(fs_info->sb, &key, inode_root, NULL);
if (IS_ERR(inode)) {
Expand Down
12 changes: 6 additions & 6 deletions fs/btrfs/inode-item.c
Expand Up @@ -135,7 +135,7 @@ static int btrfs_del_inode_extref(struct btrfs_trans_handle *trans,
u32 item_size;

key.objectid = inode_objectid;
btrfs_set_key_type(&key, BTRFS_INODE_EXTREF_KEY);
key.type = BTRFS_INODE_EXTREF_KEY;
key.offset = btrfs_extref_hash(ref_objectid, name, name_len);

path = btrfs_alloc_path();
Expand Down Expand Up @@ -209,7 +209,7 @@ int btrfs_del_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)
Expand Down Expand Up @@ -337,7 +337,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)
Expand Down Expand Up @@ -400,7 +400,7 @@ int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
struct btrfs_key key;
int ret;
key.objectid = objectid;
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.type = BTRFS_INODE_ITEM_KEY;
key.offset = 0;

ret = btrfs_insert_empty_item(trans, root, path, &key,
Expand All @@ -420,13 +420,13 @@ int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
struct btrfs_key found_key;

ret = btrfs_search_slot(trans, root, location, path, ins_len, cow);
if (ret > 0 && btrfs_key_type(location) == BTRFS_ROOT_ITEM_KEY &&
if (ret > 0 && location->type == BTRFS_ROOT_ITEM_KEY &&
location->offset == (u64)-1 && path->slots[0] != 0) {
slot = path->slots[0] - 1;
leaf = path->nodes[0];
btrfs_item_key_to_cpu(leaf, &found_key, slot);
if (found_key.objectid == location->objectid &&
btrfs_key_type(&found_key) == btrfs_key_type(location)) {
found_key.type == location->type) {
path->slots[0]--;
return 0;
}
Expand Down

0 comments on commit 962a298

Please sign in to comment.