All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: zoned: introduce a minimal zone size and reject mount
@ 2022-02-10 13:47 Johannes Thumshirn
  2022-02-10 14:32 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Thumshirn @ 2022-02-10 13:47 UTC (permalink / raw)
  To: David Sterba
  Cc: Johannes Thumshirn, Javier González, Naohiro Aota, linux-btrfs

When creating a filesystem on a zoned block device with a zone size of
32MB or 16MB successive mounting of this filesystem fails with the
following error message:
 host:/ # mount /dev/nullb0 /mnt/
  BTRFS info (device nullb0): flagging fs with big metadata feature
  BTRFS info (device nullb0): using free space tree
  BTRFS info (device nullb0): has skinny extents
  BTRFS info (device nullb0): host-managed zoned block device /dev/nullb0, 400 zones of 33554432 bytes
  BTRFS info (device nullb0): zoned mode enabled with zone size 33554432
  BTRFS error (device nullb0): zoned: block group 67108864 must not contain super block
  BTRFS error (device nullb0): failed to read block groups: -117
  BTRFS error (device nullb0): open_ctree failed
 mount: /mnt: wrong fs type, bad option, bad superblock on /dev/nullb0, missing codepage or helper program, or other error.

This happens because mkfs.btrfs places the system block-group exactly at
the location where regular btrfs would have it's 1st super block mirror.
In case of a 16MiB filesystem, mkfs.btrfs will place the 1st metadata
block-group at this location.

As the smallest zone size on the market today is 64MiB and we're expecting
zone sizes to be more in the 256MiB - 4GiB region, refuse to mount a
filesystem with a zone size of 32MiB or smaller.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/zoned.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

@ Javier, I've CCed you because I've heared rumors that you guys have ZNS
dddrives with a zone size of 64MB. So I'd like to hear your toughts on the
patch as well, so I'm not breaking existing devices supported by Linux.


diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index b7b5fac1c779..3cf9217f6fcf 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -51,11 +51,13 @@
 #define BTRFS_MIN_ACTIVE_ZONES		(BTRFS_SUPER_MIRROR_MAX + 5)
 
 /*
- * Maximum supported zone size. Currently, SMR disks have a zone size of
- * 256MiB, and we are expecting ZNS drives to be in the 1-4GiB range. We do not
- * expect the zone size to become larger than 8GiB in the near future.
+ * Minimum / maximum supported zone size. Currently, SMR disks have a zone
+ * size of 256MiB, and we are expecting ZNS drives to be in the 1-4GiB range.
+ * We do not expect the zone size to become larger than 8GiB or smaller than
+ * 64MiB in the near future.
  */
 #define BTRFS_MAX_ZONE_SIZE		SZ_8G
+#define BTRFS_MIN_ZONE_SIZE		SZ_64M
 
 #define SUPER_INFO_SECTORS	((u64)BTRFS_SUPER_INFO_SIZE >> SECTOR_SHIFT)
 
@@ -402,6 +404,13 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
 				 zone_info->zone_size, BTRFS_MAX_ZONE_SIZE);
 		ret = -EINVAL;
 		goto out;
+	} else if (zone_info->zone_size < BTRFS_MIN_ZONE_SIZE) {
+		btrfs_err_in_rcu(fs_info,
+		"zoned: %s: zone size %llu smaller than supported minimum %u",
+				 rcu_str_deref(device->name),
+				 zone_info->zone_size, BTRFS_MIN_ZONE_SIZE);
+		ret = -EINVAL;
+		goto out;
 	}
 
 	nr_sectors = bdev_nr_sectors(bdev);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: zoned: introduce a minimal zone size and reject mount
  2022-02-10 13:47 [PATCH] btrfs: zoned: introduce a minimal zone size and reject mount Johannes Thumshirn
@ 2022-02-10 14:32 ` David Sterba
  2022-02-10 15:04   ` Johannes Thumshirn
  0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2022-02-10 14:32 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: David Sterba, Javier González, Naohiro Aota, linux-btrfs

