Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp2553645rdb; Fri, 18 Aug 2023 04:05:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkbs9R3Gn82I+lGFT7K2mMUvakPtCmAlgszcpvb3D84Q9xkXoKCrJb1JBdj4Q/GyNYN1Ab X-Received: by 2002:a05:6a20:841e:b0:140:3aa:e2ce with SMTP id c30-20020a056a20841e00b0014003aae2cemr3310039pzd.42.1692356752708; Fri, 18 Aug 2023 04:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692356752; cv=none; d=google.com; s=arc-20160816; b=mRSIPIE0KI+UIA3Shnv0r1fwaorKWVJthFaFQ4+2acA2L44+EVEawzB4efDOI3dSgi S/xChsvrbGL+SrGcMmdxPNaOJpQlE/gKnShmE0qNkqFpcgGgLx5MJrdDwFkVQzqu/3En mVsa9cSge1xpVSTirZ9+7CaXUzioil0l5Sz54M6IwjPyRRnm13NsjTzASsnJnKNsaGUN 29Xe4l5QxJD8yGvWj+osj0cYAU0BQB9Rs/FdrVpJPzuoY8S63tBs/wNCfgB/Y4NLKV+G nLTXgeH8K9zFkJqbQpBfxRk8iRUSuibsUMUN2Yk0FT89AOERWFBVzOdSFzLSrRNRIu80 BwhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+k4AymOTYpK21gn03wgHsQAPsh+GXZ0jNfrYWgrQlN4=; fh=IbQVS9zw4f0wpFIN30h3V23lkpsn7ElwlgfpAcJnn1g=; b=0+NZXG5Dlu6MBW+G0oZeqR3zcyFlMGrEK7EYY4t6R7obCbI9h60p9tx6lqZ5oBAYqJ iQtyI0OW8cO6wSAoZLoOMGjb4wGLL6bTbcJX6J05hyJBMjeeg1Sa6m5NoYFfHfv4KBrg ggyt5XuhLicJO7XgaSKdzW7UwCg4j68TlHEE1PMNqDH5Mm/fnzaplhW0YkmyK4//CydV mF1MMkmfUM1rPFTPc+t7K0i8bQbAbFU7rnRMsmmbAN6o57r/SCS7TnPad6iI1rrzoW0U 3Bux1kq80RuTm6w6VxyT/ltteE1YkGlmE04+wKYx1GUEgkPNx5X57hkhB2M5D8xNnZcU B7Ew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w3-20020a63f503000000b0055b43079640si1230904pgh.707.2023.08.18.04.05.39; Fri, 18 Aug 2023 04:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234407AbjHODQH (ORCPT + 99 others); Mon, 14 Aug 2023 23:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234238AbjHODOW (ORCPT ); Mon, 14 Aug 2023 23:14:22 -0400 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4609D1998; Mon, 14 Aug 2023 20:13:40 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4RPxDZ1nQ1z4f3khv; Tue, 15 Aug 2023 11:13:34 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgAXp6ld7dpknET3Ag--.64666S9; Tue, 15 Aug 2023 11:13:37 +0800 (CST) From: Yu Kuai To: xni@redhat.com, song@kernel.org Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH -next v2 5/7] md: factor out a helper rdev_is_spare() from remove_and_add_spares() Date: Tue, 15 Aug 2023 11:09:55 +0800 Message-Id: <20230815030957.509535-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230815030957.509535-1-yukuai1@huaweicloud.com> References: <20230815030957.509535-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAXp6ld7dpknET3Ag--.64666S9 X-Coremail-Antispam: 1UD129KBjvJXoW7Kr47Kr4xtr13KF4fCF1fCrg_yoW8GF17pa yIgFWYkw4UZayUWa1vgryUGa43K3W0g3yIkFyxCa4fZas8Jry5Kws5CF90qFn8AFWFvF45 Za1Uta1kCF1rKF7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMx C20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAF wI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20x vE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v2 0xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxV W8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQSdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu Kuai There are no functional changes, just to make the code simpler and prepare to delay remove_and_add_spares() to md_start_sync(). Signed-off-by: Yu Kuai --- drivers/md/md.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index ea091eef23d1..6baaa4d314b3 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -9169,6 +9169,14 @@ static bool rdev_removeable(struct md_rdev *rdev) return true; } +static bool rdev_is_spare(struct md_rdev *rdev) +{ + return !test_bit(Candidate, &rdev->flags) && rdev->raid_disk >= 0 && + !test_bit(In_sync, &rdev->flags) && + !test_bit(Journal, &rdev->flags) && + !test_bit(Faulty, &rdev->flags); +} + static int remove_and_add_spares(struct mddev *mddev, struct md_rdev *this) { @@ -9217,13 +9225,10 @@ static int remove_and_add_spares(struct mddev *mddev, rdev_for_each(rdev, mddev) { if (this && this != rdev) continue; + if (rdev_is_spare(rdev)) + spares++; if (test_bit(Candidate, &rdev->flags)) continue; - if (rdev->raid_disk >= 0 && - !test_bit(In_sync, &rdev->flags) && - !test_bit(Journal, &rdev->flags) && - !test_bit(Faulty, &rdev->flags)) - spares++; if (rdev->raid_disk >= 0) continue; if (test_bit(Faulty, &rdev->flags)) -- 2.39.2