Skip to contentSkip to conversation

btrfs-progs: fi resize: fix false 0.00B sized output

PATCH Superseded Su Yue 1 participant 2 messages Apr 19, 2021 Btrfs file system

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Su Yue

author
#0 lore raw

PATCH 1/1 btrfs-progs: fi resize: fix false 0.00B sized output

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

---
 cmds/filesystem.c | 7 +++++++
 1 file changed, 7 insertions(+)
cmds/filesystem.c +7 -0
index 9e3cce687d6e..607c85a0bccc 100644
@@ -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",
Signature · 1 line
2.30.1
author
#1 lore raw
Quoted 26 lines · Su Yue

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

---
 cmds/filesystem.c | 7 +++++++
 1 file changed, 7 insertions(+)
cmds/filesystem.c +1 -0
index 9e3cce687d6e..607c85a0bccc 100644
@@ -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) */

cmds/filesystem.c static int check_resize_args(const char *amount, const char *path) { · line 1165

Quoted 6 lines
cmds/filesystem.c +4 -0
+		if (mod == 0) {
+			new_size = diff;
+			diff = new_size - old_size;
 
 
+			mod = diff;

Hmmm.. diff is a u64... will send v2.

Quoted 6 lines
cmds/filesystem.c +2 -0
+		}
+
 		if (mod < 0) {
 			if (diff > old_size) {
 				error("current size is %s which is smaller than 
 %s",