On Thu, Feb 10, 2022 at 05:47:05AM -0800, Johannes Thumshirn wrote:
> When creating a filesystem on a zoned block device with a zone size of
> 32MB or 16MB successive mounting of this filesystem fails with the
> following error message:
>  host:/ # mount /dev/nullb0 /mnt/
>   BTRFS info (device nullb0): flagging fs with big metadata feature
>   BTRFS info (device nullb0): using free space tree
>   BTRFS info (device nullb0): has skinny extents
>   BTRFS info (device nullb0): host-managed zoned block device /dev/nullb0, 400 zones of 33554432 bytes
>   BTRFS info (device nullb0): zoned mode enabled with zone size 33554432
>   BTRFS error (device nullb0): zoned: block group 67108864 must not contain super block
>   BTRFS error (device nullb0): failed to read block groups: -117
>   BTRFS error (device nullb0): open_ctree failed
>  mount: /mnt: wrong fs type, bad option, bad superblock on /dev/nullb0, missing codepage or helper program, or other error.
> 
> This happens because mkfs.btrfs places the system block-group exactly at
> the location where regular btrfs would have it's 1st super block mirror.
> In case of a 16MiB filesystem, mkfs.btrfs will place the 1st metadata
> block-group at this location.
> 
> As the smallest zone size on the market today is 64MiB and we're expecting
> zone sizes to be more in the 256MiB - 4GiB region, refuse to mount a
> filesystem with a zone size of 32MiB or smaller.

Nooooo, I've been using 4MiB zones for testing, it's an excellent setup
to trigger all sorts of bugs. The 64MiB zone size is problematic for the
reason you say but I think it's an outlier, so maybe add it as an
exception.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: zoned: introduce a minimal zone size and reject mount
  2022-02-10 14:32 ` David Sterba
@ 2022-02-10 15:04   ` Johannes Thumshirn
  0 siblings, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2022-02-10 15:04 UTC (permalink / raw)
  To: dsterba; +Cc: David Sterba, Javier González, Naohiro Aota, linux-btrfs

On 10/02/2022 15:36, David Sterba wrote:
> On Thu, Feb 10, 2022 at 05:47:05AM -0800, Johannes Thumshirn wrote:
>> When creating a filesystem on a zoned block device with a zone size of
>> 32MB or 16MB successive mounting of this filesystem fails with the
>> following error message:
>>  host:/ # mount /dev/nullb0 /mnt/
>>   BTRFS info (device nullb0): flagging fs with big metadata feature
>>   BTRFS info (device nullb0): using free space tree
>>   BTRFS info (device nullb0): has skinny extents
>>   BTRFS info (device nullb0): host-managed zoned block device /dev/nullb0, 400 zones of 33554432 bytes
>>   BTRFS info (device nullb0): zoned mode enabled with zone size 33554432
>>   BTRFS error (device nullb0): zoned: block group 67108864 must not contain super block
>>   BTRFS error (device nullb0): failed to read block groups: -117
>>   BTRFS error (device nullb0): open_ctree failed
>>  mount: /mnt: wrong fs type, bad option, bad superblock on /dev/nullb0, missing codepage or helper program, or other error.
>>
>> This happens because mkfs.btrfs places the system block-group exactly at
>> the location where regular btrfs would have it's 1st super block mirror.
>> In case of a 16MiB filesystem, mkfs.btrfs will place the 1st metadata
>> block-group at this location.
>>
>> As the smallest zone size on the market today is 64MiB and we're expecting
>> zone sizes to be more in the 256MiB - 4GiB region, refuse to mount a
>> filesystem with a zone size of 32MiB or smaller.
> 
> Nooooo, I've been using 4MiB zones for testing, it's an excellent setup
> to trigger all sorts of bugs. The 64MiB zone size is problematic for the
> reason you say but I think it's an outlier, so maybe add it as an
> exception.
> 

Yeah 32M (and probably 16M but that needs more zoned special casing) can be
fixed with mkfs and then with 8M zones all sorts of strange problems start to
occur.

I do have a patch for 32M, but I didn't want to go down the rabbit hole for
only simulated hardware.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-10 15:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 13:47 [PATCH] btrfs: zoned: introduce a minimal zone size and reject mount Johannes Thumshirn
2022-02-10 14:32 ` David Sterba
2022-02-10 15:04   ` Johannes Thumshirn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.