From patchwork Wed Aug 26 14:03:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaolei X-Patchwork-Id: 7077751 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2CA78C05AC for ; Wed, 26 Aug 2015 14:39:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53314208DE for ; Wed, 26 Aug 2015 14:39:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82AD2208DD for ; Wed, 26 Aug 2015 14:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756646AbbHZOFg (ORCPT ); Wed, 26 Aug 2015 10:05:36 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:64775 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1756589AbbHZOFU (ORCPT ); Wed, 26 Aug 2015 10:05:20 -0400 X-IronPort-AV: E=Sophos;i="5.15,520,1432569600"; d="scan'208";a="100045105" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 26 Aug 2015 22:08:26 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t7QE5AF7026810 for ; Wed, 26 Aug 2015 22:05:10 +0800 Received: from localhost.localdomain (10.167.226.114) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server id 14.3.181.6; Wed, 26 Aug 2015 22:05:16 +0800 From: Zhao Lei To: CC: Zhao Lei Subject: [PATCH 4/4] btrfs-progs: Simplify all-subvolumn-clean condition for wait_for_subvolume_cleaning Date: Wed, 26 Aug 2015 22:03:39 +0800 Message-ID: <26cc4d36b398b1bb582532db5cd8e65019e1e812.1440597812.git.zhaolei@cn.fujitsu.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using a dirty-subvolumn-counter in old code, this patch turn to use a simple and direct way: If (not dirty-subvolumn found in current loop) { return all_clean; } Signed-off-by: Zhao Lei --- cmds-subvolume.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/cmds-subvolume.c b/cmds-subvolume.c index 0b398f0..20e2c01 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -67,11 +67,11 @@ static int wait_for_subvolume_cleaning(int fd, int count, u64 *ids, int sleep_interval) { int ret; - int remaining; + int dirty_cnt; int i; - remaining = count; while (1) { + dirty_cnt = 0; for (i = 0; i < count; i++) { if (!ids[i]) continue; @@ -80,22 +80,21 @@ static int wait_for_subvolume_cleaning(int fd, int count, u64 *ids, fprintf(stderr, "ERROR: can't perform the search - %s\n", strerror(-ret)); - goto out; + return ret; } if (ret) { printf("Subvolume id %llu is gone\n", ids[i]); ids[i] = 0; - remaining--; + } else { + dirty_cnt++; } } - if (!remaining) + if (dirty_cnt == 0) break; sleep(sleep_interval); } - ret = 0; -out: - return ret; + return 0; } static const char * const subvolume_cmd_group_usage[] = {