From patchwork Tue Jun 25 02:46:23 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: 11014461 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 8CEF81575 for ; Tue, 25 Jun 2019 02:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C2528AB1 for ; Tue, 25 Jun 2019 02:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 681BE28B6E; Tue, 25 Jun 2019 02:46:32 +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=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 C128D28AB1 for ; Tue, 25 Jun 2019 02:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730592AbfFYCqb (ORCPT ); Mon, 24 Jun 2019 22:46:31 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:51033 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730587AbfFYCq3 (ORCPT ); Mon, 24 Jun 2019 22:46:29 -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=1561430789; x=1592966789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GKv1oj6zY/ZraVIoPcbsLc1hDCrrNULySwbCBOwMDQo=; b=miWAThwjLCuiPsURfbARDqIfB603tHFMr1MTTTvbu09Pk1mEjoTb9e2K GPxZxZ5xyy4IdkvlxOcoT1SCYBe5QllU2+rbiTfEc/PrDCf8GXOj1u4Qz 4YDzBLXs1KMf0OW+8jsbC7XfgW4fgpZmzpjRJIzk3rStS273BVb/btss1 UgYRrYjzBgVcB9ndyqtdQidcgGmjIHpq8MTJEhePU3SJaULp1rVre6hYe VmDIumBZh3/DVQ1uqr8yQy1nw+2xT/SHiycJe3p+rOo5YUe12UZqgBb5V 8NX1GMlphTjNwlj6hzCPTZ7zTHMoyhqe6GKiq4ADbt2iF+aCQhjjvMBRk A==; X-IronPort-AV: E=Sophos;i="5.63,413,1557158400"; d="scan'208";a="112654038" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 25 Jun 2019 10:46:29 +0800 IronPort-SDR: FceNXFyC7htLRgz+MdnIoI1ybTh9LoyY8taTfQM8Q2cjornt9Sw8zIOICNmtKhrA+dbXX+EEN1 /kcLRxV2gxZWA8lvXaCSo6NCyvUU6ccRUhiUpgAgJpGx8BROJZYh81S06PQPNWfn0FgG6R5jJb 3XwbNbVciR3M3ZgjxEeRG5Hr1qCrzJdk/AorawV/cEZwqJpOGLo3D260BihggQC0SdxBIRDzom GidzSk6dgpjdLa2f+iA2M/ykhbn3Iy0cuaFXlFwMYLQQMiqpKz1ha0Ae5CaSRKxHL+8ZL60DiH v6sQa9YjVvX9LP4IbnO9bEdj Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 24 Jun 2019 19:45:46 -0700 IronPort-SDR: b2CxkUa2nyEevIeLM6jKLSJsF8Qrt4EKMo0hNdxM6RJ9Ig1M9Bl+2LV8o/d79yIIFvWKUnO0HE IhoLB6bvJCS+KQNfVuLXFooboJxk+hP1hjYEglHDoV4LfEltM9YsAgo4u8nrs+fOWpVjr9b3UC lhzdjUuA8xCHk+0Zq3Hj+cYO8GzRNaxMjxQd8BORcyHtl50I8+rdCSIuNTknYtxk5TXEOay9bC 3i1yd7NCd7DvCSsaBFQ+INU2DtPXaP3SUWG7dpVASeqkI278RV+EkikLQtD1EcrfERxOQU1Dwm ivI= Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 24 Jun 2019 19:46:27 -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 1/3] block: Allow mapping of vmalloc-ed buffers Date: Tue, 25 Jun 2019 11:46:23 +0900 Message-Id: <20190625024625.23976-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190625024625.23976-1-damien.lemoal@wdc.com> References: <20190625024625.23976-1-damien.lemoal@wdc.com> MIME-Version: 1.0 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 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: Chaitanya Kulkarni 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);