From patchwork Wed Jun 14 08:47:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 107822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1100746vqr; Wed, 14 Jun 2023 02:11:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+q2S5jf9cOvVi0K7Ayzoul/eA7wFZgw7l4fZpP7j6/eNxdyCZPyRDRDj6u+av1u06DnsY X-Received: by 2002:aa7:c90d:0:b0:518:79e7:4dbf with SMTP id b13-20020aa7c90d000000b0051879e74dbfmr2830202edt.35.1686733875764; Wed, 14 Jun 2023 02:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686733875; cv=none; d=google.com; s=arc-20160816; b=Ia2EqskCyXyMswnc+zZEyBTc8vz5gl/dadF82Bf2DoagNejqabhD6r7TQuuHdyqC0h PBAsBx5NXl4MZbSe+8qui+TkVs3B0oUliWwf7qoo5DftRT6DHyNohT40uBq8NjuGrRc1 3gcVkp+zuBy0XCPCD3l9mka+MzhAWkBm2KzJZZNBUFbfjNmPxPCqRKqfh5+sf9i/0sk3 xRxbmM+dS4pZG0OXGdNGtNy+k13nIZdexCB3fI33j8RfiB7gOY/yBPQu8c89fhc0/G55 xnnuJqpx6Ob/GS5n/yk9aiqxPwhQ4i6DSmXzfemNWxxcLudlm4RzzKFVIoITSDO3rwaS +0oQ== 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=9lEhM60aVXNa1bOzPotINx+mJDB2HCwEO+L18lxn01Q=; b=SXhvmEuCyvp/1sgLanYw6U119URDF3KwKNDMwuzP2wNOZ1FgdNjEjnp9cLklvL79ux fAxgOV9E17U2Gxm3vCewMNbisURH9YEOOj7GARvP3zDErhC0dkIEqRKS9QZXmZ4xYOEM HdnnrIPXyEBNkTL07aKcggiy7Femb59A5qAPPVjgXeH7dwZTGcl3UcjcdkUeuPXBzOU/ KKMIow/9Yjwx+gNnH9TKjKGv/XKwnwAd4iqRglRiF6SuUqKpJn4+IaFml9tCGft1vZgy ZlqfZiaQ7wTGNOTB9beJOmFDRxPRwzIO0kAecfAbchRc6gUGVKytuDR7wJxuTNwmgLe6 LD5Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i19-20020a50fc13000000b0051497f4840asi8655896edr.169.2023.06.14.02.10.48; Wed, 14 Jun 2023 02:11:15 -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 S243801AbjFNIwr (ORCPT + 99 others); Wed, 14 Jun 2023 04:52:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243779AbjFNIwe (ORCPT ); Wed, 14 Jun 2023 04:52:34 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E32B271E; Wed, 14 Jun 2023 01:52:17 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4Qgzgv5rZRz4f3l7H; Wed, 14 Jun 2023 16:52:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgBnHbG7f4lks7u0Lg--.65484S5; Wed, 14 Jun 2023 16:52:13 +0800 (CST) From: linan666@huaweicloud.com To: song@kernel.org, neilb@suse.de Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH 1/3] md/raid10: record rdev/replacement in struct r10bio Date: Wed, 14 Jun 2023 16:47:38 +0800 Message-Id: <20230614084740.1493969-2-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230614084740.1493969-1-linan666@huaweicloud.com> References: <20230614084740.1493969-1-linan666@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgBnHbG7f4lks7u0Lg--.65484S5 X-Coremail-Antispam: 1UD129KBjvJXoW7Xw47Cw43AryDZw4UCr1rZwb_yoW8Jr4Upa 1DGF13Cr47Wayj9r4DAa1UCa4ftanYy3y8GFWY934aq34avrWDAF4UGrW5urWUZFsxW34I vw1DKrZ5G3WUAFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBlb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrV ACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWU JVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lw4CEc2x0rVAKj4xxMx AIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_ Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwI xGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWx JwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcV C2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU858n5UUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768668660802837175?= X-GMAIL-MSGID: =?utf-8?q?1768668660802837175?= From: Li Nan Getting rdev/replacement from mirror is risky. Replacement can replace rdev while repl_bio pending, which forces us to add some complex code to handle this scenario, but there are still some bugs left. Record rdev/replacement in r10bio and get them from r10bio is a better way. It is easy to ensure that rdev and replacement remains consistent in io process, which can help us clean up some code and fix bugs. Signed-off-by: Li Nan --- drivers/md/raid10.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/md/raid10.h b/drivers/md/raid10.h index 8c072ce0bc54..261315ffe8c0 100644 --- a/drivers/md/raid10.h +++ b/drivers/md/raid10.h @@ -145,12 +145,12 @@ struct r10bio { */ struct r10dev { struct bio *bio; - union { - struct bio *repl_bio; /* used for resync and - * writes */ - struct md_rdev *rdev; /* used for reads - * (read_slot >= 0) */ - }; + /* Currently just used for normal reads and writes */ + struct md_rdev *rdev; + /* used for resync and writes */ + struct bio *repl_bio; + /* Currently just used for normal writes */ + struct md_rdev *replacement; sector_t addr; int devnum; } devs[];