public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: minor mkfs fs size error message enhancements
@ 2022-09-09 21:48 Luis Chamberlain
  2022-09-09 21:48 ` [PATCH 1/2] btrfs-progs: mkfs: fix error message for minimum zoned filesystem size Luis Chamberlain
  2022-09-09 21:48 ` [PATCH 2/2] btrfs-progs: mkfs: use pretty_size_mode() on min size error Luis Chamberlain
  0 siblings, 2 replies; 5+ messages in thread
From: Luis Chamberlain @ 2022-09-09 21:48 UTC (permalink / raw)
  To: dsterba, johannes.thumshirn, naohiro.aota, linux-btrfs,
	damien.lemoal
  Cc: pankydev8, p.raghav, mcgrof

Here are just a couple of minor enhancements to the error printed when
we get an error to create a filesystem on ZNS which simply makes no
sense at all at first glance.

Luis Chamberlain (2):
  btrfs-progs: mkfs: fix error message for minimum zoned filesystem size
  btrfs-progs: mkfs: use pretty_size_mode() on min size error

 mkfs/main.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

-- 
2.35.1


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

* [PATCH 1/2] btrfs-progs: mkfs: fix error message for minimum zoned filesystem size
  2022-09-09 21:48 [PATCH 0/2] btrfs-progs: minor mkfs fs size error message enhancements Luis Chamberlain
@ 2022-09-09 21:48 ` Luis Chamberlain
  2022-09-14  8:28   ` Pankaj Raghav
  2022-09-09 21:48 ` [PATCH 2/2] btrfs-progs: mkfs: use pretty_size_mode() on min size error Luis Chamberlain
  1 sibling, 1 reply; 5+ messages in thread
From: Luis Chamberlain @ 2022-09-09 21:48 UTC (permalink / raw)
  To: dsterba, johannes.thumshirn, naohiro.aota, linux-btrfs,
	damien.lemoal
  Cc: pankydev8, p.raghav, mcgrof

The minimum size for a filesystem on a zone storage device
actually depends on the size of a devices' zone size, given 5
dedicated zones are required, regardless of their fulll size
of the drive:

  * 2 zones for the primary superblock
  * 1 zone for the system block group
  * 1 zone for a metadata block group
  * 1 zone for a data block group

So the minimum size for a btrfs filesystem for a zone storage
device is completely device specific.

The check for this however complains about the minimum
size required for btrfs in general, not for the above
consideration. Fix the error message so that users
understand the exact reason why mkfs might fail
if you want to create a filesystem which cannot
possibly fit into less than 5 zones. Also clarify how
the minimum size then is completely device specific.

Without this a user can end up scratching their heads
if they tried to create say a 512 MiB filesystem on
a 100 GiB NVMe ZNS drive with 128 MiB zone size.
In this case 5 * 128 = 640 MiB is the minimum required.
Without this patch a user will end up with the following
error message:

ERROR: size 268435456 is too small to make a usable filesystem
ERROR: minimum size for a zoned btrfs filesystem is 47185920

Clearly 268435456 (256 MiB) >  47185920 (45 MiB). Fix
the error message so that the user knows what to do if
they want the mimimum filesystem for btrfs zone storage
device.

With this now the user sees:

ERROR: Size 512.00MiB is too small to make a usable filesystem.
ERROR: The minimum size for a zoned btrfs filesystem requires
ERROR: 5 dedicated zones. This device's zone size is 128.00MiB so
ERROR: the minimum size for a btrfs filesystem for this zoned
ERROR: storage device (/dev/nvme5n1) is 640.00MiB

The following fstests fail because of this issue, and at first glance
it was not clear why:

  * brfs/132
  * generic/226
  * generic/416
  * generic/650

Now it's clear what the issue is and what needs to get done to
fix those respective tests. But note, that if working on a sequential
zone then parallel writes are expected to fail, so tests which require
that and use parallel writes must also check for sequential zones
and bail if one is to be used. Each of these tests needs to be adapted
a bit for zoned devices to work properly.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 mkfs/main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index eaecdc061dfe..ebf462587bd5 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1401,10 +1401,14 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 	 * 1 zone for a data block group
 	 */
 	if (zoned && block_count && block_count < 5 * zone_size(file)) {
-		error("size %llu is too small to make a usable filesystem",
-			block_count);
-		error("minimum size for a zoned btrfs filesystem is %llu",
-			min_dev_size);
+		error("Size %s is too small to make a usable filesystem.",
+			pretty_size_mode(block_count, UNITS_DEFAULT));
+		error("The minimum size for a zoned btrfs filesystem requires");
+		error("5 dedicated zones. This device's zone size is %s so",
+			pretty_size_mode(zone_size(file), UNITS_DEFAULT));
+		error("the minimum size for a btrfs filesystem for this zoned");
+		error("storage device (%s) is %s",
+			file, pretty_size_mode(5 * zone_size(file), UNITS_DEFAULT));
 		goto error;
 	}
 
-- 
2.35.1


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

* [PATCH 2/2] btrfs-progs: mkfs: use pretty_size_mode() on min size error
  2022-09-09 21:48 [PATCH 0/2] btrfs-progs: minor mkfs fs size error message enhancements Luis Chamberlain
  2022-09-09 21:48 ` [PATCH 1/2] btrfs-progs: mkfs: fix error message for minimum zoned filesystem size Luis Chamberlain
