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: 69504 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1946728qgf; Tue, 7 Jun 2016 05:18:29 -0700 (PDT) X-Received: by 10.98.62.218 with SMTP id y87mr22028077pfj.38.1465301909569; Tue, 07 Jun 2016 05:18:29 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i124si34803109pfg.4.2016.06.07.05.18.23; Tue, 07 Jun 2016 05:18:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161022AbcFGMSM (ORCPT + 31 others); Tue, 7 Jun 2016 08:18:12 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:35120 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932382AbcFGMSI (ORCPT ); Tue, 7 Jun 2016 08:18:08 -0400 Received: by mail-pa0-f53.google.com with SMTP id xk1so45667909pac.2 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=ZncBDJ7ashx2eWCiW5w7pVhWeeWrXsDk+bs3wbHrpK+ozif7X5Tn8/gMlRJee5jcdk e7vajpcotf+gT8A/7GGxC51el601ozn0oA2D1+Nu2jrG0Hbu7K3oORqCv3cYsfitCKfk 5vdlS/j/71r8fFjVK+jJe6O9juyOch5HeJ0Iz9rji2t6mmNPTnWgdaYZ6FOyXJ5LZm/O l7pJkl2h3FvzKQ4kzLyU4Zcbpw0WobLV/T0+1YJKTwLvL3P1snQe2MPHupXynZd/ktZ5 cxhYfdwvpBmgUXGhtGDJq5SGu4CL2B3T+Hy/e+Gcj/yPMkpw+s/FHdwP1yd/umOMtIdP CK2w== X-Gm-Message-State: ALyK8tKkE5v6bBoBHy2vB+VGYvkJNwbNY5EupfW3PUt0GZ/7CSWSKF1b4qBMqkvNogBXejeR 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 1.7.9.5 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);