From patchwork Sun Jul 5 18:47:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11644581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 89DAB6C1 for ; Sun, 5 Jul 2020 18:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D9DF20899 for ; Sun, 5 Jul 2020 18:52:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="o71jpY2Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728172AbgGESwb (ORCPT ); Sun, 5 Jul 2020 14:52:31 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:31874 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728133AbgGESw1 (ORCPT ); Sun, 5 Jul 2020 14:52:27 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200705185222epoutp0206781dd720db1b28de91b3a81f4078e1~e7-J47NFj3075530755epoutp02G for ; Sun, 5 Jul 2020 18:52:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200705185222epoutp0206781dd720db1b28de91b3a81f4078e1~e7-J47NFj3075530755epoutp02G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593975142; bh=+K/IUmUogGLkZXpodowxoJ/FLK3QQNBHyElRvdThP3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o71jpY2ZOxyciu+t4fgwqMBtNL8KFU0JrmgqKR2CYv0LWY9G6fYJIqyhXsddRR78E 1eMzZfMACk1XA8JV3T5Oe3TllxQ159IqKxT0NEnI2JvD2RZWKAarWEcbm8zGXMyxvB P4DH6IHquYxmrGAZ1CsMxYWvPaK3rhLx/RM+EFMI= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20200705185222epcas5p2655d7f75c9997d925e61cb0a57c09c0d~e7-JbJsS92058620586epcas5p2g; Sun, 5 Jul 2020 18:52:22 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 84.C7.09703.661220F5; Mon, 6 Jul 2020 03:52:22 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20200705185221epcas5p28b6d060df829b751109265222285da0e~e7-IRsvrN2058620586epcas5p2f; Sun, 5 Jul 2020 18:52:21 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200705185221epsmtrp147a3216c334bbd4f68ec760f75006703~e7-IQ2VDE0303903039epsmtrp17; Sun, 5 Jul 2020 18:52:21 +0000 (GMT) X-AuditID: b6c32a4a-4b5ff700000025e7-4c-5f022166c93c Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 85.04.08382.461220F5; Mon, 6 Jul 2020 03:52:20 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200705185218epsmtip2e411299166826203d3627aeeceb51079~e7-F3kW7_3204832048epsmtip2u; Sun, 5 Jul 2020 18:52:18 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, mb@lightnvm.io, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, Kanchan Joshi , Selvakumar S , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v3 3/4] block: enable zone-append for iov_iter of bvec type Date: Mon, 6 Jul 2020 00:17:49 +0530 Message-Id: <1593974870-18919-4-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593974870-18919-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAKsWRmVeSWpSXmKPExsWy7bCmhm6aIlO8wbHpPBa/p09htZizahuj xeq7/WwWXf+2sFi0tn9jsjg9YRGTxbvWcywWj+98Zrc4+v8tm8WUaU2MFntvaVvs2XuSxeLy rjlsFiu2H2Gx2PZ7PrPFlSmLmC1e/zjJZnH+73FWByGPnbPusntsXqHlcflsqcemT5PYPbqv /mD06NuyitHj8yY5j/YD3Uwem568ZQrgjOKySUnNySxLLdK3S+DK+HB2KXPBC4GKRTd/sDUw vuftYuTkkBAwkeh5f4Wli5GLQ0hgN6NE14MeZgjnE6PE990vGSGcb4wS11b8ZYVpebCphw0i sZdR4vCOh1DOZ0aJS83NQFUcHGwCmhIXJpeCmCICNhI7l6iAlDALtDNLXDt5CWyQsIC3xPXl TYwgNouAqsSjmdfBbF4BZ4n5m38wQyyTk7h5rhPM5hRwkWjbfRrsPAmBLRwS1yf3sEMUuUhc ODUT6jphiVfHt0DFpSRe9rdB2cUSv+4chWruYJS43jCTBSJhL3Fxz18mkEuZgY5ev0sfJMws wCfR+/sJWFhCgFeio00IolpR4t6kp1CrxCUezlgCZXtIdLw9DLZKSGA6o8S9izYTGGVnIQxd wMi4ilEytaA4Nz212LTAKC+1XK84Mbe4NC9dLzk/dxMjOBFpee1gfPjgg94hRiYOxkOMEhzM SiK8vdqM8UK8KYmVValF+fFFpTmpxYcYpTlYlMR5lX6ciRMSSE8sSc1OTS1ILYLJMnFwSjUw mS3oz3sXoDTv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7ziN8frEiQcCUiYJNkWuWvE01TY7QXz5 37kWujLsm9vSmd4GBy9yDK+aMq/17faqJbv/Kgf8vO5efi1mQ7PslnzNoqx50V6i32xPTdD0 qaq7sujT3yc/E3NXM+a9fWn371WepNTaRUWZ/cc7c1id7Ly4P2d9WLdKxSH5nf6v5fPmuvz5 X/tPO78t+6zksTO7vgo17EkuajNs/BfyhvXlKV2dKoWNyxbt/v1LPqfKkWU757P37BVyBs1N t0R8ZFxP6bvt+i5zXjx8be0pezlDQebowxszz9bviWuZMluJpTgj0VCLuag4EQCG1RVp8AIA AA== X-CMS-MailID: 20200705185221epcas5p28b6d060df829b751109265222285da0e X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200705185221epcas5p28b6d060df829b751109265222285da0e References: <1593974870-18919-1-git-send-email-joshi.k@samsung.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org zone-append with bvec iov_iter gives WARN_ON, and returns -EINVAL. Add new helper to process such iov_iter and add pages in bio honoring zone-append specific constraints. This is used to enable zone-append with io-uring fixed-buffer. Signed-off-by: Kanchan Joshi Signed-off-by: Selvakumar S Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- block/bio.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/block/bio.c b/block/bio.c index 0cecdbc..ade9da7 100644 --- a/block/bio.c +++ b/block/bio.c @@ -975,6 +975,30 @@ static int __bio_iov_bvec_add_pages(struct bio *bio, struct iov_iter *iter) iov_iter_advance(iter, size); return 0; } +static int __bio_iov_bvec_append_add_pages(struct bio *bio, struct iov_iter *iter) +{ + const struct bio_vec *bv = iter->bvec; + unsigned int len; + size_t size; + struct request_queue *q = bio->bi_disk->queue; + unsigned int max_append_sectors = queue_max_zone_append_sectors(q); + bool same_page = false; + + if (WARN_ON_ONCE(!max_append_sectors)) + return -EINVAL; + + if (WARN_ON_ONCE(iter->iov_offset > bv->bv_len)) + return -EINVAL; + + len = min_t(size_t, bv->bv_len - iter->iov_offset, iter->count); + size = bio_add_hw_page(q, bio, bv->bv_page, len, + bv->bv_offset + iter->iov_offset, + max_append_sectors, &same_page); + if (unlikely(size != len)) + return -EINVAL; + iov_iter_advance(iter, size); + return 0; +} #define PAGE_PTRS_PER_BVEC (sizeof(struct bio_vec) / sizeof(struct page *)) @@ -1105,9 +1129,10 @@ int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter) do { if (bio_op(bio) == REQ_OP_ZONE_APPEND) { - if (WARN_ON_ONCE(is_bvec)) - return -EINVAL; - ret = __bio_iov_append_get_pages(bio, iter); + if (is_bvec) + ret = __bio_iov_bvec_append_add_pages(bio, iter); + else + ret = __bio_iov_append_get_pages(bio, iter); } else { if (is_bvec) ret = __bio_iov_bvec_add_pages(bio, iter);