linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: fi resize: fix false 0.00B sized output
@ 2021-04-19 12:45 Su Yue
  2021-04-19 12:49 ` Su Yue
  0 siblings, 1 reply; 2+ messages in thread
From: Su Yue @ 2021-04-19 12:45 UTC (permalink / raw)
  To: linux-btrfs; +Cc: l, Chris Murphy

Resize to nums without sign prefix makes false output:
Resize device id 1 (/dev/sdb1) from 298.09GiB to 0.00B

The resize operation would take effect though.

Fix it by handling the case if mod is 0 in check_resize_args().

Issue: #307
Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: Su Yue <l@damenly.su>
---
 cmds/filesystem.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/cmds/filesystem.c b/cmds/filesystem.c
index 9e3cce687d6e..607c85a0bccc 100644
--- a/cmds/filesystem.c
+++ b/cmds/filesystem.c
@@ -1158,6 +1158,13 @@ static int check_resize_args(const char *amount, const char *path) {
 		}
 		old_size = di_args[dev_idx].total_bytes;
 
+		/* For target sizes without '+'/'-' sign prefix(e.g. 1:150g) */
+		if (mod == 0) {
+			new_size = diff;
+			diff = new_size - old_size;
+			mod = diff;
+		}
+
 		if (mod < 0) {
 			if (diff > old_size) {
 				error("current size is %s which is smaller than %s",
-- 
2.30.1


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

* Re: [PATCH] btrfs-progs: fi resize: fix false 0.00B sized output
  2021-04-19 12:45 [PATCH] btrfs-progs: fi resize: fix false 0.00B sized output Su Yue
@ 2021-04-19 12:49 ` Su Yue
  0 siblings, 0 replies; 2+ messages in thread
From: Su Yue @ 2021-04-19 12:49 UTC (permalink / raw)
  To: linux-btrfs; +Cc: l, Chris Murphy


On Mon 19 Apr 2021 at 20:45, Su Yue <l@damenly.su> wrote:

> Resize to nums without sign prefix makes false output:
> Resize device id 1 (/dev/sdb1) from 298.09GiB to 0.00B
>
> The resize operation would take effect though.
>
> Fix it by handling the case if mod is 0 in check_resize_args().
>
> Issue: #307
> Reported-by: Chris Murphy <lists@colorremedies.com>
> Signed-off-by: Su Yue <l@damenly.su>
> ---
>  cmds/filesystem.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/cmds/filesystem.c b/cmds/filesystem.c
> index 9e3cce687d6e..607c85a0bccc 100644
> --- a/cmds/filesystem.c
> +++ b/cmds/filesystem.c
> @@ -1158,6 +1158,13 @@ static int check_resize_args(const char 
> *amount, const char *path) {
>  		}
>  		old_size = di_args[dev_idx].total_bytes;
>
> +		/* For target sizes without '+'/'-' sign prefix(e.g. 
> 1:150g) */
> +		if (mod == 0) {
> +			new_size = diff;
> +			diff = new_size - old_size;
>

> +			mod = diff;
>
Hmmm.. diff is a u64... will send v2.
> +		}
> +
>  		if (mod < 0) {
>  			if (diff > old_size) {
>  				error("current size is %s which is smaller than 
>  %s",


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

end of thread, other threads:[~2021-04-19 12:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-19 12:45 [PATCH] btrfs-progs: fi resize: fix false 0.00B sized output Su Yue
2021-04-19 12:49 ` Su Yue

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).