Skip to contentSkip to conversation

Btrfs-progs: subvolume deletion commit mode update

PATCH New David Sterba 1 participant 4 messages Dec 10, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

cover Btrfs-progs: subvolume deletion commit mode update

Minor change in the output of 'subvolume delete' command, the commit mode is printed inline with the subvolume and the global message is moved under the newly added 'verbose' option.

David Sterba (3):
btrfs-progs: let subvol delete print commit mode inline
btrfs-progs: subvol delete: add verbosity option
btrfs-progs: subvol delete: rename variable to match the option name

 cmds-subvolume.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)
Signature · 1 line
2.1.3
#1 lore raw

PATCH 1/3 btrfs-progs: let subvol delete print commit mode inline

There are options to specify if the subvolume deletion should wait for commit after each subvol or at the end. This is reported at the beginning and considered as a noise. We'd like to report the mode for each subvolume instead.

http://www.mail-archive.com/linux-btrfs%40vger.kernel.org/msg34617.html

---
 cmds-subvolume.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
cmds-subvolume.c +3 -1
index 53eec467251d..4e452f4f4eb7 100644
@@ -303,7 +303,9 @@ again:
 		goto out;
 	}
 
-	printf("Delete subvolume '%s/%s'\n", dname, vname);
+	printf("Delete subvolume (%s): '%s/%s'\n",
+		sync_mode == 2 || (sync_mode == 1 && cnt + 1 == argc)
+		? "commit" : "no-commit", dname, vname);
 	strncpy_null(args.name, vname);
 	res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args);
 	e = errno;
Signature · 1 line
2.1.3
#2 lore raw

PATCH 2/3 btrfs-progs: subvol delete: add verbosity option

In reply to David Sterba

Add an the option -v and use it for the transaction commit mode message.

---
 cmds-subvolume.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
cmds-subvolume.c +10 -4
index 4e452f4f4eb7..b14f86e06cb4 100644
@@ -66,7 +66,7 @@ static int cmd_subvol_create(int argc, char **argv)
 
 	optind = 1;
 	while (1) {
-		int c = getopt(argc, argv, "c:i:");
+		int c = getopt(argc, argv, "c:i:v");
 		if (c < 0)
 			break;
 
@@ -217,6 +217,7 @@ static int cmd_subvol_delete(int argc, char **argv)
 	char	*dupvname = NULL;
 	char	*path;
 	DIR	*dirstream = NULL;
+	int verbose = 0;
 	int sync_mode = 0;
 	struct option long_options[] = {
 		{"commit-after", no_argument, NULL, 'c'},  /* sync mode 1 */
@@ -239,6 +240,9 @@ static int cmd_subvol_delete(int argc, char **argv)
 		case 'C':
 			sync_mode = 2;
 			break;
+		case 'v':
+			verbose++;
+			break;
 		default:
 			usage(cmd_subvol_delete_usage);
 		}
@@ -247,9 +251,11 @@ static int cmd_subvol_delete(int argc, char **argv)
 	if (check_argc_min(argc - optind, 1))
 		usage(cmd_subvol_delete_usage);
 
-	printf("Transaction commit: %s\n",
-		!sync_mode ? "none (default)" :
-		sync_mode == 1 ? "at the end" : "after each");
+	if (verbose > 0) {
+		printf("Transaction commit: %s\n",
+			!sync_mode ? "none (default)" :
+			sync_mode == 1 ? "at the end" : "after each");
+	}
 
 	cnt = optind;
 
Signature · 1 line
2.1.3
#3 lore raw

PATCH 3/3 btrfs-progs: subvol delete: rename variable to match the option name

In reply to David Sterba
---
 cmds-subvolume.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
cmds-subvolume.c +10 -10
index b14f86e06cb4..15d4b975a916 100644
@@ -218,10 +218,10 @@ static int cmd_subvol_delete(int argc, char **argv)
 	char	*path;
 	DIR	*dirstream = NULL;
 	int verbose = 0;
-	int sync_mode = 0;
+	int commit_mode = 0;
 	struct option long_options[] = {
-		{"commit-after", no_argument, NULL, 'c'},  /* sync mode 1 */
-		{"commit-each", no_argument, NULL, 'C'},  /* sync mode 2 */
+		{"commit-after", no_argument, NULL, 'c'},  /* commit mode 1 */
+		{"commit-each", no_argument, NULL, 'C'},  /* commit mode 2 */
 		{NULL, 0, NULL, 0}
 	};
 
@@ -235,10 +235,10 @@ static int cmd_subvol_delete(int argc, char **argv)
 
 		switch(c) {
 		case 'c':
-			sync_mode = 1;
+			commit_mode = 1;
 			break;
 		case 'C':
-			sync_mode = 2;
+			commit_mode = 2;
 			break;
 		case 'v':
 			verbose++;
@@ -253,8 +253,8 @@ static int cmd_subvol_delete(int argc, char **argv)
 
 	if (verbose > 0) {
 		printf("Transaction commit: %s\n",
-			!sync_mode ? "none (default)" :
-			sync_mode == 1 ? "at the end" : "after each");
+			!commit_mode ? "none (default)" :
+			commit_mode == 1 ? "at the end" : "after each");
 	}
 
 	cnt = optind;
@@ -310,7 +310,7 @@ again:
 	}
 
 	printf("Delete subvolume (%s): '%s/%s'\n",
-		sync_mode == 2 || (sync_mode == 1 && cnt + 1 == argc)
+		commit_mode == 2 || (commit_mode == 1 && cnt + 1 == argc)
 		? "commit" : "no-commit", dname, vname);
 	strncpy_null(args.name, vname);
 	res = ioctl(fd, BTRFS_IOC_SNAP_DESTROY, &args);
@@ -323,7 +323,7 @@ again:
 		goto out;
 	}
 
-	if (sync_mode == 1) {
+	if (commit_mode == 1) {
 		res = wait_for_commit(fd);
 		if (res < 0) {
 			fprintf(stderr,
@@ -347,7 +347,7 @@ out:
 		goto again;
 	}
 
-	if (sync_mode == 2 && fd != -1) {
+	if (commit_mode == 2 && fd != -1) {
 		res = wait_for_commit(fd);
 		if (res < 0) {
 			fprintf(stderr,
Signature · 1 line
2.1.3