From 158a25af0d610707f3adde042e28f72a16d65f3c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 17 Sep 2024 14:47:01 +0200 Subject: [PATCH] btrfs-progs: fi resize: warn if new size is < 256M The lower kernel limit is 256M otherwise it's considered an invalid parameter. Issue: #875 Signed-off-by: David Sterba --- Documentation/btrfs-filesystem.rst | 5 +++++ cmds/filesystem.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/Documentation/btrfs-filesystem.rst b/Documentation/btrfs-filesystem.rst index 207f7b02..b036ae5e 100644 --- a/Documentation/btrfs-filesystem.rst +++ b/Documentation/btrfs-filesystem.rst @@ -269,6 +269,11 @@ resize [options] [:][+/-][kKmMgGtTpPeE]|[:]max take a long time if there are data in the device area that's beyond the new end. Relocation of the data takes time. + Note that there's a lower limit on the new size (either specified + as an absolute size or difference) that is checked by kernel and + rejected eventually as invalid. Lower values will print a warning but + still pass the request to kernel. The currently known value is 256MiB. + See also section *EXAMPLES*. ``Options`` diff --git a/cmds/filesystem.c b/cmds/filesystem.c index 41ad2f8d..d2605bda 100644 --- a/cmds/filesystem.c +++ b/cmds/filesystem.c @@ -1408,6 +1408,9 @@ static int check_resize_args(const char *amount, const char *path, u64 *devid_re di_args[dev_idx].path, pretty_size_mode(di_args[dev_idx].total_bytes, UNITS_DEFAULT), res_str); + if (new_size < 256 * SZ_1M) + warning("the new size %lld (%s) is < 256MiB, this may be rejected by kernel", + new_size, pretty_size_mode(new_size, UNITS_DEFAULT)); out: free(di_args);