From patchwork Wed Apr 11 06:26:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gu Jinxiang X-Patchwork-Id: 10334879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BF1486053B for ; Wed, 11 Apr 2018 06:26:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD6428738 for ; Wed, 11 Apr 2018 06:26:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2C152873B; Wed, 11 Apr 2018 06:26:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F58B28738 for ; Wed, 11 Apr 2018 06:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752354AbeDKG0r (ORCPT ); Wed, 11 Apr 2018 02:26:47 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:26232 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751870AbeDKG0q (ORCPT ); Wed, 11 Apr 2018 02:26:46 -0400 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="38770370" Received: from bogon (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 11 Apr 2018 14:26:44 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (unknown [10.167.33.83]) by cn.fujitsu.com (Postfix) with ESMTP id BB67248AE780 for ; Wed, 11 Apr 2018 14:26:42 +0800 (CST) Received: from localhost.localdomain (10.167.226.132) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 11 Apr 2018 14:26:41 +0800 From: Gu Jinxiang To: Subject: [PATCH] btrfs-progs: remove meaningless process Date: Wed, 11 Apr 2018 14:26:40 +0800 Message-ID: <1523428000-6511-1-git-send-email-gujx@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.167.226.132] X-yoursite-MailScanner-ID: BB67248AE780.A5D4D X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: gujx@cn.fujitsu.com Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- cmds-scrub.c | 19 ------------------- 1 file changed, 19 deletions(-) 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; }