diff mbox series

[04/26] btrfs-progs: zoned: add new ZONED feature flag

Message ID c222a684214512e36fc721ee23ded5145bf9d89c.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
With the zoned feature enabled, a zoned block device-aware btrfs allocates
block groups aligned to the device zones and always write in sequential
zones at the zone write pointer position.

It also supports "emulated" zoned mode on a non-zoned device. In the
emulated mode, btrfs emulates conventional zones by slicing the device with
a fixed size.

We don't support conversion from the ext4 volume with the zoned feature
because we can't be sure all the converted block groups are aligned to zone
boundaries.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 common/fsfeatures.c        | 8 ++++++++
 common/fsfeatures.h        | 3 ++-
 kernel-shared/ctree.h      | 4 +++-
 kernel-shared/print-tree.c | 1 +
 4 files changed, 14 insertions(+), 2 deletions(-)

Comments

Johannes Thumshirn April 26, 2021, 7:45 a.m. UTC | #1
On 26/04/2021 08:28, Naohiro Aota wrote:
> diff --git a/common/fsfeatures.c b/common/fsfeatures.c
> index 569208a9e5b1..c0793339b531 100644
> --- a/common/fsfeatures.c
> +++ b/common/fsfeatures.c
> @@ -100,6 +100,14 @@ static const struct btrfs_feature mkfs_features[] = {
>  		NULL, 0,
>  		NULL, 0,
>  		"RAID1 with 3 or 4 copies" },
> +#ifdef BTRFS_ZONED
> +	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
> +		"zoned",
> +		NULL, 0,
> +		NULL, 0,
> +		NULL, 0,
> +		"support Zoned devices" },
> +#endif

Shouldn't we set the compat version to 5.12?
I.e.:
#ifdef BTRFS_ZONED
	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
		"zoned",
		VERSION_TO_STRING2(5,12),
		NULL, 0,
		NULL, 0,
		"support Zoned devices" },
#endif
David Sterba April 27, 2021, 3:45 p.m. UTC | #2
On Mon, Apr 26, 2021 at 07:45:23AM +0000, Johannes Thumshirn wrote:
> On 26/04/2021 08:28, Naohiro Aota wrote:
> > diff --git a/common/fsfeatures.c b/common/fsfeatures.c
> > index 569208a9e5b1..c0793339b531 100644
> > --- a/common/fsfeatures.c
> > +++ b/common/fsfeatures.c
> > @@ -100,6 +100,14 @@ static const struct btrfs_feature mkfs_features[] = {
> >  		NULL, 0,
> >  		NULL, 0,
> >  		"RAID1 with 3 or 4 copies" },
> > +#ifdef BTRFS_ZONED
> > +	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
> > +		"zoned",
> > +		NULL, 0,
> > +		NULL, 0,
> > +		NULL, 0,
> > +		"support Zoned devices" },
> > +#endif
> 
> Shouldn't we set the compat version to 5.12?
> I.e.:
> #ifdef BTRFS_ZONED
> 	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
> 		"zoned",
> 		VERSION_TO_STRING2(5,12),
> 		NULL, 0,
> 		NULL, 0,
> 		"support Zoned devices" },
> #endif

