From patchwork Tue Jun 7 12:17:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 9161021 X-Patchwork-Delegate: herbert@gondor.apana.org.au 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 484FF60467 for ; Tue, 7 Jun 2016 12:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37D191FE95 for ; Tue, 7 Jun 2016 12:19:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C7DD26861; Tue, 7 Jun 2016 12:19:49 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 A830A1FE95 for ; Tue, 7 Jun 2016 12:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932385AbcFGMSL (ORCPT ); Tue, 7 Jun 2016 08:18:11 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:32938 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932381AbcFGMSI (ORCPT ); Tue, 7 Jun 2016 08:18:08 -0400 Received: by mail-pa0-f43.google.com with SMTP id ec8so39829644pac.0 for ; Tue, 07 Jun 2016 05:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=65RvATdytP+zfdamoI4QR+3pSp9fGcNQYV792kr+Ens=; b=QA03fNXgN+BOALoDjidRTvlJE7ZFTysMQ5w6Ht0mkyKaiVCB7Ud0SVR8iqFCm3W3U5 b1TOOkLx58IaNtswyR/WCWDb67CzU07+HwCp8b+AUIdpV1BDc7QQPK+JsM787i+Rs172 9UQjeum6MYBddjodWKgdZLHroEuJs7WieCumg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=65RvATdytP+zfdamoI4QR+3pSp9fGcNQYV792kr+Ens=; b=CbCmiT9vteUAututR7Wzs6OUnuilFkIs74+JJjxOYq3Za7mG6RfWUzU8SmqqDHa0sW NRfLG04l2vc9QQ/ZFf9FttBf+4+xT98Uxsg388+4aVdS4N3y1xALye9oCt8FxVSFF18H e8uOstfNIiJCLOepFXsYs+rcxLRQd9varWR0wG/88fsRDOUfIul6NuG9RlQQZlpic7dW 6wsgBafvBJLV5r+lGLVqjBom4HVCuf/SXH6ijwHJClmBTB9wJ1iIPgcvZ8B05W0KMm3r H264xnI5MtDmKbdLWkWcVT34nhjaSfG+4qgPhEuXXN9e32DRShDRTSlWA0LBdPFOhr8f UYbw== X-Gm-Message-State: ALyK8tJmuQKVfHW0QD8xhWuambw6mibJKYR107YCumI3yZDefTwBBsVirp0JQFTOR/KAyHEy X-Received: by 10.66.152.111 with SMTP id ux15mr30694667pab.43.1465301887762; Tue, 07 Jun 2016 05:18:07 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id r64sm34995877pfi.54.2016.06.07.05.18.01 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jun 2016 05:18:06 -0700 (PDT) From: Baolin Wang To: axboe@kernel.dk, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, herbert@gondor.apana.org.au, davem@davemloft.net Cc: ebiggers3@gmail.com, js1304@gmail.com, tadeusz.struk@intel.com, smueller@chronox.de, standby24x7@gmail.com, shli@kernel.org, dan.j.williams@intel.com, martin.petersen@oracle.com, sagig@mellanox.com, kent.overstreet@gmail.com, keith.busch@intel.com, tj@kernel.org, ming.lei@canonical.com, broonie@kernel.org, arnd@arndb.de, linux-crypto@vger.kernel.org, linux-block@vger.kernel.org, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [RFC v4 1/4] block: Introduce blk_bio_map_sg() to map one bio Date: Tue, 7 Jun 2016 20:17:04 +0800 Message-Id: <311c342ac55d36ab03e44c31dc65ebfa24cbc8aa.1465301616.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In dm-crypt, it need to map one bio to scatterlist for improving the hardware engine encryption efficiency. Thus this patch introduces the blk_bio_map_sg() function to map one bio with scatterlists. Signed-off-by: Baolin Wang --- block/blk-merge.c | 19 +++++++++++++++++++ include/linux/blkdev.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/block/blk-merge.c b/block/blk-merge.c index 2613531..bca0609 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -417,6 +417,25 @@ single_segment: } /* + * Map a bio to scatterlist, return number of sg entries setup. Caller must + * make sure sg can hold bio segments entries and detach the bio from list. + */ +int blk_bio_map_sg(struct request_queue *q, struct bio *bio, + struct scatterlist *sglist) +{ + struct scatterlist *sg = NULL; + int nsegs; + + nsegs = __blk_bios_map_sg(q, bio, sglist, &sg); + + if (sg) + sg_mark_end(sg); + + return nsegs; +} +EXPORT_SYMBOL(blk_bio_map_sg); + +/* * map a request to scatterlist, return number of sg entries setup. Caller * must make sure sg can hold rq->nr_phys_segments entries */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3d9cf32..cbe31f9 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1024,6 +1024,8 @@ extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fu extern struct backing_dev_info *blk_get_backing_dev_info(struct block_device *bdev); extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *); +extern int blk_bio_map_sg(struct request_queue *q, struct bio *bio, + struct scatterlist *sglist); extern void blk_dump_rq_flags(struct request *, char *); extern long nr_blockdev_pages(void);