btrfs-progs: make incompat bit wrappers more compact
Use the same macro tricks as in kernel code. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2f4e20a47a
commit
dfbdde35fc
|
@ -739,8 +739,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
|
|||
|
||||
key.objectid = bytenr;
|
||||
key.offset = (u64)-1;
|
||||
if (btrfs_fs_incompat(fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA))
|
||||
if (btrfs_fs_incompat(fs_info, SKINNY_METADATA))
|
||||
key.type = BTRFS_METADATA_ITEM_KEY;
|
||||
else
|
||||
key.type = BTRFS_EXTENT_ITEM_KEY;
|
||||
|
@ -1136,8 +1135,7 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
|
|||
struct btrfs_extent_item *ei;
|
||||
struct btrfs_key key;
|
||||
|
||||
if (btrfs_fs_incompat(fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA))
|
||||
if (btrfs_fs_incompat(fs_info, SKINNY_METADATA))
|
||||
key.type = BTRFS_METADATA_ITEM_KEY;
|
||||
else
|
||||
key.type = BTRFS_EXTENT_ITEM_KEY;
|
||||
|
|
22
cmds-check.c
22
cmds-check.c
|
@ -5144,8 +5144,7 @@ static int check_fs_roots_v2(struct btrfs_fs_info *fs_info)
|
|||
int ret;
|
||||
int err = 0;
|
||||
|
||||
ext_ref = btrfs_fs_incompat(fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF);
|
||||
ext_ref = btrfs_fs_incompat(fs_info, EXTENDED_IREF);
|
||||
|
||||
path = btrfs_alloc_path();
|
||||
if (!path)
|
||||
|
@ -7038,8 +7037,7 @@ static int check_space_cache(struct btrfs_root *root)
|
|||
btrfs_remove_free_space_cache(cache);
|
||||
}
|
||||
|
||||
if (btrfs_fs_compat_ro(root->fs_info,
|
||||
BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE)) {
|
||||
if (btrfs_fs_compat_ro(root->fs_info, FREE_SPACE_TREE)) {
|
||||
ret = exclude_super_stripes(root, cache);
|
||||
if (ret) {
|
||||
fprintf(stderr, "could not exclude super stripes: %s\n",
|
||||
|
@ -10015,8 +10013,7 @@ static int check_tree_block_ref(struct btrfs_root *root,
|
|||
|
||||
btrfs_init_path(&path);
|
||||
key.objectid = bytenr;
|
||||
if (btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA))
|
||||
if (btrfs_fs_incompat(root->fs_info, SKINNY_METADATA))
|
||||
key.type = BTRFS_METADATA_ITEM_KEY;
|
||||
else
|
||||
key.type = BTRFS_EXTENT_ITEM_KEY;
|
||||
|
@ -11788,7 +11785,7 @@ static int reinit_extent_tree(struct btrfs_trans_handle *trans,
|
|||
* the leaves of any fs roots and pin down the bytes for any file
|
||||
* extents we find. Not hard but why do it if we don't have to?
|
||||
*/
|
||||
if (btrfs_fs_incompat(fs_info, BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS)) {
|
||||
if (btrfs_fs_incompat(fs_info, MIXED_GROUPS)) {
|
||||
fprintf(stderr, "We don't support re-initing the extent tree "
|
||||
"for mixed block groups yet, please notify a btrfs "
|
||||
"developer you want to do this so they can add this "
|
||||
|
@ -12750,8 +12747,7 @@ int cmd_check(int argc, char **argv)
|
|||
global_info = info;
|
||||
root = info->fs_root;
|
||||
if (clear_space_cache == 1) {
|
||||
if (btrfs_fs_compat_ro(info,
|
||||
BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE)) {
|
||||
if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE)) {
|
||||
error(
|
||||
"free space cache v2 detected, use --clear-space-cache v2");
|
||||
ret = 1;
|
||||
|
@ -12767,8 +12763,7 @@ int cmd_check(int argc, char **argv)
|
|||
}
|
||||
goto close_out;
|
||||
} else if (clear_space_cache == 2) {
|
||||
if (!btrfs_fs_compat_ro(info,
|
||||
BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE)) {
|
||||
if (!btrfs_fs_compat_ro(info, FREE_SPACE_TREE)) {
|
||||
printf("no free space cache v2 to clear\n");
|
||||
ret = 0;
|
||||
goto close_out;
|
||||
|
@ -12921,7 +12916,7 @@ int cmd_check(int argc, char **argv)
|
|||
}
|
||||
|
||||
if (!ctx.progress_enabled) {
|
||||
if (btrfs_fs_compat_ro(info, BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE))
|
||||
if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE))
|
||||
fprintf(stderr, "checking free space tree\n");
|
||||
else
|
||||
fprintf(stderr, "checking free space cache\n");
|
||||
|
@ -12937,8 +12932,7 @@ int cmd_check(int argc, char **argv)
|
|||
* are no gaps in the file extents for inodes, otherwise we can just
|
||||
* ignore it when this happens.
|
||||
*/
|
||||
no_holes = btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_NO_HOLES);
|
||||
no_holes = btrfs_fs_incompat(root->fs_info, NO_HOLES);
|
||||
if (!ctx.progress_enabled)
|
||||
fprintf(stderr, "checking fs roots\n");
|
||||
if (check_mode == CHECK_MODE_LOWMEM)
|
||||
|
|
10
ctree.h
10
ctree.h
|
@ -2441,14 +2441,20 @@ static inline u32 btrfs_level_size(struct btrfs_root *root, int level) {
|
|||
return root->nodesize;
|
||||
}
|
||||
|
||||
static inline int btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
|
||||
#define btrfs_fs_incompat(fs_info, opt) \
|
||||
__btrfs_fs_incompat((fs_info), BTRFS_FEATURE_INCOMPAT_##opt)
|
||||
|
||||
static inline int __btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
|
||||
{
|
||||
struct btrfs_super_block *disk_super;
|
||||
disk_super = fs_info->super_copy;
|
||||
return !!(btrfs_super_incompat_flags(disk_super) & flag);
|
||||
}
|
||||
|
||||
static inline int btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
|
||||
#define btrfs_fs_compat_ro(fs_info, opt) \
|
||||
__btrfs_fs_compat_ro((fs_info), BTRFS_FEATURE_COMPAT_RO_##opt)
|
||||
|
||||
static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
|
||||
{
|
||||
struct btrfs_super_block *disk_super;
|
||||
disk_super = fs_info->super_copy;
|
||||
|
|
|
@ -1063,7 +1063,7 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
|
|||
if (ret == 0)
|
||||
fs_info->quota_enabled = 1;
|
||||
|
||||
if (btrfs_fs_compat_ro(fs_info, BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE)) {
|
||||
if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) {
|
||||
ret = find_and_setup_root(root, fs_info, BTRFS_FREE_SPACE_TREE_OBJECTID,
|
||||
fs_info->free_space_root);
|
||||
if (ret) {
|
||||
|
|
|
@ -995,8 +995,7 @@ static int lookup_inline_extent_backref(struct btrfs_trans_handle *trans,
|
|||
int ret;
|
||||
int err = 0;
|
||||
int skinny_metadata =
|
||||
btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
||||
btrfs_fs_incompat(root->fs_info, SKINNY_METADATA);
|
||||
|
||||
key.objectid = bytenr;
|
||||
key.type = BTRFS_EXTENT_ITEM_KEY;
|
||||
|
@ -1456,8 +1455,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
|
|||
u64 extent_flags;
|
||||
|
||||
if (metadata &&
|
||||
!btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)) {
|
||||
!btrfs_fs_incompat(root->fs_info, SKINNY_METADATA)) {
|
||||
offset = root->nodesize;
|
||||
metadata = 0;
|
||||
}
|
||||
|
@ -1552,8 +1550,7 @@ int btrfs_set_block_flags(struct btrfs_trans_handle *trans,
|
|||
struct btrfs_extent_item *item;
|
||||
u32 item_size;
|
||||
int skinny_metadata =
|
||||
btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
||||
btrfs_fs_incompat(root->fs_info, SKINNY_METADATA);
|
||||
|
||||
path = btrfs_alloc_path();
|
||||
if (!path)
|
||||
|
@ -2079,8 +2076,7 @@ static int finish_current_insert(struct btrfs_trans_handle *trans,
|
|||
struct btrfs_key key;
|
||||
int ret;
|
||||
int skinny_metadata =
|
||||
btrfs_fs_incompat(extent_root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
||||
btrfs_fs_incompat(extent_root->fs_info, SKINNY_METADATA);
|
||||
|
||||
while(1) {
|
||||
ret = find_first_extent_bit(&info->extent_ins, 0, &start,
|
||||
|
@ -2193,8 +2189,7 @@ static int __free_extent(struct btrfs_trans_handle *trans,
|
|||
u32 item_size;
|
||||
u64 refs;
|
||||
int skinny_metadata =
|
||||
btrfs_fs_incompat(extent_root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
||||
btrfs_fs_incompat(extent_root->fs_info, SKINNY_METADATA);
|
||||
|
||||
if (root->fs_info->free_extent_hook) {
|
||||
root->fs_info->free_extent_hook(trans, root, bytenr, num_bytes,
|
||||
|
@ -2726,9 +2721,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
|
|||
struct btrfs_path *path;
|
||||
struct extent_buffer *leaf;
|
||||
u32 size = sizeof(*extent_item) + sizeof(*iref);
|
||||
int skinny_metadata =
|
||||
btrfs_fs_incompat(fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
|
||||
int skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
|
||||
|
||||
if (!skinny_metadata)
|
||||
size += sizeof(*block_info);
|
||||
|
@ -2800,8 +2793,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
|
|||
set_state_private(&root->fs_info->extent_ins,
|
||||
ins->objectid, (unsigned long)extent_op);
|
||||
} else {
|
||||
if (btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)) {
|
||||
if (btrfs_fs_incompat(root->fs_info, SKINNY_METADATA)) {
|
||||
ins->offset = level;
|
||||
ins->type = BTRFS_METADATA_ITEM_KEY;
|
||||
}
|
||||
|
|
|
@ -106,8 +106,7 @@ out:
|
|||
btrfs_free_path(path);
|
||||
|
||||
if (ret == -EMLINK) {
|
||||
if (btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF))
|
||||
if (btrfs_fs_incompat(root->fs_info, EXTENDED_IREF))
|
||||
ret = btrfs_insert_inode_extref(trans, root, name,
|
||||
name_len,
|
||||
inode_objectid,
|
||||
|
@ -440,8 +439,7 @@ out:
|
|||
btrfs_free_path(path);
|
||||
|
||||
if (search_ext_refs &&
|
||||
btrfs_fs_incompat(root->fs_info,
|
||||
BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)) {
|
||||
btrfs_fs_incompat(root->fs_info, EXTENDED_IREF)) {
|
||||
/*
|
||||
* No refs were found, or we could not find the name in our ref
|
||||
* array. Find and remove the extended inode ref then.
|
||||
|
|
Loading…
Reference in New Issue