All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] btrfs-progs: fi resize: fix false 0.00B sized output
@ 2021-04-20  4:58 Su Yue
  2021-05-03 17:19 ` Boris Burkov
  2021-05-06 14:21 ` David Sterba
  0 siblings, 2 replies; 3+ messages in thread
From: Su Yue @ 2021-04-20  4:58 UTC (permalink / raw)
  To: linux-btrfs; +Cc: l, boris, Chris Murphy

Resize to nums without sign prefix makes false output:
 btrfs fi resize 1:150g /srv/extra
Resize device id 1 (/dev/sdb1) from 298.09GiB to 0.00B

The resize operation would take effect though.

check_resize_args() does not handle the mod 0 case and new_size is 0.
Simply assigning @diff to @new_size to fix this.

Issue: #307
Reported-by: Chris Murphy <lists@colorremedies.com>
Signed-off-by: Su Yue <l@damenly.su>
---
Changelog:
v3:
  Just assign @diff to @new_size. (Boris Burkov)
v2:
  Calculate u64 diff using max() and min().
  Calculate mod by comparing new and old size.
---
 cmds/filesystem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

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


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

* Re: [PATCH v3] btrfs-progs: fi resize: fix false 0.00B sized output
  2021-04-20  4:58 [PATCH v3] btrfs-progs: fi resize: fix false 0.00B sized output Su Yue
@ 2021-05-03 17:19 ` Boris Burkov
  2021-05-06 14:21 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: Boris Burkov @ 2021-05-03 17:19 UTC (permalink / raw)
  To: 20210419124541.148269-1-l; +Cc: linux-btrfs, l, Chris Murphy

On Tue, Apr 20, 2021 at 12:58:27PM +0800, Su Yue wrote:
> Resize to nums without sign prefix makes false output:
>  btrfs fi resize 1:150g /srv/extra
> Resize device id 1 (/dev/sdb1) from 298.09GiB to 0.00B
> 
> The resize operation would take effect though.
> 
> check_resize_args() does not handle the mod 0 case and new_size is 0.
> Simply assigning @diff to @new_size to fix this.
> 
> Issue: #307
> Reported-by: Chris Murphy <lists@colorremedies.com>
> Signed-off-by: Su Yue <l@damenly.su>

Reviewed-by: Boris Burkov <boris@bur.io>

> ---
> Changelog:
> v3:
>   Just assign @diff to @new_size. (Boris Burkov)
> v2:
>   Calculate u64 diff using max() and min().
>   Calculate mod by comparing new and old size.
> ---
>  cmds/filesystem.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/cmds/filesystem.c b/cmds/filesystem.c
> index 9e3cce687d6e..b4c09768235c 100644
> --- a/cmds/filesystem.c
> +++ b/cmds/filesystem.c
> @@ -1158,7 +1158,10 @@ static int check_resize_args(const char *amount, const char *path) {
>  		}
>  		old_size = di_args[dev_idx].total_bytes;
>  
> -		if (mod < 0) {
> +		/* For target sizes without '+'/'-' sign prefix(e.g. 1:150g) */
> +		if (mod == 0) {
> +			new_size = diff;
> +		} else if (mod < 0) {
>  			if (diff > old_size) {
>  				error("current size is %s which is smaller than %s",
>  				      pretty_size_mode(old_size, UNITS_DEFAULT),
> -- 
> 2.30.1
> 

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

* Re: [PATCH v3] btrfs-progs: fi resize: fix false 0.00B sized output
  2021-04-20  4:58 [PATCH v3] btrfs-progs: fi resize: fix false 0.00B sized output Su Yue
  2021-05-03 17:19 ` Boris Burkov
@ 2021-05-06 14:21 ` David Sterba
  1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-05-06 14:21 UTC (permalink / raw)
  To: 20210419124541.148269-1-l; +Cc: linux-btrfs, l, boris, Chris Murphy

On Tue, Apr 20, 2021 at 12:58:27PM +0800, Su Yue wrote:
> Resize to nums without sign prefix makes false output:
>  btrfs fi resize 1:150g /srv/extra
> Resize device id 1 (/dev/sdb1) from 298.09GiB to 0.00B
> 
> The resize operation would take effect though.
> 
> check_resize_args() does not handle the mod 0 case and new_size is 0.
> Simply assigning @diff to @new_size to fix this.
> 
> Issue: #307
> Reported-by: Chris Murphy <lists@colorremedies.com>
> Signed-off-by: Su Yue <l@damenly.su>
> ---
> Changelog:
> v3:
>   Just assign @diff to @new_size. (Boris Burkov)

Patch replaced in devel, thanks.

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

end of thread, other threads:[~2021-05-06 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20  4:58 [PATCH v3] btrfs-progs: fi resize: fix false 0.00B sized output Su Yue
2021-05-03 17:19 ` Boris Burkov
2021-05-06 14:21 ` David Sterba

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.