diff mbox series

btrfs-progs: Allow specifying "min" when resizing filesystem

Message ID 20230825011156.4185571-1-lee@trager.us (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: Allow specifying "min" when resizing filesystem | expand

Commit Message

Lee Trager Aug. 25, 2023, 1:11 a.m. UTC
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(-)
diff mbox series

Patch

diff --git a/cmds/filesystem.c b/cmds/filesystem.c
index 79f3e799..c05054d3 100644
--- a/cmds/filesystem.c
+++ b/cmds/filesystem.c
@@ -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");