@@ -172,6 +172,14 @@ static const struct btrfs_feature runtime_features[] = {
VERSION_TO_STRING2(safe, 4,9),
VERSION_TO_STRING2(default, 5,15),
.desc = "free space tree (space_cache=v2)"
+ }, {
+ .name = "extra-super-reserved",
+ .flag = BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED,
+ .sysfs_name = "extra_super_reserved",
+ VERSION_TO_STRING2(compat, 6,0),
+ VERSION_NULL(safe),
+ VERSION_NULL(default),
+ .desc = "extra super block reserved space for each device"
},
/* Keep this one last */
{
@@ -45,6 +45,7 @@
#define BTRFS_RUNTIME_FEATURE_QUOTA (1ULL << 0)
#define BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE (1ULL << 1)
+#define BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED (1ULL << 2)
void btrfs_list_all_fs_features(u64 mask_disallowed);
void btrfs_list_all_runtime_features(u64 mask_disallowed);
@@ -314,6 +314,8 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
BTRFS_RUNTIME_FEATURE_FREE_SPACE_TREE);
bool extent_tree_v2 = !!(cfg->features &
BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2);
+ bool extra_super_reserved = !!(cfg->runtime_features &
+ BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED);
/* Don't include the free space tree in the blocks to process. */
if (!free_space_tree)
@@ -324,6 +326,12 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
blocks_nr = ARRAY_SIZE(extent_tree_v2_blocks);
add_block_group = false;
}
+ /*
+ * The extra 1MiB should be enough for either write-intent bitmap or
+ * future full journal.
+ */
+ if (extra_super_reserved)
+ system_group_offset += SZ_1M;
if ((cfg->features & BTRFS_FEATURE_INCOMPAT_ZONED)) {
system_group_offset = zoned_system_group_offset(cfg->zone_size);
@@ -641,6 +649,14 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
goto out;
}
+ if (extra_super_reserved) {
+ u64 ro_flags = btrfs_super_compat_ro_flags(&super) |
+ BTRFS_FEATURE_COMPAT_RO_EXTRA_SUPER_RESERVED;
+
+ btrfs_set_super_compat_ro_flags(&super, ro_flags);
+ btrfs_set_super_reserved_bytes(&super, system_group_offset);
+ }
+
if (extent_tree_v2) {
ret = create_block_group_tree(fd, cfg, buf,
system_group_offset,
@@ -1239,6 +1239,15 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
features |= BTRFS_FEATURE_INCOMPAT_ZONED;
}
+ /*
+ * Runtime extra-super-reserved feature conflicts with zoned support,
+ * as it's for regular devices explicitly.
+ */
+ if (zoned && (runtime_features &
+ BTRFS_RUNTIME_FEATURE_EXTRA_SUPER_RESERVED)) {
+ error("extra-super-reserved runtime feature conflicts with zoned devices");
+ exit(1);
+ }
/*
* Set default profiles according to number of added devices.
* For mixed groups defaults are single/single.
This allows mkfs to reserved extra 1MiB (2MiB in total). The extra 1MiB should be large enough for either write-intent bitmap or full journal. Signed-off-by: Qu Wenruo <wqu@suse.com> --- common/fsfeatures.c | 8 ++++++++ common/fsfeatures.h | 1 + mkfs/common.c | 16 ++++++++++++++++ mkfs/main.c | 9 +++++++++ 4 files changed, 34 insertions(+)