Skip to contentSkip to conversation

btrfs: sysfs: advertise zoned support among features

PATCH In review David Sterba 5 participants 13 messages Jul 28, 2021 – Aug 19, 2021 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH 1/1 btrfs: sysfs: advertise zoned support among features

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

 fs/btrfs/sysfs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +9 -3
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
 BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
 BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
 BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
 	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
 	BTRFS_FEAT_ATTR_PTR(free_space_tree),
 	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 	BTRFS_FEAT_ATTR_PTR(zoned),
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
 BTRFS_ATTR(static_feature, supported_sectorsizes,
 	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);
+
 static struct attribute *btrfs_supported_static_feature_attrs[] = {
 	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
 	BTRFS_ATTR_PTR(static_feature, supported_checksums),
 	BTRFS_ATTR_PTR(static_feature, send_stream_version),
 	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
 	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
+	BTRFS_ATTR_PTR(static_feature, zoned),
 	NULL
 };
 
Signature · 1 line
2.31.1
#1 lore raw
Quoted 33 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

  fs/btrfs/sysfs.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +1 -2
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
  BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
  BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
  BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
  BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
  #endif
  #ifdef CONFIG_FS_VERITY

fs/btrfs/sysfs.c static struct attribute *btrfs_supported_feature_attrs[] = { · line 290

Quoted 8 lines
fs/btrfs/sysfs.c +1 -1
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
  	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
  	BTRFS_FEAT_ATTR_PTR(free_space_tree),
  	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
  	BTRFS_FEAT_ATTR_PTR(zoned),
  #endif
  #ifdef CONFIG_FS_VERITY

Looks good until here.

Quoted 9 lines
fs/btrfs/sysfs.c +5 -0
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
  BTRFS_ATTR(static_feature, supported_sectorsizes,
  	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 10 lines
fs/btrfs/sysfs.c +2 -0
+
  static struct attribute *btrfs_supported_static_feature_attrs[] = {
  	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
  	BTRFS_ATTR_PTR(static_feature, supported_checksums),
  	BTRFS_ATTR_PTR(static_feature, send_stream_version),
  	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
  	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
+	BTRFS_ATTR_PTR(static_feature, zoned),
  	NULL
  };

We don't need this part. btrfs_supported_feature_attrs will take care of showing zoned if when enabled on the mounted btrfs.

As of now, this patch fails with

    [ 44.464597] sysfs: cannot create duplicate filename 

'/fs/btrfs/features/zoned'

Thanks, Anand

#2 lore raw
Quoted 61 lines · Anand Jain
Quoted 33 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

  fs/btrfs/sysfs.c | 12 +++++++++---
  1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +1 -2
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
  BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
  BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
  BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
  BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
  #endif
  #ifdef CONFIG_FS_VERITY

fs/btrfs/sysfs.c static struct attribute *btrfs_supported_feature_attrs[] = { · line 290

Quoted 8 lines
fs/btrfs/sysfs.c +1 -1
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
  	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
  	BTRFS_FEAT_ATTR_PTR(free_space_tree),
  	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
  	BTRFS_FEAT_ATTR_PTR(zoned),
  #endif
  #ifdef CONFIG_FS_VERITY

Looks good until here.

Quoted 14 lines
fs/btrfs/sysfs.c +6 -0
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
  BTRFS_ATTR(static_feature, supported_sectorsizes,
  	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);
+
  static struct attribute *btrfs_supported_static_feature_attrs[] = {
  	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
  	BTRFS_ATTR_PTR(static_feature, supported_checksums),
  	BTRFS_ATTR_PTR(static_feature, send_stream_version),
Quoted 8 lines

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 5 lines
fs/btrfs/sysfs.c +1 -0
  	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
  	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
+	BTRFS_ATTR_PTR(static_feature, zoned),
  	NULL
  };

We don't need this part. btrfs_supported_feature_attrs will take care of showing zoned if when enabled on the mounted btrfs.

The idea is to put zoned also to the static features so the zoned support can be determined before mount.

Quoted 4 lines

As of now, this patch fails with

     [ 44.464597] sysfs: cannot create duplicate filename 

'/fs/btrfs/features/zoned'

I'll have a look.

#3 lore raw
Quoted 71 lines · David Sterba
Quoted 61 lines · Anand Jain
Quoted 33 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

   fs/btrfs/sysfs.c | 12 +++++++++---
   1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +1 -2
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
   BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
   BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
   BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
   BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
   #endif
   #ifdef CONFIG_FS_VERITY

fs/btrfs/sysfs.c static struct attribute *btrfs_supported_feature_attrs[] = { · line 290

Quoted 8 lines
fs/btrfs/sysfs.c +1 -1
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
   	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
   	BTRFS_FEAT_ATTR_PTR(free_space_tree),
   	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
   	BTRFS_FEAT_ATTR_PTR(zoned),
   #endif
   #ifdef CONFIG_FS_VERITY

Looks good until here.

Quoted 14 lines
fs/btrfs/sysfs.c +6 -0
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
   BTRFS_ATTR(static_feature, supported_sectorsizes,
   	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);
+
   static struct attribute *btrfs_supported_static_feature_attrs[] = {
   	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
   	BTRFS_ATTR_PTR(static_feature, supported_checksums),
   	BTRFS_ATTR_PTR(static_feature, send_stream_version),
Quoted 8 lines

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 5 lines
fs/btrfs/sysfs.c +1 -0
   	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
   	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
+	BTRFS_ATTR_PTR(static_feature, zoned),
   	NULL
   };

We don't need this part. btrfs_supported_feature_attrs will take care of showing zoned if when enabled on the mounted btrfs.

Quoted 2 lines

The idea is to put zoned also to the static features so the zoned support can be determined before mount.

As in the proposed patch which adds a table to figure out the correct
table to add the attribute, adding to the btrfs_supported_static_feature_attrs attribute list will add only to /sys/fs/btrfs/features, however adding the attribute to btrfs_supported_feature_attrs adds to both /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features.

-------------
btrfs_supported_static_feature_attrs /sys/fs/btrfs/features btrfs_supported_feature_attrs /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features (if visible)
-------------

Quoted 8 lines
Quoted 5 lines

As of now, this patch fails with

      [ 44.464597] sysfs: cannot create duplicate filename

'/fs/btrfs/features/zoned'

I'll have a look.

#4 lore raw
Quoted 6 lines · Anand Jain

As in the proposed patch which adds a table to figure out the correct
table to add the attribute, adding to the btrfs_supported_static_feature_attrs attribute list will add only to /sys/fs/btrfs/features, however adding the attribute to btrfs_supported_feature_attrs adds to both /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features.

I can't see it in the code right now, but that would mean that eg. zoned would show up in static features once such filesystem is mounted. And that does not happen or I'm missing something.

#5 lore raw
Quoted 8 lines · David Sterba
Quoted 6 lines · Anand Jain

As in the proposed patch which adds a table to figure out the correct
table to add the attribute, adding to the btrfs_supported_static_feature_attrs attribute list will add only to /sys/fs/btrfs/features, however adding the attribute to btrfs_supported_feature_attrs adds to both /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features.

Quoted 4 lines

I can't see it in the code right now, but that would mean that eg. zoned would show up in static features once such filesystem is mounted. And that does not happen or I'm missing something.

This happens because when initialising sysfs we create the btrfs_feature_attr_group which contains btrfs_supported_feature_attrs attributes, which have
#ifdef CONFIG_BLK_DEV_ZONED

BTRFS_FEAT_ATTR_PTR(zoned),

#endif

Subsequently you define the static feature via
BTRFS_ATTR(static_feature, zoned, zoned_show);

and finally we call:

ret = sysfs_merge_group(&btrfs_kset->kobj,
&btrfs_static_feature_attr_group);

Which merges the static feature to the feature group. That's why the message about duplication. So one of the 2 definitions needs to go.

#6 lore raw
Quoted 28 lines · Nikolay Borisov
Quoted 8 lines · David Sterba
Quoted 6 lines · Anand Jain

As in the proposed patch which adds a table to figure out the correct
table to add the attribute, adding to the btrfs_supported_static_feature_attrs attribute list will add only to /sys/fs/btrfs/features, however adding the attribute to btrfs_supported_feature_attrs adds to both /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features.

Quoted 4 lines

I can't see it in the code right now, but that would mean that eg. zoned would show up in static features once such filesystem is mounted. And that does not happen or I'm missing something.

This happens because when initialising sysfs we create the btrfs_feature_attr_group which contains btrfs_supported_feature_attrs attributes, which have
#ifdef CONFIG_BLK_DEV_ZONED

BTRFS_FEAT_ATTR_PTR(zoned),

#endif

Subsequently you define the static feature via
BTRFS_ATTR(static_feature, zoned, zoned_show);

Quoted 9 lines

and finally we call:

ret = sysfs_merge_group(&btrfs_kset->kobj,
&btrfs_static_feature_attr_group);

Which merges the static feature to the feature group. That's why the message about duplication. So one of the 2 definitions needs to go.

Looking at the maze that btrfs' sysfs code is it seems the decision which of the two sets to use when defining a feature is whether it can be enabled or not at runtime. I think for zoned block device we can't really disable the support at runtime? If so then it needs to only be defined as a static feature? Just because the kernel supports it doesn't necessarily mean it's going to be used if the underlying device is not zoned, right, it should depend on the runtime characteristics of the underlying device?

#7 lore raw
Quoted 37 lines · Nikolay Borisov
Quoted 34 lines · Nikolay Borisov
Quoted 8 lines · David Sterba
Quoted 6 lines · Anand Jain

As in the proposed patch which adds a table to figure out the correct
table to add the attribute, adding to the btrfs_supported_static_feature_attrs attribute list will add only to /sys/fs/btrfs/features, however adding the attribute to btrfs_supported_feature_attrs adds to both /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features.

Quoted 4 lines

I can't see it in the code right now, but that would mean that eg. zoned would show up in static features once such filesystem is mounted. And that does not happen or I'm missing something.

This happens because when initialising sysfs we create the btrfs_feature_attr_group which contains btrfs_supported_feature_attrs attributes, which have
#ifdef CONFIG_BLK_DEV_ZONED

BTRFS_FEAT_ATTR_PTR(zoned),

#endif

Subsequently you define the static feature via
BTRFS_ATTR(static_feature, zoned, zoned_show);

and finally we call:

ret = sysfs_merge_group(&btrfs_kset->kobj,
&btrfs_static_feature_attr_group);

Quoted 8 lines
Quoted 3 lines

Which merges the static feature to the feature group. That's why the message about duplication. So one of the 2 definitions needs to go.

Looking at the maze that btrfs' sysfs code is it seems the decision

which of the two sets to use when defining a feature is whether it can

...be enabled per fsid.
::

Quoted 2 lines

I think for zoned block device we can't
really disable the support at runtime?

Hmm. It is not like that. Suppose there are two btrfs filesystems on a system fsid1 and fsid2. fsid1 is zoned. fsid2 is a normal conventional device. Then on fsid1 zoned incompatible feature/flag is enabled and, on fsid2 it is not enabled.

So IMO zoned should be added to btrfs_supported_feature_attrs.

By doing this,
on /sys/fs/btrfs/feature zoned is shown on /sys/fs/btrfs/fsid1/feature zoned is shown on /sys/fs/btrfs/faid2/feature zoned is NOT shown

btrfs_feature_visible() and get_features() manages to do that dynamically.

Quoted 2 lines

If so then it needs to only be
defined as a static feature?

No. pls.

Quoted 4 lines

Just because the kernel supports it doesn't
necessarily mean it's going to be used if the underlying device is not zoned, right, it should depend on the runtime characteristics of the underlying device?

Right. As in the above example. Imagine runtime == mkfs time in this context, so to say.

#8 lore raw
Quoted 55 lines · Anand Jain
Quoted 37 lines · Nikolay Borisov
Quoted 34 lines · Nikolay Borisov
Quoted 8 lines · David Sterba
Quoted 6 lines · Anand Jain

   As in the proposed patch which adds a table to figure out the correct table to add the attribute, adding to the btrfs_supported_static_feature_attrs attribute list will add only to /sys/fs/btrfs/features, however adding the attribute to btrfs_supported_feature_attrs adds to both /sys/fs/btrfs/features and /sys/fs/btrfs/uuid/features.

Quoted 4 lines

I can't see it in the code right now, but that would mean that eg. zoned would show up in static features once such filesystem is mounted. And that does not happen or I'm missing something.

This happens because when initialising sysfs we create the btrfs_feature_attr_group which contains btrfs_supported_feature_attrs attributes, which have
#ifdef CONFIG_BLK_DEV_ZONED

          BTRFS_FEAT_ATTR_PTR(zoned),

#endif

Subsequently you define the static feature via
BTRFS_ATTR(static_feature, zoned, zoned_show);

and finally we call:

ret = sysfs_merge_group(&btrfs_kset->kobj,
&btrfs_static_feature_attr_group);

Quoted 8 lines
Quoted 3 lines

Which merges the static feature to the feature group. That's why the message about duplication. So one of the 2 definitions needs to go.

Looking at the maze that btrfs' sysfs code is it seems the decision

which of the two sets to use when defining a feature is whether it can

...be enabled per fsid.
::

Quoted 2 lines

I think for zoned block device we can't
really disable the support at runtime?

Quoted 6 lines

 Hmm. It is not like that. Suppose there are two btrfs filesystems on a system fsid1 and fsid2.  fsid1 is zoned. fsid2 is a normal conventional device. Then on fsid1 zoned incompatible feature/flag is enabled and, on fsid2 it is not enabled.

 So IMO zoned should be added to btrfs_supported_feature_attrs.

Provided /sys/fs/btrfs/feature/zoned will return nothing in specific
values like sectorsize.

Quoted 23 lines

 By doing this,
 on /sys/fs/btrfs/feature zoned is shown on /sys/fs/btrfs/fsid1/feature zoned is shown on /sys/fs/btrfs/faid2/feature zoned is NOT shown

 btrfs_feature_visible() and get_features() manages to do that dynamically.

Quoted 2 lines

If so then it needs to only be
defined as a static feature?

 No. pls.

Quoted 4 lines

Just because the kernel supports it doesn't
necessarily mean it's going to be used if the underlying device is not zoned, right, it should depend on the runtime characteristics of the underlying device?

 Right. As in the above example. Imagine runtime == mkfs time in this context, so to say.

#9 lore raw
In reply to David Sterba
Quoted 50 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

 fs/btrfs/sysfs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +7 -3
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
 BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
 BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
 BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
 	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
 	BTRFS_FEAT_ATTR_PTR(free_space_tree),
 	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 	BTRFS_FEAT_ATTR_PTR(zoned),
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
 BTRFS_ATTR(static_feature, supported_sectorsizes,
 	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 10 lines
fs/btrfs/sysfs.c +2 -0
+
 static struct attribute *btrfs_supported_static_feature_attrs[] = {
 	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
 	BTRFS_ATTR_PTR(static_feature, supported_checksums),
 	BTRFS_ATTR_PTR(static_feature, send_stream_version),
 	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
 	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
+	BTRFS_ATTR_PTR(static_feature, zoned),
 	NULL
 };

Why isn't the above hunk predicated on CONFIG_BLK_DEV_ZONED the same as the ATTR_INCOMPAT zoneed bit, but as explained in my earlier email one of these should go and whichever remains must be predicated on CONFIG_BLK_DEV_ZONED.

Quoted 2 lines
#10 lore raw
Quoted 60 lines · Nikolay Borisov
Quoted 57 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

 fs/btrfs/sysfs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +8 -3
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
 BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
 BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
 BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
 	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
 	BTRFS_FEAT_ATTR_PTR(free_space_tree),
 	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 	BTRFS_FEAT_ATTR_PTR(zoned),
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
 BTRFS_ATTR(static_feature, supported_sectorsizes,
 	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);
+
 static struct attribute *btrfs_supported_static_feature_attrs[] = {
 	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
 	BTRFS_ATTR_PTR(static_feature, supported_checksums),
 	BTRFS_ATTR_PTR(static_feature, send_stream_version),
 	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
 	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
Quoted 8 lines

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 3 lines
fs/btrfs/sysfs.c +1 -0
+	BTRFS_ATTR_PTR(static_feature, zoned),
 	NULL
 };

Why isn't the above hunk predicated on CONFIG_BLK_DEV_ZONED the same as the ATTR_INCOMPAT zoneed bit, but as explained in my earlier email one of these should go and whichever remains must be predicated on CONFIG_BLK_DEV_ZONED.

zoned-btrfs can be used with regular devices too. In that case, zones are emulated, all of them being conventional. So btrfs zoned feature should definitely not be dependent on CONFIG_BLK_DEV_ZONED.

If CONFIG_BLK_DEV_ZONED is not defined, then zoned btrfs will be usable only on regular devices. But since in that case zoned devices will not show up, it is all consistent.

Signature · 2 lines
Damien Le Moal
Western Digital Research
#11 lore raw
Quoted 70 lines · Damien Le Moal
Quoted 60 lines · Nikolay Borisov
Quoted 57 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

 fs/btrfs/sysfs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +8 -3
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
 BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
 BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
 BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
 	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
 	BTRFS_FEAT_ATTR_PTR(free_space_tree),
 	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 	BTRFS_FEAT_ATTR_PTR(zoned),
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
 BTRFS_ATTR(static_feature, supported_sectorsizes,
 	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);
+
 static struct attribute *btrfs_supported_static_feature_attrs[] = {
 	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
 	BTRFS_ATTR_PTR(static_feature, supported_checksums),
 	BTRFS_ATTR_PTR(static_feature, send_stream_version),
 	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
 	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
Quoted 8 lines

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 3 lines
fs/btrfs/sysfs.c +1 -0
+	BTRFS_ATTR_PTR(static_feature, zoned),
 	NULL
 };

Why isn't the above hunk predicated on CONFIG_BLK_DEV_ZONED the same as the ATTR_INCOMPAT zoneed bit, but as explained in my earlier email one of these should go and whichever remains must be predicated on CONFIG_BLK_DEV_ZONED.

Quoted 7 lines

zoned-btrfs can be used with regular devices too. In that case, zones are emulated, all of them being conventional. So btrfs zoned feature should definitely not be dependent on CONFIG_BLK_DEV_ZONED.

If CONFIG_BLK_DEV_ZONED is not defined, then zoned btrfs will be usable only on regular devices. But since in that case zoned devices will not show up, it is all consistent.

Then we should discuss what the semantics of the ZONED flag under features should be? I.e do we need to explicitly distinguish between "btrfs supports zoned AND the kernel is compiled with BLK_DEV_ZONED so we say we support it" and "btrfs has support for zoned devices but you have to figure on your own if BLK_DEV_ZONED is enabled" ? I.e by having sys/fs/btrfs/zoned set to 1 what information do we want to convey to the user?

#12 lore raw
Quoted 81 lines · Nikolay Borisov
Quoted 70 lines · Damien Le Moal
Quoted 60 lines · Nikolay Borisov
Quoted 57 lines · David Sterba

We've hidden the zoned support in sysfs under debug config for the first releases but now the stability is reasonable, though not all features have been implemented.

As this depends on a config option, the per-filesystem feature won't exist as such filesystem can't be mounted. The static feature will print 1 when the support is built-in, 0 otherwise.

---

The merge target is not set, depends if everybody thinks it's the time even though there are still known bugs. We're also waiting for util-linux support (blkid, wipefs), so that needs to be synced too.

 fs/btrfs/sysfs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
fs/btrfs/sysfs.c +8 -3
index bfe5e27617b0..7ad8f802ab88 100644
@@ -263,8 +263,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
 BTRFS_FEAT_ATTR_INCOMPAT(metadata_uuid, METADATA_UUID);
 BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
 BTRFS_FEAT_ATTR_INCOMPAT(raid1c34, RAID1C34);
-/* Remove once support for zoned allocation is feature complete */
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 BTRFS_FEAT_ATTR_INCOMPAT(zoned, ZONED);
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -285,7 +284,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = {
 	BTRFS_FEAT_ATTR_PTR(metadata_uuid),
 	BTRFS_FEAT_ATTR_PTR(free_space_tree),
 	BTRFS_FEAT_ATTR_PTR(raid1c34),
-#ifdef CONFIG_BTRFS_DEBUG
+#ifdef CONFIG_BLK_DEV_ZONED
 	BTRFS_FEAT_ATTR_PTR(zoned),
 #endif
 #ifdef CONFIG_FS_VERITY
@@ -384,12 +383,19 @@ static ssize_t supported_sectorsizes_show(struct kobject *kobj,
 BTRFS_ATTR(static_feature, supported_sectorsizes,
 	   supported_sectorsizes_show);
 
+static ssize_t zoned_show(struct kobject *kobj, struct kobj_attribute *a, char *buf)
+{
+	return scnprintf(buf, PAGE_SIZE, "%d\n", IS_ENABLED(CONFIG_BLK_DEV_ZONED));
+}
+BTRFS_ATTR(static_feature, zoned, zoned_show);
+
 static struct attribute *btrfs_supported_static_feature_attrs[] = {
 	BTRFS_ATTR_PTR(static_feature, rmdir_subvol),
 	BTRFS_ATTR_PTR(static_feature, supported_checksums),
 	BTRFS_ATTR_PTR(static_feature, send_stream_version),
 	BTRFS_ATTR_PTR(static_feature, supported_rescue_options),
 	BTRFS_ATTR_PTR(static_feature, supported_sectorsizes),
Quoted 8 lines

fs/btrfs/sysfs.c static ssize_t supported_sectorsizes_show(struct kobject *kobj, · line 400

Quoted 3 lines
fs/btrfs/sysfs.c +1 -0
+	BTRFS_ATTR_PTR(static_feature, zoned),
 	NULL
 };

Why isn't the above hunk predicated on CONFIG_BLK_DEV_ZONED the same as the ATTR_INCOMPAT zoneed bit, but as explained in my earlier email one of these should go and whichever remains must be predicated on CONFIG_BLK_DEV_ZONED.

Quoted 7 lines

zoned-btrfs can be used with regular devices too. In that case, zones are emulated, all of them being conventional. So btrfs zoned feature should definitely not be dependent on CONFIG_BLK_DEV_ZONED.

If CONFIG_BLK_DEV_ZONED is not defined, then zoned btrfs will be usable only on regular devices. But since in that case zoned devices will not show up, it is all consistent.

Quoted 7 lines

Then we should discuss what the semantics of the ZONED flag under features should be? I.e do we need to explicitly distinguish between "btrfs supports zoned AND the kernel is compiled with BLK_DEV_ZONED so we say we support it" and "btrfs has support for zoned devices but you have to figure on your own if BLK_DEV_ZONED is enabled" ? I.e by having sys/fs/btrfs/zoned set to 1 what information do we want to convey to the user?

That this version of btrfs supports the zoned mode. What device you can actually apply it to then depends on CONFIG_BLK_DEV_ZONED. If that one is set, the zoned btrfs feature applies to all devices, regular and zoned. If it is not set, then the feature applies to regular devices only, since zoned devices will NOT be present. The user will not see them :)

Rather all simple I think. But I am heavily biased with this since I have been doing zoned stuff for years. So someone totally new to zoned storage needs to chime in !

Signature · 2 lines
Damien Le Moal
Western Digital Research