diff mbox series

[RFC,ONLY,4/6] btrfs-progs: allow zoned RAID1

Message ID 20220518091716.786452-5-johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: raid-stripe-tree support for progs | expand

Commit Message

Johannes Thumshirn May 18, 2022, 9:17 a.m. UTC
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 kernel-shared/zoned.c | 20 +++++++++++++++-----
 kernel-shared/zoned.h |  4 ++--
 mkfs/main.c           |  4 ++--
 3 files changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
index 396b74f0d906..7d6f4357ea9a 100644
--- a/kernel-shared/zoned.c
+++ b/kernel-shared/zoned.c
@@ -775,7 +775,7 @@  out:
 	return ret;
 }
 
-bool zoned_profile_supported(u64 map_type)
+bool zoned_profile_supported(u64 map_type, bool rst)
 {
 	bool data = (map_type & BTRFS_BLOCK_GROUP_DATA);
 	u64 flags = (map_type & BTRFS_BLOCK_GROUP_PROFILE_MASK);
@@ -784,9 +784,18 @@  bool zoned_profile_supported(u64 map_type)
 	if (flags == 0)
 		return true;
 
-	/* We can support DUP on metadata */
-	if (!data && (flags & BTRFS_BLOCK_GROUP_DUP))
-		return true;
+	if (data) {
+		/* Data RAID1 needs a raid-stripe-tree */
+		if ((flags & BTRFS_BLOCK_GROUP_RAID1_MASK) && rst)
+			return true;
+	} else {
+		/* We can support DUP on metadata/system */
+		if (flags & BTRFS_BLOCK_GROUP_DUP)
+			return true;
+		/* We can support RAID1 on metadata/system */
+		if (flags & BTRFS_BLOCK_GROUP_RAID1_MASK)
+			return true;
+	}
 
 	/* All other profiles are not supported yet */
 	return false;
@@ -903,7 +912,8 @@  int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
 		}
 	}
 
-	if (!zoned_profile_supported(map->type)) {
+	// XXX: not sure how to do yet
+	if (!zoned_profile_supported(map->type, true)) {
 		error("zoned: profile %s not yet supported",
 		      btrfs_group_profile_str(map->type));
 		ret = -EINVAL;
diff --git a/kernel-shared/zoned.h b/kernel-shared/zoned.h
index cc0d6b6f166d..c56788bcf07b 100644
--- a/kernel-shared/zoned.h
+++ b/kernel-shared/zoned.h
@@ -132,7 +132,7 @@  static inline bool btrfs_dev_is_empty_zone(struct btrfs_device *device, u64 pos)
 	return zinfo->zones[zno].cond == BLK_ZONE_COND_EMPTY;
 }
 
-bool zoned_profile_supported(u64 map_type);
+bool zoned_profile_supported(u64 map_type, bool rst);
 int btrfs_reset_dev_zone(int fd, struct blk_zone *zone);
 u64 btrfs_find_allocatable_zones(struct btrfs_device *device, u64 hole_start,
 				 u64 hole_end, u64 num_bytes);
@@ -213,7 +213,7 @@  static inline int btrfs_wipe_temporary_sb(struct btrfs_fs_devices *fs_devices)
 	return 0;
 }
 
-static inline bool zoned_profile_supported(u64 map_type)
+static inline bool zoned_profile_supported(u64 map_type, bool rst)
 {
 	return false;
 }
diff --git a/mkfs/main.c b/mkfs/main.c
index a603ec5896f3..46dbc4c0c363 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1424,8 +1424,8 @@  int BOX_MAIN(mkfs)(int argc, char **argv)
 	if (ret)
 		goto error;
 
-	if (zoned && (!zoned_profile_supported(BTRFS_BLOCK_GROUP_METADATA | metadata_profile) ||
-		      !zoned_profile_supported(BTRFS_BLOCK_GROUP_DATA | data_profile))) {
+	if (zoned && (!zoned_profile_supported(BTRFS_BLOCK_GROUP_METADATA | metadata_profile, runtime_features & BTRFS_RUNTIME_FEATURE_RAID_STRIPE_TREE) ||
+		      !zoned_profile_supported(BTRFS_BLOCK_GROUP_DATA | data_profile, runtime_features & BTRFS_RUNTIME_FEATURE_RAID_STRIPE_TREE))) {
 		error("zoned mode does not yet support RAID/DUP profiles, please specify '-d single -m single' manually");
 		goto error;
 	}