From patchwork Wed Jun 26 06:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11017031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE5711398 for ; Wed, 26 Jun 2019 06:54:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAE9F28607 for ; Wed, 26 Jun 2019 06:54:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEFE2286A8; Wed, 26 Jun 2019 06:54:43 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 2838E28607 for ; Wed, 26 Jun 2019 06:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbfFZGym (ORCPT ); Wed, 26 Jun 2019 02:54:42 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:6026 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfFZGym (ORCPT ); Wed, 26 Jun 2019 02:54:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561532082; x=1593068082; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Xd9/oVcSDaCiRyP6ZSQav/uWxyPwJP1u1o/XVGvEjuE=; b=N5GdcqSjcARB50Wr6O4NdifLdKhChQ429X6gYAuDqTkLapE666j2MerK elE1Vmz2yzuJ4T0kS/SUG9f8Ti46rxKnvXXm1iUQwJekO923ItLexpVGg iSsyTHn3F1aQVMWPy5TBhVyTR67qajnmxsg6o1nfp0Np7l4OE9e7oWBRA lVTtETARLJJ48qUDcbZvBhLB+9liWIunFTnXWu63OyQLdnyMousTOmZuP WmzLBv+V3gHzLm8LrScoMLNzbCd9bvzN9oSxYXjQ/X/IX9rqmP56+JsT6 vdBfgfadW5xyyb/m1TTT9WzeCR3uO6qWu5E0zkOZko03ePUktfUXQog+9 w==; X-IronPort-AV: E=Sophos;i="5.63,418,1557158400"; d="scan'208";a="113191697" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 26 Jun 2019 14:54:41 +0800 IronPort-SDR: hn6+WOC5hjv1X9OIbrN8lRZ/3Jn51W1MjOBK764Kq1REBTrRqepo8cy3PEbChCwkRWF5M5UNr8 AC+pssxYzTVuWYlXys+8ATkmKwTMlK9m5pRKKl7el6wgVAtDljEip29HZ+mBWDVfDbuxXwm93l ePxgZBiPq+zi7wsnfUbaPlZbtvYnob82ALYv6ZHGsF4jr12cBTdT8um+heEdHvqrt3LJwLVOeR 3od4uHBvRHNFpSxkZeVokuxajxMtOkl1IONhRBdOQX4LtrAn5Y2PViQl3SILwS091OTVl+8LTY b7PTIWlySmi+67/hysSoYZM/ Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP; 25 Jun 2019 23:53:57 -0700 IronPort-SDR: JPum1+LkLPWvK7CKjhfcSpwN4F4482rU1BehgFVXoBjg93bCr7BFVYcKoJHY+6y1qKizECvAjW AedHaQIxy2l1rxWPTFHEYC/CUtB5ACZuzwYz5EIcnJ2lzuo6fCRYuyIgrTz2nqhYngKthZPM6m ewsLL8bYuhoZC/oz3CLukeV7WyKaOMkRXhAqDEyTjFUBKzgJ5byEMxV5FN5zP97zYvvT/fvBfP +uL4q9hUOTzA2bggcEONBytAds+QRNjcZPQP+AORHSwtEJwk4DMC4CFobYpNd4iN6xQH0h1q67 +vw= Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Jun 2019 23:54:40 -0700 From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" , linux-block@vger.kernel.org, Jens Axboe Cc: Christoph Hellwig , Bart Van Assche Subject: [PATCH V3 1/3] block: Allow mapping of vmalloc-ed buffers Date: Wed, 26 Jun 2019 15:54:36 +0900 Message-Id: <20190626065438.19307-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190626065438.19307-1-damien.lemoal@wdc.com> References: <20190626065438.19307-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To allow the SCSI subsystem scsi_execute_req() function to issue requests using large buffers that are better allocated with vmalloc() rather than kmalloc(), modify bio_map_kern() to allow passing a buffer allocated with the vmalloc() function. To do so, simply test the buffer address using is_vmalloc_addr() and use vmalloc_to_page() instead of virt_to_page() to obtain the pages of vmalloc-ed buffers. Fixes: 515ce6061312 ("scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation") Fixes: e76239a3748c ("block: add a report_zones method") Cc: stable@vger.kernel.org Signed-off-by: Damien Le Moal Reviewed-by: Bart Van Assche --- block/bio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index ce797d73bb43..05afcaf655f3 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1501,6 +1501,8 @@ struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT; unsigned long start = kaddr >> PAGE_SHIFT; const int nr_pages = end - start; + bool is_vmalloc = is_vmalloc_addr(data); + struct page *page; int offset, i; struct bio *bio; @@ -1518,7 +1520,11 @@ struct bio *bio_map_kern(struct request_queue *q, void *data, unsigned int len, if (bytes > len) bytes = len; - if (bio_add_pc_page(q, bio, virt_to_page(data), bytes, + if (is_vmalloc) + page = vmalloc_to_page(data); + else + page = virt_to_page(data); + if (bio_add_pc_page(q, bio, page, bytes, offset) < bytes) { /* we don't support partial mappings */ bio_put(bio);