[PATCH] Btrfs: Don't error on resizing FS to same size

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems overly harsh to fail a resize of a btrfs file system to the
same size when a shrink or grow would succeed.  User app GParted trips
over this error.  Allow it by bypassing the shrink or grow operation.

Signed-off-by: Mike Fleetwood <mike.fleetwood@xxxxxxxxxxxxxx>
---

Example failed resize:
    # strace -e trace=ioctl btrfs filesystem resize max /mnt/0
    Resize '/mnt/0' of 'max'
    ioctl(3, 0x50009403, 0xbfa5029c)        = -1 EINVAL (Invalid argument)
    ERROR: unable to resize '/mnt/0' - Invalid argument
    # echo $?
    30
    # dmesg | tail -1
    [426094.235018] new size for /dev/loop1 is 1073741824

---
 fs/btrfs/ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index dae5dfe..00b7024 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1251,7 +1251,7 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
 		}
 		ret = btrfs_grow_device(trans, device, new_size);
 		btrfs_commit_transaction(trans, root);
-	} else {
+	} else if (new_size > old_size) {
 		ret = btrfs_shrink_device(device, new_size);
 	}
 
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux