diff mbox series

[21/26] btrfs-progs: mkfs: zoned: check incompatible features with zoned btrfs

Message ID e5868bb9c387edd53b3863efcc366056998b28c8.1619416549.git.naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: zoned: zoned block device support | expand

Commit Message

Naohiro Aota April 26, 2021, 6:27 a.m. UTC
This commit disables some features which are incompatible with zoned btrfs.

RAID/DUP is disabled because we cannot handle two zone append writes to
different zones in the kernel. MIXED_BG is disabled because the allocated
metadata region will be write holes for data writes. Space-cache (v1)
require in-place updatings.

It also disables the "--rootdir" option for now. The copying from a
directory needs some tweaks for zoned btrfs (e.g. zone size aware space
calculation), and we do not implement them yet.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 mkfs/common.c |  5 ++++-
 mkfs/main.c   | 23 +++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/mkfs/common.c b/mkfs/common.c
index 368f3b06f75e..6b0c434fbd6a 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -204,7 +204,10 @@  int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
 	btrfs_set_super_stripesize(&super, cfg->stripesize);
 	btrfs_set_super_csum_type(&super, cfg->csum_type);
 	btrfs_set_super_chunk_root_generation(&super, 1);
-	btrfs_set_super_cache_generation(&super, -1);
+	if (cfg->features & BTRFS_FEATURE_INCOMPAT_ZONED)
+		btrfs_set_super_cache_generation(&super, 0);
+	else
+		btrfs_set_super_cache_generation(&super, -1);
 	btrfs_set_super_incompat_flags(&super, cfg->features);
 	if (cfg->label)
 		__strncpy_null(super.label, cfg->label, BTRFS_LABEL_SIZE - 1);
diff --git a/mkfs/main.c b/mkfs/main.c
index 42e6e6b58b04..9407cdfa8fe7 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1191,6 +1191,23 @@  int BOX_MAIN(mkfs)(int argc, char **argv)
 		features |= BTRFS_FEATURE_INCOMPAT_RAID1C34;
 	}
 
+	if (zoned) {
+		if (source_dir_set) {
+			error("the option -r and zoned feature are incompatible");
+			exit(1);
+		}
+
+		if (features & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS) {
+			error("cannot enable mixed-bg with zoned feature");
+			exit(1);
+		}
+
+		if (features & BTRFS_FEATURE_INCOMPAT_RAID56) {
+			error("cannot enable RAID5/6 with zoned feature");
+			exit(1);
+		}
+	}
+
 	if (btrfs_check_nodesize(nodesize, sectorsize,
 				 features))
 		goto error;
@@ -1280,6 +1297,12 @@  int BOX_MAIN(mkfs)(int argc, char **argv)
 	if (ret)
 		goto error;
 
+	if (zoned && ((metadata_profile | data_profile) &
+			      BTRFS_BLOCK_GROUP_PROFILE_MASK)) {
+		error("cannot use RAID/DUP profile on zoned mode");
+		goto error;
+	}
+
 	dev_cnt--;
 
 	/*