Use the same macro tricks as in kernel code.
Signed-off-by: David Sterba <dsterba@suse.com>
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;
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;
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)
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",
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;
* 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 "
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;
}
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;
}
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");
* 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)
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;
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) {
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;
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;
}
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)
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,
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,
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);
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;
}
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,
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.