From patchwork Wed May 24 21:42:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 9747097 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 8FDA560388 for ; Wed, 24 May 2017 21:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 829FF26E16 for ; Wed, 24 May 2017 21:46:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76A7226E55; Wed, 24 May 2017 21:46:56 +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 133F926E1A for ; Wed, 24 May 2017 21:46:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1035949AbdEXVoz (ORCPT ); Wed, 24 May 2017 17:44:55 -0400 Received: from ale.deltatee.com ([207.54.116.67]:36998 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033717AbdEXVnV (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 1dDe3j-0007Gs-6r; Wed, 24 May 2017 15:43:15 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.84_2) (envelope-from ) id 1dDe3f-0004mZ-1b; 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:22 -0600 Message-Id: <1495662147-18277-12-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 11/16] bvec: convert to using pfn_t internally 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 With bv_page fenced off, we can now convert it to a pfn_t fairly simply. Everything should work the same with the exception of a BUG_ON for potentially unmappable pfns. A couple of initializers that assign {NULL} to a bio_vec had to also be changed to {} to prevent a warning seeing pfn_t is actually a struct. Signed-off-by: Logan Gunthorpe Signed-off-by: Stephen Bates --- block/blk-integrity.c | 4 ++-- block/blk-merge.c | 6 +++--- include/linux/bvec.h | 13 +++++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 857138a..2ba66f7 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -40,7 +40,7 @@ */ int blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio) { - struct bio_vec iv, ivprv = { NULL }; + struct bio_vec iv, ivprv = {}; unsigned int segments = 0; unsigned int seg_size = 0; struct bvec_iter iter; @@ -86,7 +86,7 @@ EXPORT_SYMBOL(blk_rq_count_integrity_sg); int blk_rq_map_integrity_sg(struct request_queue *q, struct bio *bio, struct scatterlist *sglist) { - struct bio_vec iv, ivprv = { NULL }; + struct bio_vec iv, ivprv = {}; struct scatterlist *sg = NULL; unsigned int segments = 0; struct bvec_iter iter; diff --git a/block/blk-merge.c b/block/blk-merge.c index 65dcee9..93e87fe 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -245,7 +245,7 @@ static unsigned int __blk_recalc_rq_segments(struct request_queue *q, struct bio *bio, bool no_sg_merge) { - struct bio_vec bv, bvprv = { NULL }; + struct bio_vec bv, bvprv = {}; int cluster, prev = 0; unsigned int seg_size, nr_phys_segs; struct bio *fbio, *bbio; @@ -347,7 +347,7 @@ EXPORT_SYMBOL(blk_recount_segments); static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio, struct bio *nxt) { - struct bio_vec end_bv = { NULL }, nxt_bv; + struct bio_vec end_bv = {}, nxt_bv; if (!blk_queue_cluster(q)) return 0; @@ -430,7 +430,7 @@ static int __blk_bios_map_sg(struct request_queue *q, struct bio *bio, struct scatterlist *sglist, struct scatterlist **sg) { - struct bio_vec bvec, bvprv = { NULL }; + struct bio_vec bvec, bvprv = {}; struct bvec_iter iter; int cluster = blk_queue_cluster(q), nsegs = 0; diff --git a/include/linux/bvec.h b/include/linux/bvec.h index b53b879..d950288 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -22,12 +22,13 @@ #include #include +#include /* * was unsigned short, but we might as well be ready for > 64kB I/O pages */ struct bio_vec { - struct page *bv_page; + pfn_t bv_pfn; unsigned int bv_len; unsigned int bv_offset; }; @@ -45,12 +46,13 @@ struct bvec_iter { static inline struct page *bvec_page(const struct bio_vec *bvec) { - return bvec->bv_page; + BUG_ON(!pfn_t_is_always_mappable(bvec->bv_pfn)); + return pfn_t_to_page(bvec->bv_pfn); } static inline void bvec_set_page(struct bio_vec *bvec, struct page *page) { - bvec->bv_page = page; + bvec->bv_pfn = page_to_pfn_t(page); } /* @@ -59,6 +61,9 @@ static inline void bvec_set_page(struct bio_vec *bvec, struct page *page) */ #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) +#define bvec_iter_pfn_t(bvec, iter) \ + (__bvec_iter_bvec((bvec), (iter))->bv_pfn) + #define bvec_iter_page(bvec, iter) \ (bvec_page(__bvec_iter_bvec((bvec), (iter)))) @@ -71,7 +76,7 @@ static inline void bvec_set_page(struct bio_vec *bvec, struct page *page) #define bvec_iter_bvec(bvec, iter) \ ((struct bio_vec) { \ - .bv_page = bvec_iter_page((bvec), (iter)), \ + .bv_pfn = bvec_iter_pfn_t((bvec), (iter)), \ .bv_len = bvec_iter_len((bvec), (iter)), \ .bv_offset = bvec_iter_offset((bvec), (iter)), \ })