Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp9656193rwr; Thu, 11 May 2023 19:23:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xBLgyw3bn+U+/7fTfPzfekiadchlJDBGQsez+R2M0FnNWa18A6AnurEInC+ofC/vmia8+ X-Received: by 2002:a17:902:ab91:b0:1ad:dbea:6e09 with SMTP id f17-20020a170902ab9100b001addbea6e09mr1590722plr.66.1683858179859; Thu, 11 May 2023 19:22:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683858179; cv=none; d=google.com; s=arc-20160816; b=1ELVHMPOWIgIbb5RO0Lwv5OSn2PUDxb+pc5T4MByiUoCKc/luw5JPwPFP0iBNIuG1n Ii/vjz2djW0mGCHKatYw8sR0B96o8KiBsmXzINrsG//nAoA8kO1+E2aY5EA6iBLiOGQe PDsOAzCgyirYfRKSaPkEmJoYOcFBE15Enqmq5zNsen5l9srDXdS7QadpAU8WLT1ORxRo gWw2riY2eyc/BaTDXXMbSbqWS5yjhoior8LKBedu93aeQL4WshRbbijnhrNvEJc0+bq7 1W5i5kDwYB7qPFC5871DVazDcOJK0bxrqxCLSrZU8R04UweDdIcbMDOsd42daHceQwBA IgwA== 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=3PIS1ybc9+8evTaOhifebTLZrf+xYNjxIdLG9sIWTi0=; b=fjfAK27H8ysRMS1JQxrNzUzlIcd+9iizeQp4m+aqbTc8KCHGYi828wmN9w+cdtt3wY oUcG0gk7/JaYkCN39uGLti5KjZX9MJF42Qdqq4ACsrw8BUhq+LsHzMtGDjtY4fB6Fh4q b7A1tvT7CPZbTzhUN2VW3MIRqe5Y/fqKuiOCU9YTpPFI+DS7Muu2xN1YEsl5eX275nWj lZiO5VL/GeYjc9A81762iPkX8KjXAnYObxIJ+xtfk6j0ipIFQ4P6C1l/QJeWIVXJz6rp uVZc/DQeoctyFWNHAgj3v9NGE4G5zViNAV7G33eNkeUqhoyUJRdv2hQozTOlOtYT1QEZ g8Zw== 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 g8-20020a1709029f8800b001a9a032386dsi7575821plq.349.2023.05.11.19.22.47; Thu, 11 May 2023 19:22:59 -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 S239824AbjELB7R (ORCPT + 99 others); Thu, 11 May 2023 21:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239679AbjELB66 (ORCPT ); Thu, 11 May 2023 21:58:58 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38A0959F1; Thu, 11 May 2023 18:58:55 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4QHX4B6t5fz4f3lXk; Fri, 12 May 2023 09:58:50 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBnHbFYnV1kbjQOJQ--.16243S5; Fri, 12 May 2023 09:58:50 +0800 (CST) From: Yu Kuai To: logang@deltatee.com, reddunur@online.de, jovetoo@gmail.com, dgilmour76@gmail.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 1/5] md/raid5: don't allow replacement while reshape is not done Date: Fri, 12 May 2023 09:56:06 +0800 Message-Id: <20230512015610.821290-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230512015610.821290-1-yukuai1@huaweicloud.com> References: <20230512015610.821290-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBnHbFYnV1kbjQOJQ--.16243S5 X-Coremail-Antispam: 1UD129KBjvJXoW7uF4DZryrKFWkuFyUGrWDXFb_yoW8Gry3pa nIkF1DXr4UZws8ta1DJa48CFyS9Fs2grZ8KrW3u34Yv3Wjqr4kA3y8KryUCr4DZF4Y93ya qw47trWDA34Iy37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JU2_M3UUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Set rdev replacement has but not only two conditions: 1) MD_RECOVERY_RUNNING is not set; 2) rdev nr_pending is 0; If reshape is interrupted(for example, echo frozen to sync_action), then rdev replacement can be set. It's safe because reshape is always prior to resync in md_check_recovery(). However, if system reboots, then kernel will complain cannot handle concurrent replacement and reshape and this array is not able to assemble anymore. Fix this problem by don't allow replacement until reshape is done. Reported-by: Peter Neuwirth Link: https://lore.kernel.org/linux-raid/e2f96772-bfbc-f43b-6da1-f520e5164536@online.de/ Signed-off-by: Yu Kuai --- drivers/md/raid5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index a58507a4345d..bd3b535c0739 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -8378,6 +8378,7 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev) p = conf->disks + disk; tmp = rdev_mdlock_deref(mddev, p->rdev); if (test_bit(WantReplacement, &tmp->flags) && + mddev->reshape_position == MaxSector && p->replacement == NULL) { clear_bit(In_sync, &rdev->flags); set_bit(Replacement, &rdev->flags); -- 2.39.2