@ 2022-09-09 21:48 ` Luis Chamberlain
  2022-09-09 23:10   ` Wang Yugui
  1 sibling, 1 reply; 5+ messages in thread
From: Luis Chamberlain @ 2022-09-09 21:48 UTC (permalink / raw)
  To: dsterba, johannes.thumshirn, naohiro.aota, linux-btrfs,
	damien.lemoal
  Cc: pankydev8, p.raghav, mcgrof

Use a human pretty output for the error message about the
minimum required size for a btrfs filesystem.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 mkfs/main.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index ebf462587bd5..8a0018abd01e 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1388,10 +1388,10 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
 	}
 	/* Check device/block_count after the nodesize is determined */
 	if (block_count && block_count < min_dev_size) {
-		error("size %llu is too small to make a usable filesystem",
-			block_count);
-		error("minimum size for btrfs filesystem is %llu",
-			min_dev_size);
+		error("Size %s is too small to make a usable filesystem",
+			pretty_size_mode(block_count, UNITS_DEFAULT));
+		error("minimum size for btrfs filesystem is %s",
+			pretty_size_mode(min_dev_size, UNITS_DEFAULT));
 		goto error;
 	}
 	/*
-- 
2.35.1


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

* Re: [PATCH 2/2] btrfs-progs: mkfs: use pretty_size_mode() on min size error
  2022-09-09 21:48 ` [PATCH 2/2] btrfs-progs: mkfs: use pretty_size_mode() on min size error Luis Chamberlain
@ 2022-09-09 23:10   ` Wang Yugui
  0 siblings, 0 replies; 5+ messages in thread
From: Wang Yugui @ 2022-09-09 23:10 UTC (permalink / raw)
  To: linux-btrfs
  Cc: dsterba, johannes.thumshirn, naohiro.aota, damien.lemoal,
	pankydev8, p.raghav, mcgrof

Hi,

> Use a human pretty output for the error message about the
> minimum required size for a btrfs filesystem.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
>  mkfs/main.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mkfs/main.c b/mkfs/main.c
> index ebf462587bd5..8a0018abd01e 100644
> --- a/mkfs/main.c
> +++ b/mkfs/main.c
> @@ -1388,10 +1388,10 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
>  	}
>  	/* Check device/block_count after the nodesize is determined */
>  	if (block_count && block_count < min_dev_size) {
> -		error("size %llu is too small to make a usable filesystem",
> -			block_count);
> -		error("minimum size for btrfs filesystem is %llu",
> -			min_dev_size);
> +		error("Size %s is too small to make a usable filesystem",
> +			pretty_size_mode(block_count, UNITS_DEFAULT));
> +		error("minimum size for btrfs filesystem is %s",
> +			pretty_size_mode(min_dev_size, UNITS_DEFAULT));
>  		goto error;
>  	}
>  	/*
> -- 
> 2.35.1

Could we do a rename 'block_count' to 'byte_count' here?

It is a size based on byte, not based on block (sector).

and '--byte-count' is used as a param of mkfs.btrfs.

Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2022/09/10



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

* Re: [PATCH 1/2] btrfs-progs: mkfs: fix error message for minimum zoned filesystem size
  2022-09-09 21:48 ` [PATCH 1/2] btrfs-progs: mkfs: fix error message for minimum zoned filesystem size Luis Chamberlain
@ 2022-09-14  8:28   ` Pankaj Raghav
  0 siblings, 0 replies; 5+ messages in thread
From: Pankaj Raghav @ 2022-09-14  8:28 UTC (permalink / raw)
  To: Luis Chamberlain
  Cc: dsterba, johannes.thumshirn, naohiro.aota, linux-btrfs,
	damien.lemoal, p.raghav

> With this now the user sees:
> 
> ERROR: Size 512.00MiB is too small to make a usable filesystem.
> ERROR: The minimum size for a zoned btrfs filesystem requires
> ERROR: 5 dedicated zones. This device's zone size is 128.00MiB so
> ERROR: the minimum size for a btrfs filesystem for this zoned
> ERROR: storage device (/dev/nvme5n1) is 640.00MiB
> 
> The following fstests fail because of this issue, and at first glance
> it was not clear why:
> 
>   * brfs/132
>   * generic/226
>   * generic/416
>   * generic/650
> 
> Now it's clear what the issue is and what needs to get done to
> fix those respective tests. But note, that if working on a sequential
> zone then parallel writes are expected to fail, so tests which require
> that and use parallel writes must also check for sequential zones
> and bail if one is to be used. Each of these tests needs to be adapted
> a bit for zoned devices to work properly.
> 
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
Looks good,
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>

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

end of thread, other threads:[~2022-09-14  8:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-09 21:48 [PATCH 0/2] btrfs-progs: minor mkfs fs size error message enhancements Luis Chamberlain
2022-09-09 21:48 ` [PATCH 1/2] btrfs-progs: mkfs: fix error message for minimum zoned filesystem size Luis Chamberlain
2022-09-14  8:28   ` Pankaj Raghav
2022-09-09 21:48 ` [PATCH 2/2] btrfs-progs: mkfs: use pretty_size_mode() on min size error Luis Chamberlain
2022-09-09 23:10   ` Wang Yugui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox