From patchwork Wed May 24 21:42:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 9747063 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 DDD18601C2 for ; Wed, 24 May 2017 21:44:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF5A626E1A for ; Wed, 24 May 2017 21:44:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C444626E4F; Wed, 24 May 2017 21:44:47 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 6854B26E1A for ; Wed, 24 May 2017 21:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035961AbdEXVom (ORCPT ); Wed, 24 May 2017 17:44:42 -0400 Received: from ale.deltatee.com ([207.54.116.67]:37002 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1035951AbdEXVnV (ORCPT ); Wed, 24 May 2017 17:43:21 -0400 Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1dDe3m-0007Gu-77; Wed, 24 May 2017 15:43:16 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.84_2) (envelope-from ) id 1dDe3f-0004mj-9A; Wed, 24 May 2017 15:43:07 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvdimm@lists.01.org, linux-nvme@lists.infradead.org, linux-rdma@vger.kernel.org Cc: Christoph Hellwig , Jason Gunthorpe , Jens Axboe , Dan Williams , Ross Zwisler , Matthew Wilcox , Andrew Morton , Ming Lei , Johannes Berg , Stephen Bates , Sagi Grimberg , Keith Busch , =?UTF-8?q?Christian=20K=C3=B6nig?= , Benjamin Herrenschmidt , Jerome Glisse , Logan Gunthorpe Date: Wed, 24 May 2017 15:42:24 -0600 Message-Id: <1495662147-18277-14-git-send-email-logang@deltatee.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1495662147-18277-1-git-send-email-logang@deltatee.com> References: <1495662147-18277-1-git-send-email-logang@deltatee.com> X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvdimm@lists.01.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-rdma@vger.kernel.org, hch@lst.de, jgunthorpe@obsidianresearch.com, axboe@kernel.dk, ross.zwisler@linux.intel.com, mawilcox@microsoft.com, akpm@linux-foundation.org, ming.lei@canonical.com, sbates@raithlin.com, sagi@grimberg.me, dan.j.williams@intel.com, johannes.berg@intel.com, keith.busch@intel.com, christian.koenig@amd.com, benh@kernel.crashing.org, jglisse@redhat.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [RFC PATCH 13/16] block: bio: introduce bio_add_pfn X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.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 We introduce bio_add_pfn which is the same as bio_add_page but expects a pfn_t instead of a page pointer. bio_add_page is then converted to be an inline call to bio_add_pfn. Signed-off-by: Logan Gunthorpe Signed-off-by: Stephen Bates --- block/bio.c | 16 ++++++++-------- include/linux/bio.h | 19 ++++++++++++++++++- include/linux/pfn_t.h | 5 +++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/block/bio.c b/block/bio.c index e785f50..d8b6aeb 100644 --- a/block/bio.c +++ b/block/bio.c @@ -810,17 +810,17 @@ int bio_add_pc_page(struct request_queue *q, struct bio *bio, struct page EXPORT_SYMBOL(bio_add_pc_page); /** - * bio_add_page - attempt to add page to bio + * bio_add_pfn - attempt to add pfn to bio * @bio: destination bio - * @page: page to add + * @pfn: pfn to add * @len: vec entry length * @offset: vec entry offset * - * Attempt to add a page to the bio_vec maplist. This will only fail + * Attempt to add a pfn to the bio_vec maplist. This will only fail * if either bio->bi_vcnt == bio->bi_max_vecs or it's a cloned bio. */ -int bio_add_page(struct bio *bio, struct page *page, - unsigned int len, unsigned int offset) +int bio_add_pfn(struct bio *bio, pfn_t pfn, unsigned int len, + unsigned int offset) { struct bio_vec *bv; @@ -838,7 +838,7 @@ int bio_add_page(struct bio *bio, struct page *page, if (bio->bi_vcnt > 0) { bv = &bio->bi_io_vec[bio->bi_vcnt - 1]; - if (page == bvec_page(bv) && + if (pfn_t_equal(pfn, bv->bv_pfn) && offset == bv->bv_offset + bv->bv_len) { bv->bv_len += len; goto done; @@ -849,7 +849,7 @@ int bio_add_page(struct bio *bio, struct page *page, return 0; bv = &bio->bi_io_vec[bio->bi_vcnt]; - bvec_set_page(bv, page); + bv->bv_pfn = pfn; bv->bv_len = len; bv->bv_offset = offset; @@ -858,7 +858,7 @@ int bio_add_page(struct bio *bio, struct page *page, bio->bi_iter.bi_size += len; return len; } -EXPORT_SYMBOL(bio_add_page); +EXPORT_SYMBOL(bio_add_pfn); /** * bio_iov_iter_get_pages - pin user or kernel pages and add them to a bio diff --git a/include/linux/bio.h b/include/linux/bio.h index 16c0b02..bc5f5d3 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -429,7 +429,24 @@ extern void bio_init(struct bio *bio, struct bio_vec *table, extern void bio_reset(struct bio *); void bio_chain(struct bio *, struct bio *); -extern int bio_add_page(struct bio *, struct page *, unsigned int,unsigned int); +extern int bio_add_pfn(struct bio *bio, pfn_t, unsigned int, unsigned int); + +/** + * bio_add_page - attempt to add page to bio + * @bio: destination bio + * @page: page to add + * @len: vec entry length + * @offset: vec entry offset + * + * Attempt to add a pfn to the bio_vec maplist. This will only fail + * if either bio->bi_vcnt == bio->bi_max_vecs or it's a cloned bio. + */ +static inline int bio_add_page(struct bio *bio, struct page *page, + unsigned int len, unsigned int offset) +{ + return bio_add_pfn(bio, page_to_pfn_t(page), len, offset); +} + extern int bio_add_pc_page(struct request_queue *, struct bio *, struct page *, unsigned int, unsigned int); int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter); diff --git a/include/linux/pfn_t.h b/include/linux/pfn_t.h index 07bd5ba..9612c87 100644 --- a/include/linux/pfn_t.h +++ b/include/linux/pfn_t.h @@ -48,6 +48,11 @@ static inline pfn_t phys_to_pfn_t(phys_addr_t addr, u64 flags) return __pfn_to_pfn_t(addr >> PAGE_SHIFT, flags); } +static inline bool pfn_t_equal(pfn_t a, pfn_t b) +{ + return a.val == b.val; +} + static inline bool pfn_t_has_page(pfn_t pfn) { return (pfn.val & PFN_MAP) == PFN_MAP || (pfn.val & PFN_DEV) == 0;