From patchwork Thu May 6 04:04:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1474771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FbKjV0wrCz9sW5; Thu, 6 May 2021 14:05:01 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1leVFy-00054O-Sa; Thu, 06 May 2021 04:04:58 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1leVFw-00053W-TL for kernel-team@lists.ubuntu.com; Thu, 06 May 2021 04:04:56 +0000 Received: from mail-pf1-f200.google.com ([209.85.210.200]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1leVFw-0005Od-Kb for kernel-team@lists.ubuntu.com; Thu, 06 May 2021 04:04:56 +0000 Received: by mail-pf1-f200.google.com with SMTP id 76-20020a62164f0000b029027f27f50e56so2708322pfw.16 for ; Wed, 05 May 2021 21:04:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RitwzflkCSy2JzdX6UNRuR+PRr4Sa1D7vtgJfyXE2J8=; b=BC828fLhTOIcJwTdeZiJp6hp/ihaXOmg2ZVjsRchw8HuDiy/AyApDrtXyBJHWW8Bbw MICNDfBcMlHRRMSPSecmkd7ZGq5J1XwCEMzrr2LUjVjJBxR850GMrIfN9EPXJlIZBRhT ufeYWB9lKSTYXfupHhVb790UtwqRr2CaLANoEBEVGmJ88pYecPVusyobEwGT8XjHFqHi KMaN1ol9OotpZTQs3j7DuIb6o8JXBPQovJBLT/SHorkCz0XH6qgwihxvFWmUT7L76wWj H4tt/p1KSeK+ZuJKsGGEEVYNT69Duhweq9KAO12CGdpHLDNeOUmJkUpd2cRb2pFI+Jmq c9Kg== X-Gm-Message-State: AOAM533ujccSIzzQRV1Ayh8/P6DyQd4S+26/FJTtLWBh++WVv795Cmar 9mpDUGmIO5ERhE4dSctQKguObLaAGVh7EOh4Ju0uMbC1/jY7HHGJfEGof1xH1Yoe1NWV/NmgwRg gIUHWe6d9KLybRpT5nHB35SGnqj6zl1CA8C1cToU/fQ== X-Received: by 2002:a63:4d24:: with SMTP id a36mr2262585pgb.64.1620273895368; Wed, 05 May 2021 21:04:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8/0xeqvEauOaSJU7aNdZu9ldSEMER18rPoHi8JVjIDOg9LEJcyMOKPNwv6QZ/JpYVOlMguA== X-Received: by 2002:a63:4d24:: with SMTP id a36mr2262569pgb.64.1620273895127; Wed, 05 May 2021 21:04:55 -0700 (PDT) Received: from desktop.. (122-58-78-211-adsl.sparkbb.co.nz. [122.58.78.211]) by smtp.gmail.com with ESMTPSA id ge4sm675315pjb.4.2021.05.05.21.04.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 21:04:54 -0700 (PDT) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][F][G][PATCH 1/6] md: add md_submit_discard_bio() for submitting discard bio Date: Thu, 6 May 2021 16:04:33 +1200 Message-Id: <20210506040442.10877-3-matthew.ruffell@canonical.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210506040442.10877-1-matthew.ruffell@canonical.com> References: <20210506040442.10877-1-matthew.ruffell@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Xiao Ni BugLink: https://bugs.launchpad.net/bugs/1896578 Move these logic from raid0.c to md.c, so that we can also use it in raid10.c. Reviewed-by: Coly Li Reviewed-by: Guoqing Jiang Tested-by: Adrian Huang Signed-off-by: Xiao Ni Signed-off-by: Song Liu (backported from cf78408f937a67f59f5e90ee8e6cadeed7c128a8) [mruffell: change submit_bio_noacct() to generic_make_request(), add request_queue argument to trace_block_bio_remap()] Signed-off-by: Matthew Ruffell --- drivers/md/md.c | 20 ++++++++++++++++++++ drivers/md/md.h | 2 ++ drivers/md/raid0.c | 14 ++------------ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 209d88bda401..ff5f4f658bf6 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8566,6 +8566,26 @@ void md_write_end(struct mddev *mddev) EXPORT_SYMBOL(md_write_end); +/* This is used by raid0 and raid10 */ +void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, + struct bio *bio, sector_t start, sector_t size) +{ + struct bio *discard_bio = NULL; + + if (__blkdev_issue_discard(rdev->bdev, start, size, GFP_NOIO, 0, + &discard_bio) || !discard_bio) + return; + + bio_chain(discard_bio, bio); + bio_clone_blkg_association(discard_bio, bio); + if (mddev->gendisk) + trace_block_bio_remap(bdev_get_queue(rdev->bdev), + discard_bio, disk_devt(mddev->gendisk), + bio->bi_iter.bi_sector); + generic_make_request(discard_bio); +} +EXPORT_SYMBOL_GPL(md_submit_discard_bio); + /* md_allow_write(mddev) * Calling this ensures that the array is marked 'active' so that writes * may proceed without blocking. It is important to call this before diff --git a/drivers/md/md.h b/drivers/md/md.h index c26fa8bd41e7..7ded5599eca4 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -710,6 +710,8 @@ extern void md_write_end(struct mddev *mddev); extern void md_done_sync(struct mddev *mddev, int blocks, int ok); extern void md_error(struct mddev *mddev, struct md_rdev *rdev); extern void md_finish_reshape(struct mddev *mddev); +void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, + struct bio *bio, sector_t start, sector_t size); extern int mddev_congested(struct mddev *mddev, int bits); extern bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio); diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 57e834964b00..b1cf4384d253 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -526,7 +526,6 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) for (disk = 0; disk < zone->nb_dev; disk++) { sector_t dev_start, dev_end; - struct bio *discard_bio = NULL; struct md_rdev *rdev; if (disk < start_disk_index) @@ -549,18 +548,9 @@ static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) rdev = conf->devlist[(zone - conf->strip_zone) * conf->strip_zone[0].nb_dev + disk]; - if (__blkdev_issue_discard(rdev->bdev, + md_submit_discard_bio(mddev, rdev, bio, dev_start + zone->dev_start + rdev->data_offset, - dev_end - dev_start, GFP_NOIO, 0, &discard_bio) || - !discard_bio) - continue; - bio_chain(discard_bio, bio); - bio_clone_blkg_association(discard_bio, bio); - if (mddev->gendisk) - trace_block_bio_remap(bdev_get_queue(rdev->bdev), - discard_bio, disk_devt(mddev->gendisk), - bio->bi_iter.bi_sector); - generic_make_request(discard_bio); + dev_end - dev_start); } bio_endio(bio); }