For Btrfs with 16E fs size support, resize by unit t/p/e is desired. The request comes from redhat bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1058608. Originally, # btrfs resize -1T <path> : prompt 'invalid argument' while, # btrfs resize -1024G <path> : will work We add t/p/e support by replacing lib/cmdline.c:memparse with btrfs_memparse. The btrfs_memparse copies memparse's code and add unit t/p/e parsing. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> --- fs/btrfs/ioctl.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e174770..357b706 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1448,6 +1448,47 @@ out_ra: return ret; } +/* + * The memparse only supports k/m/g suffixes + * For Btrfs with 16E fs size support, t/p/e support is desired + * This function copies the memparse and adds t/p/e suffixes parsing + */ +static int btrfs_memparse(const char *ptr, u64 *retval) +{ + int ret = 0; + char *endptr; /* local pointer to end of parsed string */ + + *retval = simple_strtoull(ptr, &endptr, 0); + if (*(endptr + 1) != '\0') + return -EINVAL; + + switch (*endptr) { + case 'E': + case 'e': + *retval <<= 10; + case 'P': + case 'p': + *retval <<= 10; + case 'T': + case 't': + *retval <<= 10; + case 'G': + case 'g': + *retval <<= 10; + case 'M': + case 'm': + *retval <<= 10; + case 'K': + case 'k': + *retval <<= 10; + break; + default: + ret = -EINVAL; + } + + return ret; +} + static noinline int btrfs_ioctl_resize(struct file *file, void __user *arg) { @@ -1526,8 +1567,8 @@ static noinline int btrfs_ioctl_resize(struct file *file, mod = 1; sizestr++; } - new_size = memparse(sizestr, NULL); - if (new_size == 0) { + ret = btrfs_memparse(sizestr, &new_size); + if (ret < 0 || new_size == 0) { ret = -EINVAL; goto out_free; } -- 1.8.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html