From patchwork Thu Jul 2 15:38: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: 11639369 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 90CDC739 for ; Thu, 2 Jul 2020 15:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 79B25212CC for ; Thu, 2 Jul 2020 15:42:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="lsdTsq2i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730214AbgGBPmd (ORCPT ); Thu, 2 Jul 2020 11:42:33 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:50288 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728754AbgGBPmO (ORCPT ); Thu, 2 Jul 2020 11:42:14 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200702154210epoutp0447a725c5c59666fb8b620c00402a5a41~d_dOIl8cR0370403704epoutp04T for ; Thu, 2 Jul 2020 15:42:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200702154210epoutp0447a725c5c59666fb8b620c00402a5a41~d_dOIl8cR0370403704epoutp04T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593704530; bh=K2+mo5xwtG55Pc3yxkOmmDHced+n9HmetT3RPTBR6qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lsdTsq2iD8fvVh5VNbFGBMQ/P2EE73NS4bOpy1C3SagWi47RvzS8ClZ0fBdJgX1Tf +yYA6etUGBCXh0Pcl55VfHPrv2ncP7/q+r0E0ElYPfnqI3WvR6cUaDW3vk0tKMRvPU I49W85ySCeyD9d6ZmHR1i/AlZHLd9hdku2jtTcto= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20200702154209epcas5p32cccb69e788b0aebef47dc18e38c6a86~d_dNpPej60760807608epcas5p33; Thu, 2 Jul 2020 15:42:09 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id AE.F4.09703.1500EFE5; Fri, 3 Jul 2020 00:42:09 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20200702154208epcas5p39fe202f642a9d5c8dde9b911645c594c~d_dNAacFJ0760807608epcas5p32; Thu, 2 Jul 2020 15:42:08 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200702154208epsmtrp267a36aa897c5d7f936c14f2572b63871~d_dM-igcg1523715237epsmtrp2H; Thu, 2 Jul 2020 15:42:08 +0000 (GMT) X-AuditID: b6c32a4a-4cbff700000025e7-7c-5efe00515716 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id A2.3A.08382.0500EFE5; Fri, 3 Jul 2020 00:42:08 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200702154206epsmtip10254bcf4288da0e1fe7b88f3d3197880~d_dLAKyfU2838528385epsmtip13; Thu, 2 Jul 2020 15:42:06 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de, Damien.LeMoal@wdc.com, Kanchan Joshi , Selvakumar S , Nitesh Shetty , Javier Gonzalez Subject: [PATCH 1/2] block: fix error code for zone-append Date: Thu, 2 Jul 2020 21:08:49 +0530 Message-Id: <1593704330-11540-2-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593704330-11540-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCIsWRmVeSWpSXmKPExsWy7bCmhm4gw784gz8XpCx+T5/CarH6bj+b RWv7NyaLlauPMlk8vvOZ3eLo/7dsFpMOXWO02HtL2+LyrjlsFtt+z2e2uDJlEbPF6x8n2Rx4 PC6fLfXYtKqTzWP3zQY2j74tqxg9Pm+S82g/0M0UwBbFZZOSmpNZllqkb5fAlXHr8AOmgjls FSeW/GNvYOxn7WLk5JAQMJG439rD1sXIxSEksJtR4tiKd1DOJ0aJJVfmM0E43xglVrYfZuli 5ABrWfRPHSK+F6ho0VNWCOczo8TG20sZQYrYBDQlLkwuBVkhIqAmsXfRJ7CpzAJtTBKzVlxn B0kIC1hJnH23lwXEZhFQlTi65TkjiM0r4Cxx98gEZoj75CRunusEszkFXCS+zm1kARkkIfCV XWLq9e0sEEUuEr1rVjFB2MISr45vYYewpSQ+v9vLBmEXS/y6c5QZormDUeJ6w0yoZnuJi3v+ MoFczQx09fpd+iBhZgE+id7fT5ggPuaV6GgTgqhWlLg36Sk07MQlHs5YAmV7SHx6+AhslZDA dEaJg4s4JzDKzkIYuoCRcRWjZGpBcW56arFpgVFearlecWJucWleul5yfu4mRnDC0PLawfjw wQe9Q4xMHIyHGCU4mJVEeE8b/IoT4k1JrKxKLcqPLyrNSS0+xCjNwaIkzqv040yckEB6Yklq dmpqQWoRTJaJg1Oqgam9yFPGZJlsfcRh7v8ru5W/753K89LQXTjOpDH98r1ZFYeXqW2VYU88 dcXVZi7rb9+vfY5nHhlFfp94oXvCqRmy8mdf2aVKJQlZLdn0Uu+HnlHunw+bjjX/unB/l99s eeONGxxeWSbq5juVeOpr/94i3uTgz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TjtMlfhi5dj3N4feZ3h0nAt3PejcvxnA8GZnrqbP+zfZ3/5 1r2bX39LsCzOmn3ImvF85ffXcb5Miqten3APvfq148yhTdXyKopzreTS2ZkmKbEUZyQaajEX FScCADYgtYPFAgAA X-CMS-MailID: 20200702154208epcas5p39fe202f642a9d5c8dde9b911645c594c X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200702154208epcas5p39fe202f642a9d5c8dde9b911645c594c References: <1593704330-11540-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 avoid returning success when it should report failure, preventing odd behavior in caller. Signed-off-by: Kanchan Joshi Signed-off-by: Selvakumar S Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez Reviewed-by: Damien Le Moal --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index a7366c0..0cecdbc 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1044,7 +1044,7 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter) size_t offset; if (WARN_ON_ONCE(!max_append_sectors)) - return 0; + return -EINVAL; /* * Move page array up in the allocated memory for the bio vecs as far as From patchwork Thu Jul 2 15:38:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11639367 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 91B3A739 for ; Thu, 2 Jul 2020 15:42:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 72E3F212CC for ; Thu, 2 Jul 2020 15:42:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="izOV2O0L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730129AbgGBPmT (ORCPT ); Thu, 2 Jul 2020 11:42:19 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:58489 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730075AbgGBPmS (ORCPT ); Thu, 2 Jul 2020 11:42:18 -0400 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200702154214epoutp030867fdb9779eceafafc6eff5093bd89c~d_dSO75pg1997319973epoutp03J for ; Thu, 2 Jul 2020 15:42:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200702154214epoutp030867fdb9779eceafafc6eff5093bd89c~d_dSO75pg1997319973epoutp03J DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593704534; bh=w3gBvUllQl4Xfn65TlaPAu9PKFeAfpv83AwoDs7hlJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=izOV2O0L4wILjoFYQI+d0xXkCPjLIbAcB3a2i5giVdNsMRQ2+tn3IU9y5QYyGiZSY s/dRUyerU0sw9gaV3phv6DfEVFaMEqhlZpm2k7rzdVYbGnTcW0Hztj1Q578KyBcNV+ dzIJ2sFMv6wIxA/oCXQV1/4Wjs8Q0kplG9g3QBNM= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200702154213epcas5p1f4178438e4510c09856fef9c2f0de250~d_dRcZZsu0362503625epcas5p1_; Thu, 2 Jul 2020 15:42:13 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id FB.93.09475.5500EFE5; Fri, 3 Jul 2020 00:42:13 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20200702154213epcas5p4e8d42861cb5ae91ddeccf1ed73107304~d_dQ5Eh3q0916109161epcas5p4B; Thu, 2 Jul 2020 15:42:13 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200702154213epsmtrp2f4499e948140739dda8d46395b2bdbfe~d_dQ4QIwZ1523715237epsmtrp2L; Thu, 2 Jul 2020 15:42:13 +0000 (GMT) X-AuditID: b6c32a4b-39fff70000002503-1d-5efe0055dc8e Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id D4.3D.08303.4500EFE5; Fri, 3 Jul 2020 00:42:12 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200702154210epsmtip1efde914ac48c288c309f028a5df2305c~d_dO15mG-3197931979epsmtip1I; Thu, 2 Jul 2020 15:42:10 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, kbusch@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de, Damien.LeMoal@wdc.com, Kanchan Joshi , Selvakumar S , Nitesh Shetty , Javier Gonzalez Subject: [PATCH 2/2] block: enable zone-append for iov_iter of bvec type Date: Thu, 2 Jul 2020 21:08:50 +0530 Message-Id: <1593704330-11540-3-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593704330-11540-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRmVeSWpSXmKPExsWy7bCmlm4ow784g09HFSx+T5/CarH6bj+b RWv7NyaLlauPMlk8vvOZ3eLo/7dsFpMOXWO02HtL2+LyrjlsFtt+z2e2uDJlEbPF6x8n2Rx4 PC6fLfXYtKqTzWP3zQY2j74tqxg9Pm+S82g/0M0UwBbFZZOS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DJlEbPF6x8n2Rx4 PC6fLfXYtKqTzWP3zQY2j74tqxg9Pm+S82g/0M0UwBbFZZOSmpNZllqkb5fAlXH47D6WghUC FX2PZrE1MO7k7WLk5JAQMJHY9GYKE4gtJLCDUeLvFi2IuLhE87Uf7BC2sMTKf8+BbC6gmo+M EtPW3GHrYuTgYBPQlLgwuRSkRkRAQ2LF52VMIDXMAn1MEkvezQBrFhbwkDi65wfYAhYBVYmz b96zgdi8As4S/1c+ZIFYICdx81wnM4jNKeAi8XVuIwvEQc4S29+0sE9g5FvAyLCKUTK1oDg3 PbfYsMAoL7Vcrzgxt7g0L10vOT93EyM4WLW0djDuWfVB7xAjEwfjIUYJDmYlEd7TBr/ihHhT EiurUovy44tKc1KLDzFKc7AoifN+nbUwTkggPbEkNTs1tSC1CCbLxMEp1cBkKXc398SuzJeN MhWHfBYZC6xXLjK4Y/nfKdTJtdrhgJPD391anq/fTMpfN8dwp/efOUde5rTJGlp6RVetqi15 t+ismDd3d/LGvwIhismcp+PK3/cVWah56Pp+cFpRE3ukte7gn0PaFopPTyrErWb/nNQax/lP Wpf5zd+KxXlWb1Pr0ja37vGfyN5VIhtwQHGdNotVINflvJD/XXLXbzAI1E9cFLJ6/4qQ31vU WqKtm3dq2XQyzw4wu5sb9bNBJtHS/19Z6xJVqdv9Bc/fCXOnVfcXBKdeP5Cr6jV9uQnn1CWe ZzZ/OPzl3oGjLh7NnDZfSgIWnzEvi9zT97D2w/JXwimSQrMbeVa/1tzgpsRSnJFoqMVcVJwI AIiLEaLFAgAA X-CMS-MailID: 20200702154213epcas5p4e8d42861cb5ae91ddeccf1ed73107304 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200702154213epcas5p4e8d42861cb5ae91ddeccf1ed73107304 References: <1593704330-11540-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. 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);