@@ -1144,10 +1144,11 @@ next:
static DEFINE_SIMPLE_COMMAND(filesystem_defrag, "defragment");
static const char * const cmd_filesystem_resize_usage[] = {
- "btrfs filesystem resize [options] [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max <path>",
+ "btrfs filesystem resize [options] [devid:][+/-]<newsize>[kKmMgGtTpPeE]|[devid:]max|min <path>",
"Resize a filesystem",
"If 'max' is passed, the filesystem will occupy all available space",
"on the device 'devid'.",
+ "If 'min' is passed, the filesystem will reduce size to allocated space.",
"[kK] means KiB, which denotes 1KiB = 1024B, 1MiB = 1024KiB, etc.",
"",
OPTLINE("--enqueue", "wait if there's another exclusive operation running, otherwise continue"),
@@ -1218,6 +1219,8 @@ static int check_resize_args(const char *amount, const char *path) {
if (strcmp(sizestr, "max") == 0) {
res_str = "max";
+ } else if (strcmp(sizestr, "min") == 0) {
+ res_str = "min";
} else if (strcmp(sizestr, "cancel") == 0) {
/* Different format, print and exit */
pr_verbose(LOG_DEFAULT, "Request to cancel resize\n");
This simply allows the btrfs filesystem resize command to accept "min" as an option. Processing is done in kernel. Signed-off-by: Lee Trager <lee@trager.us> --- cmds/filesystem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)