Skip to contentSkip to conversation

btrfs: ioctl: resize: Only how new size if size changed

PATCH In review Marcos Paulo de Souza 3 participants 3 messages Feb 11, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: ioctl: resize: Only how new size if size changed

There is no point to inform the user about "new size" if didn't changed at all.

---
 fs/btrfs/ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/ioctl.c +3 -3
index be5350582955..fa31a8021d24 100644
@@ -1712,9 +1712,6 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 
 	new_size = round_down(new_size, fs_info->sectorsize);
 
-	btrfs_info_in_rcu(fs_info, "new size for %s is %llu",
-			  rcu_str_deref(device->name), new_size);
-
 	if (new_size > old_size) {
 		trans = btrfs_start_transaction(root, 0);
 		if (IS_ERR(trans)) {
@@ -1727,6 +1724,9 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 		ret = btrfs_shrink_device(device, new_size);
 	} /* equal, nothing need to do */
 
+	if (ret == 0 && new_size != old_size)
+		btrfs_info_in_rcu(fs_info, "new size for %s is %llu",
+			  rcu_str_deref(device->name), new_size);
 out_free:
 	kfree(vol_args);
 out:
Signature · 1 line
2.24.0
#2 lore raw
In reply to Marcos Paulo de Souza
Quoted 2 lines · Marcos Paulo de Souza

There is no point to inform the user about "new size" if didn't changed at all.

Makes sense. I'll also update the message to show the old and new sizes.

Quoted 20 lines
---
 fs/btrfs/ioctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/ioctl.c +0 -3
index be5350582955..fa31a8021d24 100644
@@ -1712,9 +1712,6 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 
 	new_size = round_down(new_size, fs_info->sectorsize);
 
-	btrfs_info_in_rcu(fs_info, "new size for %s is %llu",
-			  rcu_str_deref(device->name), new_size);
-
 	if (new_size > old_size) {
 		trans = btrfs_start_transaction(root, 0);
 		if (IS_ERR(trans)) {

fs/btrfs/ioctl.c static noinline int btrfs_ioctl_resize(struct file *file, · line 1729

Quoted 6 lines
fs/btrfs/ioctl.c +3 -0
@@ -1727,6 +1724,9 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 		ret = btrfs_shrink_device(device, new_size);
 	} /* equal, nothing need to do */
 
+	if (ret == 0 && new_size != old_size)
+		btrfs_info_in_rcu(fs_info, "new size for %s is %llu",
+			  rcu_str_deref(device->name), new_size);

And maybe also print devid, other messages usually print both.

Quoted 5 lines
fs/btrfs/ioctl.c +0 -0
 out_free:
 	kfree(vol_args);
 out:
Signature · 1 line
2.24.0