diff mbox

btrfs-progs: remove meaningless process

Message ID 1523428000-6511-1-git-send-email-gujx@cn.fujitsu.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gu Jinxiang April 11, 2018, 6:26 a.m. UTC
Variable do_wait is synchronized with the variable do_background,
when if(do_background) is true, if(!do_wait) is also true, so parent
process will goto out immediately. The following wait never be run.

And if option -B is chosen, when do_background is 0 and do_wait is 1,
there is no need to fork a child process to wait for scrub over.

So remove unnecessary process.

Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com>
---
 cmds-scrub.c | 19 -------------------
 1 file changed, 19 deletions(-)
diff mbox

Patch

diff --git a/cmds-scrub.c b/cmds-scrub.c
index efd7db94..3fb16887 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -1109,7 +1109,6 @@  static int scrub_start(int argc, char **argv, int resume)
 	int print_raw = 0;
 	char *path;
 	int do_background = 1;
-	int do_wait = 0;
 	int do_print = 0;
 	int do_quiet = 0;
 	int do_record = 1;
@@ -1147,7 +1146,6 @@  static int scrub_start(int argc, char **argv, int resume)
 		switch (c) {
 		case 'B':
 			do_background = 0;
-			do_wait = 1;
 			do_print = 1;
 			break;
 		case 'd':
@@ -1374,28 +1372,11 @@  static int scrub_start(int argc, char **argv, int resume)
 		}
 
 		if (pid) {
-			int stat;
 			scrub_handle_sigint_parent();
 			if (!do_quiet)
 				printf("scrub %s on %s, fsid %s (pid=%d)\n",
 				       n_start ? "started" : "resumed",
 				       path, fsid, pid);
-			if (!do_wait) {
-				err = 0;
-				goto out;
-			}
-			ret = wait(&stat);
-			if (ret != pid) {
-				error_on(!do_quiet, "wait failed (ret=%d): %m",
-					ret);
-				err = 1;
-				goto out;
-			}
-			if (!WIFEXITED(stat) || WEXITSTATUS(stat)) {
-				error_on(!do_quiet, "scrub process failed");
-				err = WIFEXITED(stat) ? WEXITSTATUS(stat) : -1;
-				goto out;
-			}
 			err = 0;
 			goto out;
 		}