From patchwork Thu May 6 04:04:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Ruffell X-Patchwork-Id: 1474769 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 4FbKjS1S0Wz9sV5; Thu, 6 May 2021 14:04:59 +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 1leVFw-00053N-Mc; Thu, 06 May 2021 04:04:56 +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 1leVFv-000533-4X for kernel-team@lists.ubuntu.com; Thu, 06 May 2021 04:04:55 +0000 Received: from mail-pg1-f198.google.com ([209.85.215.198]) by youngberry.canonical.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1leVFu-0005OV-Sj for kernel-team@lists.ubuntu.com; Thu, 06 May 2021 04:04:54 +0000 Received: by mail-pg1-f198.google.com with SMTP id z19-20020a63e1130000b02901fcdcf0c5a3so2504073pgh.19 for ; Wed, 05 May 2021 21:04:54 -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=T5q23CIUjr6+9H0ew4bphhIE3c1YhyF6EH4kP29UHkU=; b=Raxuh5Gv9ifinY5ZPrcWqhKFJHTIIYpOwSoiYBfrJY+y6vGU1BHU/h6/q/RtJiD4q/ GcN/Tbfnf7fn8vPukTj4lDhK8pgL2JqbJI3H7q6LLmlGTxFr9VieDv8WpoaH1440Mg9G LaQ05ZBnQd9bZ8Zy4P9d4SGvEjaxYqNOMQSuoPm9sDH6OZebx1nlzJrap4xOSHiX7VHO KeIuk6kwwmZfjY7l3BE2HPmiuO9kP8c0vxB8R9ROvr6gVRhT4bwqEo4RhL+PleaNC3U8 jJUm/QNv3Ww40ogUSZx0hCmN2OSc3YJSA64eHV7gKBC2G+SNb89IifLbs61CUQUnYXEZ uCJw== X-Gm-Message-State: AOAM5300E8NXBzyYIFUw10ZAxh0YYFPSQ8TOrTws4pVSgYsajRDlgaS5 zsWHdNQ7tYrOmNh1HLtLgsLekYXxtpDCFT4kaRt4s55Ln2+2Mkw7Qg1OfkPr1ApBynCjijDJLhU fZRKeVTYK6jZsP4Q/zosgl+1qyTyQetUKaF/ViAit8w== X-Received: by 2002:aa7:842a:0:b029:28d:f82e:a4ba with SMTP id q10-20020aa7842a0000b029028df82ea4bamr2417509pfn.33.1620273893626; Wed, 05 May 2021 21:04:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYlkZdPPoNw3Ae13ngIH0NM0+yLmmUtFqoS9R/1uRaxHaCscfRshn0hYapELEgQUqf+tdl2A== X-Received: by 2002:aa7:842a:0:b029:28d:f82e:a4ba with SMTP id q10-20020aa7842a0000b029028df82ea4bamr2417479pfn.33.1620273893318; Wed, 05 May 2021 21:04:53 -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.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 21:04:52 -0700 (PDT) From: Matthew Ruffell To: kernel-team@lists.ubuntu.com Subject: [SRU][H][PATCH 1/6] md: add md_submit_discard_bio() for submitting discard bio Date: Thu, 6 May 2021 16:04:32 +1200 Message-Id: <20210506040442.10877-2-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 (cherry picked from commit cf78408f937a67f59f5e90ee8e6cadeed7c128a8) 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 04384452a7ab..476c22067798 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -8590,6 +8590,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(discard_bio, + disk_devt(mddev->gendisk), + bio->bi_iter.bi_sector); + submit_bio_noacct(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 34070ab30a8a..af1f78c5eca0 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -713,6 +713,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 bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio); extern void md_super_write(struct mddev *mddev, struct md_rdev *rdev, diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index fdada0bf2217..cbc3fbe7b54a 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -478,7 +478,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) @@ -501,18 +500,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(discard_bio, - disk_devt(mddev->gendisk), - bio->bi_iter.bi_sector); - submit_bio_noacct(discard_bio); + dev_end - dev_start); } bio_endio(bio); }