Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp636142rwr; Thu, 20 Apr 2023 04:34:47 -0700 (PDT) X-Google-Smtp-Source: AKy350bMGdYyQd4oNxWvQWM2fba3VZwD1YYz0PWR3el5AleWlpZKrAQcLpohcsjDH1MiixhcfGtx X-Received: by 2002:a17:902:da81:b0:1a1:add5:c355 with SMTP id j1-20020a170902da8100b001a1add5c355mr1600051plx.5.1681990487617; Thu, 20 Apr 2023 04:34:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681990487; cv=none; d=google.com; s=arc-20160816; b=kg2JV6DqAQeIrLVux5Te8SYazQ+sLoy3TGdm2IjJrEAxGRflZdYFdAxYbNBQ+HQF7/ aW9ThpsiUUb7WhXXXxtNjWgKS+N8mgRm5kWm8XMnb95hIKWDfCUdsQR329zWibBOFxG2 fcAhMz6zBXvkhTWse+oFDQMC/V8ZcW8/D9I58JtLR+WYraK0J0QzoqGkACpMUNyBxDsP ce8ip/6Osy7j/PZG5imqU4/cpNQ9yZpX/Q4pKFh32UbFQVBx4j1wozJaie8/BYPB2txC ExKDlHY3JreGvVWQz4LauNbLgHPW66hymZU854VKvpgncyTZPxzJc8K/DefxySNL+EQH B44A== 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=aV72MPo/QVgpm81UJG9HNcQ8101Ja154dK8BzvUH0wQ=; b=yw6m/qheFTjlx2vCOMKCFfM5KLhDEuuAO8+hWob+1GPLAaoafBqlX16iNKmKE61YKh BlU5bPEHcEuBHV5nbXbz6koU/gqbO+A9jvy76uehhf4uyBZxzsHa9CYYS9kNl0YQ/xMt MAhdiVxpTmgwJQBZEJb43hBe9UEY2A5VESlhCAA7zrue4ZOVWe/IxoJOucQPFsC+qzeo fpbVt6Wl3xGziAMvDdxnPuJBvZT7RihXAt/zX/Uy1bzzJ/3RIVRVEdWqjhrHAkC6g2km cnXwoZF4h9iwoxrMYNZGRspDZg0T4l915mhJ8tXhXNxhdMLgGEpK2Q7zxzoaufQC2k0T 4kcg== 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 b3-20020a170902e94300b001a64b5976c4si1756628pll.110.2023.04.20.04.34.34; Thu, 20 Apr 2023 04:34:47 -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 S234686AbjDTLcB (ORCPT + 99 others); Thu, 20 Apr 2023 07:32:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234052AbjDTLbo (ORCPT ); Thu, 20 Apr 2023 07:31:44 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F3B51FFB; Thu, 20 Apr 2023 04:31:21 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Q2Fpp3d77z4f3nV8; Thu, 20 Apr 2023 19:31:14 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCnD7OAIkFkVY8hHw--.17021S8; Thu, 20 Apr 2023 19:31:15 +0800 (CST) From: Yu Kuai To: song@kernel.org, neilb@suse.de, akpm@osdl.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 4/8] md/raid1-10: factor out a helper to submit normal write Date: Thu, 20 Apr 2023 19:29:42 +0800 Message-Id: <20230420112946.2869956-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230420112946.2869956-1-yukuai1@huaweicloud.com> References: <20230420112946.2869956-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgCnD7OAIkFkVY8hHw--.17021S8 X-Coremail-Antispam: 1UD129KBjvJXoWxAF1rXFW5ZF1xGrW5urW3Jrb_yoW5tFWxp3 9Iqas3Z3y7XFW7Wa1DZay8J3WSg3WDtrWUCFW3CayfAFy3ZryDta18JryIgryDAFyrCry7 ZF18K3y7Ww47JFUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9C14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrw CFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE 14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2 IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxK x2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI 0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQSdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,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 There are multiple places to do the same thing, factor out a helper to prevent redundant code, and the helper will be used in following patch as well. Signed-off-by: Yu Kuai --- drivers/md/raid1-10.h | 17 +++++++++++++++++ drivers/md/raid1.c | 13 ++----------- drivers/md/raid10.c | 26 ++++---------------------- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/drivers/md/raid1-10.h b/drivers/md/raid1-10.h index 664646a3591a..9dc53d8a8129 100644 --- a/drivers/md/raid1-10.h +++ b/drivers/md/raid1-10.h @@ -113,6 +113,22 @@ static inline void md_bio_reset_resync_pages(struct bio *bio, } while (idx++ < RESYNC_PAGES && size > 0); } +static inline void md_submit_write(struct bio *bio) +{ + struct md_rdev *rdev = (struct md_rdev *)bio->bi_bdev; + + bio->bi_next = NULL; + bio_set_dev(bio, rdev->bdev); + if (test_bit(Faulty, &rdev->flags)) + bio_io_error(bio); + else if (unlikely(bio_op(bio) == REQ_OP_DISCARD && + !bdev_max_discard_sectors(bio->bi_bdev))) + /* Just ignore it */ + bio_endio(bio); + else + submit_bio_noacct(bio); +} + static inline bool md_add_bio_to_plug(struct mddev *mddev, struct bio *bio, blk_plug_cb_fn unplug) { @@ -128,4 +144,5 @@ static inline bool md_add_bio_to_plug(struct mddev *mddev, struct bio *bio, return true; } + #endif diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 44c8d113621f..c068ed3e6c96 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -797,17 +797,8 @@ static void flush_bio_list(struct r1conf *conf, struct bio *bio) while (bio) { /* submit pending writes */ struct bio *next = bio->bi_next; - struct md_rdev *rdev = (void *)bio->bi_bdev; - bio->bi_next = NULL; - bio_set_dev(bio, rdev->bdev); - if (test_bit(Faulty, &rdev->flags)) { - bio_io_error(bio); - } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && - !bdev_max_discard_sectors(bio->bi_bdev))) - /* Just ignore it */ - bio_endio(bio); - else - submit_bio_noacct(bio); + + md_submit_write(bio); bio = next; cond_resched(); } diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index d67c5672933c..fd625026c97b 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -907,17 +907,8 @@ static void flush_pending_writes(struct r10conf *conf) while (bio) { /* submit pending writes */ struct bio *next = bio->bi_next; - struct md_rdev *rdev = (void*)bio->bi_bdev; - bio->bi_next = NULL; - bio_set_dev(bio, rdev->bdev); - if (test_bit(Faulty, &rdev->flags)) { - bio_io_error(bio); - } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && - !bdev_max_discard_sectors(bio->bi_bdev))) - /* Just ignore it */ - bio_endio(bio); - else - submit_bio_noacct(bio); + + md_submit_write(bio); bio = next; cond_resched(); } @@ -1127,17 +1118,8 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) while (bio) { /* submit pending writes */ struct bio *next = bio->bi_next; - struct md_rdev *rdev = (void*)bio->bi_bdev; - bio->bi_next = NULL; - bio_set_dev(bio, rdev->bdev); - if (test_bit(Faulty, &rdev->flags)) { - bio_io_error(bio); - } else if (unlikely((bio_op(bio) == REQ_OP_DISCARD) && - !bdev_max_discard_sectors(bio->bi_bdev))) - /* Just ignore it */ - bio_endio(bio); - else - submit_bio_noacct(bio); + + md_submit_write(bio); bio = next; cond_resched(); } -- 2.39.2