From patchwork Sun Feb 5 06:22:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9555911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AA543604DA for ; Sun, 5 Feb 2017 06:23:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A7F526E81 for ; Sun, 5 Feb 2017 06:23:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DD2A27165; Sun, 5 Feb 2017 06:23:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C85926E81 for ; Sun, 5 Feb 2017 06:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751385AbdBEGWm (ORCPT ); Sun, 5 Feb 2017 01:22:42 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35965 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891AbdBEGWg (ORCPT ); Sun, 5 Feb 2017 01:22:36 -0500 Received: by mail-pf0-f196.google.com with SMTP id 19so4540566pfo.3; Sat, 04 Feb 2017 22:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TccNPI6/wT71CvsZ1NUmkM19w0enyVHMLcSHVYxUtCE=; b=ryJ2SQxff8kAPf9IwLS3vwVDNjCy7QDsWrCZ4emvdKnu/toRm4iTBqiDfZd2kf2e8y UzEMywt1iVCP9LdYOX5YPYTI3ayRTj7OSWXHOAd5UeDSGhHKVjuoq4OLeRsNLh+knG+U mKI6uySj+LQAsPhjlT1MOopIvKmd5TddF2eZlVuwxHhdZuDdk/WeYbN5ZbIRsV2yotXV yo9GYBzYncYltQO/+7f+rV0OkooS4zDWWzNNODR5Ruhht79Gwvz1S8QfNIyhu+OxeDyS gUBDx6nBO636WVVsyupHOj4dq0NKEtIuEo5TaykuQpudyFDkhS/xIOb0pqNWWSv1i6fb +hcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TccNPI6/wT71CvsZ1NUmkM19w0enyVHMLcSHVYxUtCE=; b=aV73lv0Stg7MM91ptT8Oj6i8cAPLKHTzrx7icyyhCfwanhN+Nu7va/AgdUI4q/q86N vV975Ey/Yx0Oz7xgrJPLX5VN/Ot+LjFXy+Bd83sy/WGCBvnxiuPb2u8wzCZH1gi5P3xH tVYWoEXh/8vITGQlcQ8TlrvPQdi2Z8nzMx49XNPE90mvjMUZOwr5VVV+01D7v9RDf0lP O3CgUSpv7VHZR6ZK1Iz8kbEWgZ/Y0ODRBVI4EmF7ODgJ/8x34+wwab3rll0bwPHHC9H7 tkodc0idPPLVCghk5jTgQbnW+7G1FzX8Y2eteMODYnzUY6qU9hNU6x/ZolMTMIZuIuNz SCEw== X-Gm-Message-State: AIkVDXKf9OUWQcUWkxA2mYTlQmT7oAINfdLpIAmF7aoWG0kTx8AWbln+It1dwcSLLd7guw== X-Received: by 10.84.216.30 with SMTP id m30mr8294940pli.72.1486275755616; Sat, 04 Feb 2017 22:22:35 -0800 (PST) Received: from localhost (li405-222.members.linode.com. [106.187.53.222]) by smtp.gmail.com with ESMTPSA id z127sm64619187pgz.29.2017.02.04.22.22.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Feb 2017 22:22:34 -0800 (PST) From: Ming Lei To: Shaohua Li , Jens Axboe , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-block@vger.kernel.org, Christoph Hellwig , NeilBrown Cc: Ming Lei Subject: [PATCH 2/4] md: introduce bio_clone_slow_mddev_partial() Date: Sun, 5 Feb 2017 14:22:11 +0800 Message-Id: <1486275733-7268-3-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486275733-7268-1-git-send-email-tom.leiming@gmail.com> References: <1486275733-7268-1-git-send-email-tom.leiming@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In raid1/raid10, most users of bio_clone_mddev() need bio_trim() too, that means only part of the bio is required to be cloned, and not necessary to clone the whole bio each time, and it is just enough to clone the specified bvecs range. So this patch introduces bio_clone_slow_mddev_partial() to improve the situation, and it is named as slow because the following patch will switch to bio_clone_fast() in bio_clone_mddev(). Signed-off-by: Ming Lei --- drivers/md/md.c | 16 ++++++++++++++++ drivers/md/md.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/drivers/md/md.c b/drivers/md/md.c index 4c1b82defa78..704be11355a9 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -200,6 +200,22 @@ struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask, } EXPORT_SYMBOL_GPL(bio_clone_mddev); +struct bio *bio_clone_slow_mddev_partial(struct bio *bio, gfp_t gfp_mask, + struct mddev *mddev, int offset, + int size) +{ + struct bio_set *bs; + + if (!mddev || !mddev->bio_set) + bs = fs_bio_set; + else + bs = mddev->bio_set; + + return bio_clone_bioset_partial(bio, gfp_mask, bs, offset << 9, + size << 9); +} +EXPORT_SYMBOL_GPL(bio_clone_slow_mddev_partial); + /* * We have a system wide 'event count' that is incremented * on any 'interesting' event, and readers of /proc/mdstat diff --git a/drivers/md/md.h b/drivers/md/md.h index 968bbe72b237..4f4e6ded59e5 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -675,6 +675,9 @@ extern void mddev_suspend(struct mddev *mddev); extern void mddev_resume(struct mddev *mddev); extern struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask, struct mddev *mddev); +extern struct bio *bio_clone_slow_mddev_partial(struct bio *bio, gfp_t gfp_mask, + struct mddev *mddev, int offset, + int size); extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs, struct mddev *mddev);