Folded in, thanks.
David Sterba April 27, 2021, 3:46 p.m. UTC | #3
On Mon, Apr 26, 2021 at 03:27:20PM +0900, Naohiro Aota wrote:
> With the zoned feature enabled, a zoned block device-aware btrfs allocates
> block groups aligned to the device zones and always write in sequential
> zones at the zone write pointer position.
> 
> It also supports "emulated" zoned mode on a non-zoned device. In the
> emulated mode, btrfs emulates conventional zones by slicing the device with
> a fixed size.
> 
> We don't support conversion from the ext4 volume with the zoned feature
> because we can't be sure all the converted block groups are aligned to zone
> boundaries.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
>  common/fsfeatures.c        | 8 ++++++++
>  common/fsfeatures.h        | 3 ++-
>  kernel-shared/ctree.h      | 4 +++-
>  kernel-shared/print-tree.c | 1 +
>  4 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/common/fsfeatures.c b/common/fsfeatures.c
> index 569208a9e5b1..c0793339b531 100644
> --- a/common/fsfeatures.c
> +++ b/common/fsfeatures.c
> @@ -100,6 +100,14 @@ static const struct btrfs_feature mkfs_features[] = {
>  		NULL, 0,
>  		NULL, 0,
>  		"RAID1 with 3 or 4 copies" },
> +#ifdef BTRFS_ZONED
> +	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
> +		"zoned",
> +		NULL, 0,
> +		NULL, 0,
> +		NULL, 0,
> +		"support Zoned devices" },
> +#endif
>  	/* Keep this one last */
>  	{ "list-all", BTRFS_FEATURE_LIST_ALL, NULL }
>  };
> diff --git a/common/fsfeatures.h b/common/fsfeatures.h
> index 74ec2a21caf6..1a7d7f62897f 100644
> --- a/common/fsfeatures.h
> +++ b/common/fsfeatures.h
> @@ -25,7 +25,8 @@
>  		| BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
>  
>  /*
> - * Avoid multi-device features (RAID56) and mixed block groups
> + * Avoid multi-device features (RAID56), mixed block groups, and zoned
> + * btrfs
>   */
>  #define BTRFS_CONVERT_ALLOWED_FEATURES				\
>  	(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF			\

Looks like BTRFS_FEATURE_INCOMPAT_ZONED should be here.
Naohiro Aota April 28, 2021, 12:07 a.m. UTC | #4
On Tue, Apr 27, 2021 at 05:46:36PM +0200, David Sterba wrote:
> On Mon, Apr 26, 2021 at 03:27:20PM +0900, Naohiro Aota wrote:
> > With the zoned feature enabled, a zoned block device-aware btrfs allocates
> > block groups aligned to the device zones and always write in sequential
> > zones at the zone write pointer position.
> > 
> > It also supports "emulated" zoned mode on a non-zoned device. In the
> > emulated mode, btrfs emulates conventional zones by slicing the device with
> > a fixed size.
> > 
> > We don't support conversion from the ext4 volume with the zoned feature
> > because we can't be sure all the converted block groups are aligned to zone
> > boundaries.
> > 
> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> > ---
> >  common/fsfeatures.c        | 8 ++++++++
> >  common/fsfeatures.h        | 3 ++-
> >  kernel-shared/ctree.h      | 4 +++-
> >  kernel-shared/print-tree.c | 1 +
> >  4 files changed, 14 insertions(+), 2 deletions(-)
> > 
> > diff --git a/common/fsfeatures.c b/common/fsfeatures.c
> > index 569208a9e5b1..c0793339b531 100644
> > --- a/common/fsfeatures.c
> > +++ b/common/fsfeatures.c
> > @@ -100,6 +100,14 @@ static const struct btrfs_feature mkfs_features[] = {
> >  		NULL, 0,
> >  		NULL, 0,
> >  		"RAID1 with 3 or 4 copies" },
> > +#ifdef BTRFS_ZONED
> > +	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
> > +		"zoned",
> > +		NULL, 0,
> > +		NULL, 0,
> > +		NULL, 0,
> > +		"support Zoned devices" },
> > +#endif
> >  	/* Keep this one last */
> >  	{ "list-all", BTRFS_FEATURE_LIST_ALL, NULL }
> >  };
> > diff --git a/common/fsfeatures.h b/common/fsfeatures.h
> > index 74ec2a21caf6..1a7d7f62897f 100644
> > --- a/common/fsfeatures.h
> > +++ b/common/fsfeatures.h
> > @@ -25,7 +25,8 @@
> >  		| BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
> >  
> >  /*
> > - * Avoid multi-device features (RAID56) and mixed block groups
> > + * Avoid multi-device features (RAID56), mixed block groups, and zoned
> > + * btrfs
> >   */
> >  #define BTRFS_CONVERT_ALLOWED_FEATURES				\
> >  	(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF			\
> 
> Looks like BTRFS_FEATURE_INCOMPAT_ZONED should be here.

Since, we do not support converting ext4 to zoned btrfs, I didn't list
it here. I do not think we can support the converting easily, since
ext4's data might not aligned to the zone boundary.
diff mbox series

Patch

diff --git a/common/fsfeatures.c b/common/fsfeatures.c
index 569208a9e5b1..c0793339b531 100644
--- a/common/fsfeatures.c
+++ b/common/fsfeatures.c
@@ -100,6 +100,14 @@  static const struct btrfs_feature mkfs_features[] = {
 		NULL, 0,
 		NULL, 0,
 		"RAID1 with 3 or 4 copies" },
+#ifdef BTRFS_ZONED
+	{ "zoned", BTRFS_FEATURE_INCOMPAT_ZONED,
+		"zoned",
+		NULL, 0,
+		NULL, 0,
+		NULL, 0,
+		"support Zoned devices" },
+#endif
 	/* Keep this one last */
 	{ "list-all", BTRFS_FEATURE_LIST_ALL, NULL }
 };
diff --git a/common/fsfeatures.h b/common/fsfeatures.h
index 74ec2a21caf6..1a7d7f62897f 100644
--- a/common/fsfeatures.h
+++ b/common/fsfeatures.h
@@ -25,7 +25,8 @@ 
 		| BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA)
 
 /*
- * Avoid multi-device features (RAID56) and mixed block groups
+ * Avoid multi-device features (RAID56), mixed block groups, and zoned
+ * btrfs
  */
 #define BTRFS_CONVERT_ALLOWED_FEATURES				\
 	(BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF			\
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 7683b8bbf0b4..77a5ad488104 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -495,6 +495,7 @@  struct btrfs_super_block {
 #define BTRFS_FEATURE_INCOMPAT_NO_HOLES		(1ULL << 9)
 #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID    (1ULL << 10)
 #define BTRFS_FEATURE_INCOMPAT_RAID1C34		(1ULL << 11)
+#define BTRFS_FEATURE_INCOMPAT_ZONED		(1ULL << 12)
 
 #define BTRFS_FEATURE_COMPAT_SUPP		0ULL
 
@@ -519,7 +520,8 @@  struct btrfs_super_block {
 	 BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA |	\
 	 BTRFS_FEATURE_INCOMPAT_NO_HOLES |		\
 	 BTRFS_FEATURE_INCOMPAT_RAID1C34 |		\
-	 BTRFS_FEATURE_INCOMPAT_METADATA_UUID)
+	 BTRFS_FEATURE_INCOMPAT_METADATA_UUID |		\
+	 BTRFS_FEATURE_INCOMPAT_ZONED)
 
 /*
  * A leaf is full of items. offset and size tell us where to find
diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 92df05c15d68..76853aee8634 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -1614,6 +1614,7 @@  static struct readable_flag_entry incompat_flags_array[] = {
 	DEF_INCOMPAT_FLAG_ENTRY(NO_HOLES),
 	DEF_INCOMPAT_FLAG_ENTRY(METADATA_UUID),
 	DEF_INCOMPAT_FLAG_ENTRY(RAID1C34),
+	DEF_INCOMPAT_FLAG_ENTRY(ZONED),
 };
 static const int incompat_flags_num = sizeof(incompat_flags_array) /
 				      sizeof(struct readable_flag_entry);