Skip to contentSkip to conversation

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

PATCH New Lee Trager 1 participant 1 message Aug 25, 2023 Btrfs file system

lore
Share & tools
lore

Lee Trager

author
#0 lore raw

PATCH 1/1 btrfs-progs: Allow specifying "min" when resizing filesystem

This simply allows the btrfs filesystem resize command to accept "min" as an option. Processing is done in kernel.

---
 cmds/filesystem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
cmds/filesystem.c +4 -1
index 79f3e799..c05054d3 100644
@@ -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");
Signature · 1 line
2.34.1