From patchwork Wed Jun 17 17:23:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11610333 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 E84D3618 for ; Wed, 17 Jun 2020 17:27:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF813208B8 for ; Wed, 17 Jun 2020 17:27:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="WkMojGkf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726964AbgFQR1I (ORCPT ); Wed, 17 Jun 2020 13:27:08 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:57118 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbgFQR1H (ORCPT ); Wed, 17 Jun 2020 13:27:07 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200617172705epoutp01d2ac4a02ac6a886b53e92600e1ed76b3~ZZNjAcSRz1947919479epoutp01S for ; Wed, 17 Jun 2020 17:27:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200617172705epoutp01d2ac4a02ac6a886b53e92600e1ed76b3~ZZNjAcSRz1947919479epoutp01S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592414825; bh=GDO7X/pOKQXLyuzzWrlxMlTjJnzAq7Lh38N/EO1S+rY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WkMojGkfEhkLNJviZzM+SLn3gJ+x4bDy4Rwo/OVZgZvfye2rEgUb1kDVeSgRZUdZZ 0ofTsvjNup9bNtCyOzqtepBeGk4vLe5zwqB7ppLNgogbBw1VYtyEH/QS0mOgiQsytt 4Kclu0kbbeC6TAgvPzX5LOwy7caA6pXQcDayQ6L4= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20200617172703epcas5p3e9ff5dda503c94b4b04ca66af6b5463a~ZZNho3aBm1731717317epcas5p3u; Wed, 17 Jun 2020 17:27:03 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id BE.66.09475.7625AEE5; Thu, 18 Jun 2020 02:27:03 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20200617172702epcas5p4dbf4729d31d9a85ab1d261d04f238e61~ZZNgh9iRQ0132401324epcas5p4e; Wed, 17 Jun 2020 17:27:02 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200617172702epsmtrp120faf98315f32fc623eea2f8ff5d60b9~ZZNghDb6w1872618726epsmtrp1A; Wed, 17 Jun 2020 17:27:02 +0000 (GMT) X-AuditID: b6c32a4b-389ff70000002503-2d-5eea52672a81 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id BA.2C.08382.6625AEE5; Thu, 18 Jun 2020 02:27:02 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200617172700epsmtip14cd840243725f84066880e1b97cbd725~ZZNeh0t7E0930109301epsmtip1R; Wed, 17 Jun 2020 17:27:00 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, selvakuma.s1@samsung.com, nj.shetty@samsung.com, javier.gonz@samsung.com, Kanchan Joshi Subject: [PATCH 1/3] fs,block: Introduce IOCB_ZONE_APPEND and direct-io handling Date: Wed, 17 Jun 2020 22:53:37 +0530 Message-Id: <1592414619-5646-2-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592414619-5646-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7bCmlm560Ks4g1VNBhar7/azWXT928Ji 8a71HIvF4zuf2S2O/n/LZrFw4zImiynTmhgt9t7Sttiz9ySLxeVdc9gstv2ez2xxZcoiZovX P06yWZz/e5zVgc/j8tlSj02fJrF79G1ZxejxeZOcx6Ynb5kCWKO4bFJSczLLUov07RK4MvZ/ usNW8Fy4oufuC+YGxiaBLkYODgkBE4kDL6y7GLk4hAR2M0q8Xt7ECuF8YpTonLAAyvnGKHH7 wl32LkZOsI67h9cyQiT2MkpM2HiLCcL5zCjxcuceJpC5bAKaEhcml4KYIgI2EjuXqID0Mgs0 MEn8/64DYgsLBEk8WnKaGcRmEVCV+P/6HiOIzSvgJPHg6SIWiF1yEjfPdYLVcAo4S8zefAns IAmBRg6JrXtfM0IUuUi8fbiVFcIWlnh1fAvUoVISL/vboOxiiV93jjJDNHcwSlxvmAm1wV7i 4p6/YDczA928fpc+xKF8Er2/nzBBgohXoqNNCKJaUeLepKdQq8QlHs5YAmV7SCz8f5QJxBYS mMYo0f3UewKj7CyEoQsYGVcxSqYWFOempxabFhjnpZbrFSfmFpfmpesl5+duYgSnDS3vHYyP HnzQO8TIxMF4iFGCg1lJhNf594s4Id6UxMqq1KL8+KLSnNTiQ4zSHCxK4rxKP87ECQmkJ5ak ZqemFqQWwWSZODilGphiC3UW7UqavHaW4Zc71is4V16L1GNp9XjZkv/k7bv8F1XLmm65z/ny 9qjmjI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wJzl7s+bSvTkJ53en3x040fIiSNHi/YrnLybRnDg6z/HowhH0v1fBNXxB+Ses2RweR+aLfy 1iqDux/vdBd1p07XWNWk8k3k49JGb1ERv/eGdVP2N173ddKYve019z8R1i/37uswfy1eyO8+ P+HZl831mWuUt+3kfq2nYZNybsHvG01fpsfOC5554tecGSXRu3+H/k3awWWQV3T5zabZpdFK LMUZiYZazEXFiQD71pzvywIAAA== X-CMS-MailID: 20200617172702epcas5p4dbf4729d31d9a85ab1d261d04f238e61 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200617172702epcas5p4dbf4729d31d9a85ab1d261d04f238e61 References: <1592414619-5646-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 From: Selvakumar S Introduce IOCB_ZONE_APPEND flag, which is set in kiocb->ki_flags for zone-append. Direct I/O submission path uses this flag to send bio with append op. And completion path uses the same to return zone-relative offset to upper layer. Signed-off-by: SelvaKumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/block_dev.c | 19 ++++++++++++++++++- include/linux/fs.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 47860e5..4c84b4d0 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -185,6 +185,10 @@ static unsigned int dio_bio_write_op(struct kiocb *iocb) /* avoid the need for a I/O completion work item */ if (iocb->ki_flags & IOCB_DSYNC) op |= REQ_FUA; +#ifdef CONFIG_BLK_DEV_ZONED + if (iocb->ki_flags & IOCB_ZONE_APPEND) + op |= REQ_OP_ZONE_APPEND | REQ_NOMERGE; +#endif return op; } @@ -295,6 +299,14 @@ static int blkdev_iopoll(struct kiocb *kiocb, bool wait) return blk_poll(q, READ_ONCE(kiocb->ki_cookie), wait); } +#ifdef CONFIG_BLK_DEV_ZONED +static inline long blkdev_bio_end_io_append(struct bio *bio) +{ + return (bio->bi_iter.bi_sector % + blk_queue_zone_sectors(bio->bi_disk->queue)) << SECTOR_SHIFT; +} +#endif + static void blkdev_bio_end_io(struct bio *bio) { struct blkdev_dio *dio = bio->bi_private; @@ -307,15 +319,20 @@ static void blkdev_bio_end_io(struct bio *bio) if (!dio->is_sync) { struct kiocb *iocb = dio->iocb; ssize_t ret; + long res = 0; if (likely(!dio->bio.bi_status)) { ret = dio->size; iocb->ki_pos += ret; +#ifdef CONFIG_BLK_DEV_ZONED + if (iocb->ki_flags & IOCB_ZONE_APPEND) + res = blkdev_bio_end_io_append(bio); +#endif } else { ret = blk_status_to_errno(dio->bio.bi_status); } - dio->iocb->ki_complete(iocb, ret, 0); + dio->iocb->ki_complete(iocb, ret, res); if (dio->multi_bio) bio_put(&dio->bio); } else { diff --git a/include/linux/fs.h b/include/linux/fs.h index 6c4ab4d..dc547b9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -315,6 +315,7 @@ enum rw_hint { #define IOCB_SYNC (1 << 5) #define IOCB_WRITE (1 << 6) #define IOCB_NOWAIT (1 << 7) +#define IOCB_ZONE_APPEND (1 << 8) struct kiocb { struct file *ki_filp; From patchwork Wed Jun 17 17:23:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11610339 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 BD84060D for ; Wed, 17 Jun 2020 17:27:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A1C6B21655 for ; Wed, 17 Jun 2020 17:27:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="VIVRo5P+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726511AbgFQR1L (ORCPT ); Wed, 17 Jun 2020 13:27:11 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:57126 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbgFQR1K (ORCPT ); Wed, 17 Jun 2020 13:27:10 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200617172707epoutp01d1b3eb1a2691d5c74ddb73a08a5614d6~ZZNlcZwt02594825948epoutp01W for ; Wed, 17 Jun 2020 17:27:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200617172707epoutp01d1b3eb1a2691d5c74ddb73a08a5614d6~ZZNlcZwt02594825948epoutp01W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592414828; bh=LBOG9REbmAYlHxyR7jvFKAsWiegyIQK04zGZkOS/AuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VIVRo5P+85YJNvtuuFawNE3HwwsLkXdVdxOvwMCADalzbiDuM4IxSx+DDkZukEkoc AAt6jDlJL8y4vkF1yrCL1pIfvToZ1low1JB3j2MCnsGIcgIW/JGc1B4dHca7myxrYH 5MCS7vNX88+qulds/3tvF/FpZzo/qmzm+YuBX300= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20200617172707epcas5p22cf195448282ebdc2ef7834a5b393f9a~ZZNk6izzV1456214562epcas5p2u; Wed, 17 Jun 2020 17:27:07 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 67.B1.09703.B625AEE5; Thu, 18 Jun 2020 02:27:07 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20200617172706epcas5p4dcbc164063f58bad95b211b9d6dfbfa9~ZZNkWh_sk1866218662epcas5p4h; Wed, 17 Jun 2020 17:27:06 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200617172706epsmtrp21060c8d107a2d39f9ec9248ee4cf3b76~ZZNkVqCpa0603706037epsmtrp2T; Wed, 17 Jun 2020 17:27:06 +0000 (GMT) X-AuditID: b6c32a4a-4b5ff700000025e7-34-5eea526b99d7 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id AB.2C.08382.A625AEE5; Thu, 18 Jun 2020 02:27:06 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200617172704epsmtip1b3a347b0422349a9dbfab1eae38da006~ZZNiMuSIR0780107801epsmtip1G; Wed, 17 Jun 2020 17:27:04 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, selvakuma.s1@samsung.com, nj.shetty@samsung.com, javier.gonz@samsung.com, Kanchan Joshi , Arnav Dawn Subject: [PATCH 2/3] aio: add support for zone-append Date: Wed, 17 Jun 2020 22:53:38 +0530 Message-Id: <1592414619-5646-3-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592414619-5646-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRmVeSWpSXmKPExsWy7bCmpm520Ks4g717hS1+b3vEYrH6bj+b Rde/LSwW71rPsVg8vvOZ3eLo/7dsFgs3LmOymDKtidFi7y1tiz17T7JYXN41h81i2+/5zBZX pixitnj94ySbxfm/x1kd+D0uny312PRp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Z3eLo/7dsFgs3LmOymDKtidFi7y1tiz17T7JYXN41h81i2+/5zBZX pixitnj94ySbxfm/x1kd+D0uny312PRpErtH35ZVjB6fN8l5bHrylimANYrLJiU1J7MstUjf LoErY9O+CywFK/kqNvxfz9rA+JO7i5GTQ0LARGLT7Y/MXYxcHEICuxklLjSfZYVIiEs0X/vB DmELS6z895wdougjo0TvrMdADgcHm4CmxIXJpSA1IgIOEl3HHzOB1DALrGWSeDdlIyNIQljA VGLDsitgNouAqsTBl7eYQWxeASeJ751vGSEWyEncPNcJFucUcJaYvfkS2BFCQDV/Fs1incDI t4CRYRWjZGpBcW56brFhgWFearlecWJucWleul5yfu4mRnAIa2nuYNy+6oPeIUYmDsZDjBIc zEoivM6/X8QJ8aYkVlalFuXHF5XmpBYfYpTmYFES571RuDBOSCA9sSQ1OzW1ILUIJsvEwSnV wLT3uIqg5B7H8B97Jlpun8m15+epddz3M7qTnyr67dpV5Bp+5/7aL9ffaay4/p3j5n47nbgb OfNu7mX/vW3S0t5CNZmnNpPvpjfvrOJfffLoFO9c20cClxe8OvSwTnLyw8IWD3X1tD1mJUrz xFvmZx0OZ3ZwF5zZs2t10Pbttr3hWQXrbk7aFlLubLGwNH7hmrbKOb8tevZOyWjyrUo+KbR7 jffVHuNTM+41lvxNEY84aP4ySyLr2rqlXDesZPuFT978xn9ULq5n+uOne0LSYpa++yj5jbuJ /blFR/f1fb41nAsabnlE9a2RX3G2uEgu5amPd3LPpgOHTpfP8mU6NXe9y6JDqeUR82/ZZW98 bc6nxFKckWioxVxUnAgAqm13RdACAAA= X-CMS-MailID: 20200617172706epcas5p4dcbc164063f58bad95b211b9d6dfbfa9 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200617172706epcas5p4dcbc164063f58bad95b211b9d6dfbfa9 References: <1592414619-5646-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 Introduce IOCB_CMD_ZONE_APPEND opcode for zone-append. On append completion zone-relative offset is returned using io_event->res2. Signed-off-by: Kanchan Joshi Signed-off-by: Arnav Dawn Signed-off-by: SelvaKumar S Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/aio.c | 8 ++++++++ include/uapi/linux/aio_abi.h | 1 + 2 files changed, 9 insertions(+) diff --git a/fs/aio.c b/fs/aio.c index 7ecddc2..8b10a55d 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1579,6 +1579,10 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb, __sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true); __sb_writers_release(file_inode(file)->i_sb, SB_FREEZE_WRITE); } +#ifdef CONFIG_BLK_DEV_ZONED + if (iocb->aio_lio_opcode == IOCB_CMD_ZONE_APPEND) + req->ki_flags |= IOCB_ZONE_APPEND; +#endif req->ki_flags |= IOCB_WRITE; aio_rw_done(req, call_write_iter(file, req, &iter)); } @@ -1846,6 +1850,10 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, return aio_fsync(&req->fsync, iocb, true); case IOCB_CMD_POLL: return aio_poll(req, iocb); +#ifdef CONFIG_BLK_DEV_ZONED + case IOCB_CMD_ZONE_APPEND: + return aio_write(&req->rw, iocb, false, compat); +#endif default: pr_debug("invalid aio operation %d\n", iocb->aio_lio_opcode); return -EINVAL; diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h index 8387e0a..541d96a 100644 --- a/include/uapi/linux/aio_abi.h +++ b/include/uapi/linux/aio_abi.h @@ -43,6 +43,7 @@ enum { IOCB_CMD_NOOP = 6, IOCB_CMD_PREADV = 7, IOCB_CMD_PWRITEV = 8, + IOCB_CMD_ZONE_APPEND = 9, }; /* From patchwork Wed Jun 17 17:23:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11610343 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 709EA60D for ; Wed, 17 Jun 2020 17:27:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52D7B2158C for ; Wed, 17 Jun 2020 17:27:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="YtESYsZQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbgFQR1U (ORCPT ); Wed, 17 Jun 2020 13:27:20 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:41059 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726979AbgFQR1U (ORCPT ); Wed, 17 Jun 2020 13:27:20 -0400 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200617172716epoutp020a30dc73f3b0facc0e3251e27fa682a4~ZZNs7V67d2360023600epoutp02S for ; Wed, 17 Jun 2020 17:27:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200617172716epoutp020a30dc73f3b0facc0e3251e27fa682a4~ZZNs7V67d2360023600epoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1592414836; bh=63VBCGU/0ntQ7nedglOpC7zYZy8fqZsAEdxHsErn/AY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YtESYsZQx9eLZsDBLy/va2jnyvIj0AE+VPn5N2RK4XLB8VHQ+CoCLOdzTbjN/jSfq cEmPH4Yoei+sLscXDTOmupdH93PNfYvAVd7LpbalO7CFRm2S4nwx8ljItNBau0cT3c dOUTsGcBNl1Qyxp9OQhysG6f1A/bkFCe5juO1ezo= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200617172714epcas5p1fe972604ea8b24f8f56d96196e0b0eab~ZZNrgz2Ll1054310543epcas5p1B; Wed, 17 Jun 2020 17:27:14 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id CF.66.09475.2725AEE5; Thu, 18 Jun 2020 02:27:14 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20200617172713epcas5p352f2907a12bd4ee3c97be1c7d8e1569e~ZZNqw0bGY2692326923epcas5p3e; Wed, 17 Jun 2020 17:27:13 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200617172713epsmtrp21f71c5731452333edc77419e8f5a90c5~ZZNqv-Dj80603706037epsmtrp2W; Wed, 17 Jun 2020 17:27:13 +0000 (GMT) X-AuditID: b6c32a4b-39fff70000002503-3a-5eea52723055 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 54.7E.08303.1725AEE5; Thu, 18 Jun 2020 02:27:13 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200617172711epsmtip1f74a209597ea26fe133e1bc32c360cfa~ZZNotmn7c1160511605epsmtip1l; Wed, 17 Jun 2020 17:27:11 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, selvakuma.s1@samsung.com, nj.shetty@samsung.com, javier.gonz@samsung.com, Kanchan Joshi Subject: [PATCH 3/3] io_uring: add support for zone-append Date: Wed, 17 Jun 2020 22:53:39 +0530 Message-Id: <1592414619-5646-4-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592414619-5646-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOIsWRmVeSWpSXmKPExsWy7bCmlm5R0Ks4gzNPpSxW3+1ns+j6t4XF 4l3rORaLx3c+s1sc/f+WzWLhxmVMFlOmNTFa7L2lbbFn70kWi8u75rBZbPs9n9niypRFzBav f5xkszj/9zirA5/H5bOlHps+TWL36NuyitHj8yY5j01P3jIFsEZx2aSk5mSWpRbp2yVwZRzZ PpG9YK5pxdQ5F1kbGNdpdTFyckgImEgsXPmfuYuRi0NIYDejxJy/D6CcT4wSt3ceZoJwPjNK XJj7hr2LkQOs5VizOkR8F6PEru+9CEU3jk9kBCliE9CUuDC5FMQUEbCR2LlEBWQbs0ADk8T/ 7zogYWEBK4nOZTogYRYBVYnbN3czg9i8Ak4Se1fOZYY4Tk7i5rlOMJtTwFli9uZLrCCbJAT+ sku0Pe1lgShykbg+cRE7hC0s8er4FihbSuLzu71sEHaxxK87R5khmjsYJa43zIRqtpe4uOcv E8hBzEAnr9+lD3Enn0Tv7ydMEO/ySnS0CUFUK0rcm/SUFcIWl3g4YwmU7SFx9e1VdkgoTGOU WP/oHvsERtlZCFMXMDKuYpRMLSjOTU8tNi0wzkst1ytOzC0uzUvXS87P3cQIThta3jsYHz34 oHeIkYmD8RCjBAezkgiv8+8XcUK8KYmVValF+fFFpTmpxYcYpTlYlMR5lX6ciRMSSE8sSc1O TS1ILYLJMnFwSjUwOU78+4ljLs8SNpXaHWbT9ZpO7rhn0G22Yf9ag/SiGbcOsZgte6Cz6jrz EsWjl1486Lrr1JfpEif9W2CNQaR4NEsL84Wy1parS6vD13Y7Te/zss6P21XpVWXoXnv4vsLT 97UzZhne1i/zfGQj0F/pxLc/55z67rfPFvLfn8mxdk7eFX+1yq9ze+ryzJ/df3bwistzkQNL tnZvK+A/ddv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Ld4ne/nYrf6UnHSKaNZa25tXZYtwz454uj1mxuMlViK MxINtZiLihMB8rpxuckCAAA= X-CMS-MailID: 20200617172713epcas5p352f2907a12bd4ee3c97be1c7d8e1569e X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200617172713epcas5p352f2907a12bd4ee3c97be1c7d8e1569e References: <1592414619-5646-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 From: Selvakumar S Introduce three new opcodes for zone-append - IORING_OP_ZONE_APPEND : non-vectord, similiar to IORING_OP_WRITE IORING_OP_ZONE_APPENDV : vectored, similar to IORING_OP_WRITEV IORING_OP_ZONE_APPEND_FIXED : append using fixed-buffers Repurpose cqe->flags to return zone-relative offset. Signed-off-by: SelvaKumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/io_uring.c | 72 +++++++++++++++++++++++++++++++++++++++++-- include/uapi/linux/io_uring.h | 8 ++++- 2 files changed, 77 insertions(+), 3 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 155f3d8..c14c873 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -649,6 +649,10 @@ struct io_kiocb { unsigned long fsize; u64 user_data; u32 result; +#ifdef CONFIG_BLK_DEV_ZONED + /* zone-relative offset for append, in bytes */ + u32 append_offset; +#endif u32 sequence; struct list_head link_list; @@ -875,6 +879,26 @@ static const struct io_op_def io_op_defs[] = { .hash_reg_file = 1, .unbound_nonreg_file = 1, }, + [IORING_OP_ZONE_APPEND] = { + .needs_mm = 1, + .needs_file = 1, + .unbound_nonreg_file = 1, + .pollout = 1, + }, + [IORING_OP_ZONE_APPENDV] = { + .async_ctx = 1, + .needs_mm = 1, + .needs_file = 1, + .hash_reg_file = 1, + .unbound_nonreg_file = 1, + .pollout = 1, + }, + [IORING_OP_ZONE_APPEND_FIXED] = { + .needs_file = 1, + .hash_reg_file = 1, + .unbound_nonreg_file = 1, + .pollout = 1, + }, }; static void io_wq_submit_work(struct io_wq_work **workptr); @@ -1285,7 +1309,16 @@ static void __io_cqring_fill_event(struct io_kiocb *req, long res, long cflags) if (likely(cqe)) { WRITE_ONCE(cqe->user_data, req->user_data); WRITE_ONCE(cqe->res, res); +#ifdef CONFIG_BLK_DEV_ZONED + if (req->opcode == IORING_OP_ZONE_APPEND || + req->opcode == IORING_OP_ZONE_APPENDV || + req->opcode == IORING_OP_ZONE_APPEND_FIXED) + WRITE_ONCE(cqe->res2, req->append_offset); + else + WRITE_ONCE(cqe->flags, cflags); +#else WRITE_ONCE(cqe->flags, cflags); +#endif } else if (ctx->cq_overflow_flushed) { WRITE_ONCE(ctx->rings->cq_overflow, atomic_inc_return(&ctx->cached_cq_overflow)); @@ -1961,6 +1994,9 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res) static void io_complete_rw(struct kiocb *kiocb, long res, long res2) { struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); +#ifdef CONFIG_BLK_DEV_ZONED + req->append_offset = (u32)res2; +#endif io_complete_rw_common(kiocb, res); io_put_req(req); @@ -1976,6 +2012,9 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2) if (res != req->result) req_set_fail_links(req); req->result = res; +#ifdef CONFIG_BLK_DEV_ZONED + req->append_offset = (u32)res2; +#endif if (res != -EAGAIN) WRITE_ONCE(req->iopoll_completed, 1); } @@ -2408,7 +2447,8 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req, u8 opcode; opcode = req->opcode; - if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) { + if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED || + opcode == IORING_OP_ZONE_APPEND_FIXED) { *iovec = NULL; return io_import_fixed(req, rw, iter); } @@ -2417,7 +2457,8 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req, if (req->buf_index && !(req->flags & REQ_F_BUFFER_SELECT)) return -EINVAL; - if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) { + if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE || + opcode == IORING_OP_ZONE_APPEND) { if (req->flags & REQ_F_BUFFER_SELECT) { buf = io_rw_buffer_select(req, &sqe_len, needs_lock); if (IS_ERR(buf)) { @@ -2704,6 +2745,9 @@ static int io_write(struct io_kiocb *req, bool force_nonblock) req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT; req->result = 0; +#ifdef CONFIG_BLK_DEV_ZONED + req->append_offset = 0; +#endif io_size = ret; if (req->flags & REQ_F_LINK_HEAD) req->result = io_size; @@ -2738,6 +2782,13 @@ static int io_write(struct io_kiocb *req, bool force_nonblock) __sb_writers_release(file_inode(req->file)->i_sb, SB_FREEZE_WRITE); } +#ifdef CONFIG_BLK_DEV_ZONED + if (req->opcode == IORING_OP_ZONE_APPEND || + req->opcode == IORING_OP_ZONE_APPENDV || + req->opcode == IORING_OP_ZONE_APPEND_FIXED) + kiocb->ki_flags |= IOCB_ZONE_APPEND; +#endif + kiocb->ki_flags |= IOCB_WRITE; if (!force_nonblock) @@ -4906,6 +4957,12 @@ static int io_req_defer_prep(struct io_kiocb *req, case IORING_OP_WRITEV: case IORING_OP_WRITE_FIXED: case IORING_OP_WRITE: +#ifdef CONFIG_BLK_DEV_ZONED + fallthrough; + case IORING_OP_ZONE_APPEND: + case IORING_OP_ZONE_APPENDV: + case IORING_OP_ZONE_APPEND_FIXED: +#endif ret = io_write_prep(req, sqe, true); break; case IORING_OP_POLL_ADD: @@ -5038,6 +5095,12 @@ static void io_cleanup_req(struct io_kiocb *req) case IORING_OP_WRITEV: case IORING_OP_WRITE_FIXED: case IORING_OP_WRITE: +#ifdef CONFIG_BLK_DEV_ZONED + fallthrough; + case IORING_OP_ZONE_APPEND: + case IORING_OP_ZONE_APPENDV: + case IORING_OP_ZONE_APPEND_FIXED: +#endif if (io->rw.iov != io->rw.fast_iov) kfree(io->rw.iov); break; @@ -5086,6 +5149,11 @@ static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, } ret = io_read(req, force_nonblock); break; +#ifdef CONFIG_BLK_DEV_ZONED + case IORING_OP_ZONE_APPEND: + case IORING_OP_ZONE_APPENDV: + case IORING_OP_ZONE_APPEND_FIXED: +#endif case IORING_OP_WRITEV: case IORING_OP_WRITE_FIXED: case IORING_OP_WRITE: diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 92c2269..6c8e932 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -130,6 +130,9 @@ enum { IORING_OP_PROVIDE_BUFFERS, IORING_OP_REMOVE_BUFFERS, IORING_OP_TEE, + IORING_OP_ZONE_APPEND, + IORING_OP_ZONE_APPENDV, + IORING_OP_ZONE_APPEND_FIXED, /* this goes last, obviously */ IORING_OP_LAST, @@ -157,7 +160,10 @@ enum { struct io_uring_cqe { __u64 user_data; /* sqe->data submission passed back */ __s32 res; /* result code for this event */ - __u32 flags; + union { + __u32 res2; /* res2 like aio, currently used for zone-append */ + __u32 flags; + }; }; /*