diff mbox series

[1/2] btrfs-progs: use profile_supported in mkfs as well

Message ID 20220126090403.57672-2-johannes.thumshirn@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: support DUP on metadata for zoned | expand

Commit Message

Johannes Thumshirn Jan. 26, 2022, 9:04 a.m. UTC
Currently we have two places checking if a block-group profile is
supported on a zoned device, one in mkfs/main.c and one in
kernel-shared/zoned.c.

Use the one from kernel-shared/zoned.c in mkfs as well, unifying all
checks.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 kernel-shared/zoned.c | 2 +-
 kernel-shared/zoned.h | 1 +
 mkfs/main.c           | 4 ++--
 3 files changed, 4 insertions(+), 3 deletions(-)

Comments

David Sterba Feb. 1, 2022, 4:33 p.m. UTC | #1
On Wed, Jan 26, 2022 at 01:04:02AM -0800, Johannes Thumshirn wrote:
> Currently we have two places checking if a block-group profile is
> supported on a zoned device, one in mkfs/main.c and one in
> kernel-shared/zoned.c.
> 
> Use the one from kernel-shared/zoned.c in mkfs as well, unifying all
> checks.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  kernel-shared/zoned.c | 2 +-
>  kernel-shared/zoned.h | 1 +
>  mkfs/main.c           | 4 ++--
>  3 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
> index 776576bc6c77..e6fd4b31b9d6 100644
> --- a/kernel-shared/zoned.c
> +++ b/kernel-shared/zoned.c
> @@ -808,7 +808,7 @@ out:
>  	return ret;
>  }
>  
> -static bool profile_supported(u64 flags)
> +bool profile_supported(u64 flags)

Making a function part of public APIs should go with a rename adding a
prefix, here it's supported profiles for zoned mode, but it's used
without any other context in mkfs so at last "zoned_profile_supported"
would be good. I'll update it.
diff mbox series

Patch

diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
index 776576bc6c77..e6fd4b31b9d6 100644
--- a/kernel-shared/zoned.c
+++ b/kernel-shared/zoned.c
@@ -808,7 +808,7 @@  out:
 	return ret;
 }
 
-static bool profile_supported(u64 flags)
+bool profile_supported(u64 flags)
 {
 	flags &= BTRFS_BLOCK_GROUP_PROFILE_MASK;
 
diff --git a/kernel-shared/zoned.h b/kernel-shared/zoned.h
index fbe9df8d9506..eedf20a79a6b 100644
--- a/kernel-shared/zoned.h
+++ b/kernel-shared/zoned.h
@@ -118,6 +118,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 profile_supported(u64 flags);
 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);
diff --git a/mkfs/main.c b/mkfs/main.c
index ce86a0dbdf42..78a5e8a0888f 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1334,8 +1334,8 @@  int BOX_MAIN(mkfs)(int argc, char **argv)
 	if (ret)
 		goto error;
 
-	if (zoned && ((metadata_profile | data_profile) &
-		      BTRFS_BLOCK_GROUP_PROFILE_MASK)) {
+	if (zoned && (!profile_supported(metadata_profile) ||
+		      !profile_supported(data_profile))) {
 		error("zoned mode does not yet support RAID/DUP profiles, please specify '-d single -m single' manually");
 		goto error;
 	}