linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Misono, Tomohiro" <misono.tomohiro@jp.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH v2 1/5] btrfs-progs: subvol: exchange subvol del --commit-after and --commit-each
Date: Wed, 27 Sep 2017 11:01:09 +0900	[thread overview]
Message-ID: <4ea9ba07-a36e-57f6-57a5-331f064482da@jp.fujitsu.com> (raw)
In-Reply-To: <7610069d-bd81-2239-0be8-6635478c2dda@jp.fujitsu.com>

Current code is reversed in --commit-after and --commit-each operation.
i.e. --commit-after means --commit-each actually. This patch fix this
and also introduces enum type for more readable code.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
---
 cmds-subvolume.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 666f6e0..9e561f3 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -263,6 +263,7 @@ static int cmd_subvol_delete(int argc, char **argv)
 	DIR	*dirstream = NULL;
 	int verbose = 0;
 	int commit_mode = 0;
+	enum { COMMIT_AFTER = 1, COMMIT_EACH = 2 };
 
 	while (1) {
 		int c;
@@ -279,10 +280,10 @@ static int cmd_subvol_delete(int argc, char **argv)
 
 		switch(c) {
 		case 'c':
-			commit_mode = 1;
+			commit_mode = COMMIT_AFTER;
 			break;
 		case 'C':
-			commit_mode = 2;
+			commit_mode = COMMIT_EACH;
 			break;
 		case 'v':
 			verbose++;
@@ -298,7 +299,7 @@ static int cmd_subvol_delete(int argc, char **argv)
 	if (verbose > 0) {
 		printf("Transaction commit: %s\n",
 			!commit_mode ? "none (default)" :
-			commit_mode == 1 ? "at the end" : "after each");
+			commit_mode == COMMIT_AFTER ? "at the end" : "after each");
 	}
 
 	cnt = optind;
@@ -338,7 +339,7 @@ again:
 	}
 
 	printf("Delete subvolume (%s): '%s/%s'\n",
-		commit_mode == 2 || (commit_mode == 1 && cnt + 1 == argc)
+		commit_mode == COMMIT_EACH || (commit_mode == COMMIT_AFTER && cnt + 1 == argc)
 		? "commit" : "no-commit", dname, vname);
 	memset(&args, 0, sizeof(args));
 	strncpy_null(args.name, vname);
@@ -350,7 +351,7 @@ again:
 		goto out;
 	}
 
-	if (commit_mode == 1) {
+	if (commit_mode == COMMIT_EACH) {
 		res = wait_for_commit(fd);
 		if (res < 0) {
 			error("unable to wait for commit after '%s': %s",
@@ -373,7 +374,7 @@ out:
 		goto again;
 	}
 
-	if (commit_mode == 2 && fd != -1) {
+	if (commit_mode == COMMIT_AFTER && fd != -1) {
 		res = wait_for_commit(fd);
 		if (res < 0) {
 			error("unable to do final sync after deletion: %s",
-- 
2.9.5


  reply	other threads:[~2017-09-27  2:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-27  2:00 [PATCH v2 0/5] btrfs-progs: subvol: fix del --commit-after Misono, Tomohiro
2017-09-27  2:01 ` Misono, Tomohiro [this message]
2017-09-27  2:01 ` [PATCH v2 2/5] btrfs-progs: move get_fsid() to util.c Misono, Tomohiro
2017-09-27  2:02 ` [PATCH v2 3/5] btrfs-progs: move seen_fsid " Misono, Tomohiro
2017-09-27  2:02 ` [PATCH v2 4/5] btrfs-progs: change seen_fsid to hold fd and DIR* Misono, Tomohiro
2017-09-27  2:03 ` [PATCH v2 5/5] btrfs-progs: subvol: fix subvol del --commit-after Misono, Tomohiro
2017-09-27 15:03   ` David Sterba
2017-09-27 15:08 ` [PATCH v2 0/5] btrfs-progs: subvol: fix " David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ea9ba07-a36e-57f6-57a5-331f064482da@jp.fujitsu.com \
    --to=misono.tomohiro@jp.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).