From patchwork Thu Jun 25 17:15:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11625799 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 79ADE618 for ; Thu, 25 Jun 2020 17:18:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 577E620707 for ; Thu, 25 Jun 2020 17:18:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="ZWQf4HV8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404187AbgFYRSm (ORCPT ); Thu, 25 Jun 2020 13:18:42 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:24733 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404413AbgFYRSl (ORCPT ); Thu, 25 Jun 2020 13:18:41 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200625171836epoutp02269ed7fa5d4460bb1470e8c44b9a6f61~b2Qbe0zqy1719217192epoutp02B for ; Thu, 25 Jun 2020 17:18:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200625171836epoutp02269ed7fa5d4460bb1470e8c44b9a6f61~b2Qbe0zqy1719217192epoutp02B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593105516; bh=YTGGLNu4nig8Vx38SR8emuy9VTWu71Zk4LR4sgwbEjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZWQf4HV8vper8LUHeQ+jOp4CXrcLH7nFUkCD9irz6+nUPu2b61XiYYYm2rFsb8OaW WT3J9elFDKLcK27o9DEBzBiTv3AFCNmUKvvLKrncA6AUD48uTct/N86v44N7+bWsUd vBfxStUtWX18afed+Co8tlMYTSQ/RFv2hN51E1WU= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200625171835epcas5p1af144de8b8e1b8d9a8c8c3cd052730d4~b2QaohFej1015710157epcas5p11; Thu, 25 Jun 2020 17:18:35 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id E1.AA.09703.B6CD4FE5; Fri, 26 Jun 2020 02:18:35 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20200625171834epcas5p226a24dfcb84cfa83fe29a2bd17795d85~b2QZlXZ1b2484524845epcas5p2M; Thu, 25 Jun 2020 17:18:34 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200625171834epsmtrp2955a684b3710c7b060d75c15c0be5fc5~b2QZkgf342298422984epsmtrp2E; Thu, 25 Jun 2020 17:18:34 +0000 (GMT) X-AuditID: b6c32a4a-4cbff700000025e7-e6-5ef4dc6b4d23 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 7D.77.08382.A6CD4FE5; Fri, 26 Jun 2020 02:18:34 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200625171831epsmtip24f6edb673b9a642b3435a862c8557034~b2QXDPNZb1929619296epsmtip2k; Thu, 25 Jun 2020 17:18:31 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: asml.silence@gmail.com, Damien.LeMoal@wdc.com, hch@infradead.org, 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, selvakuma.s1@samsung.com, nj.shetty@samsung.com, javier.gonz@samsung.com, Kanchan Joshi , Arnav Dawn Subject: [PATCH v2 1/2] fs,block: Introduce RWF_ZONE_APPEND and handling in direct IO path Date: Thu, 25 Jun 2020 22:45:48 +0530 Message-Id: <1593105349-19270-2-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593105349-19270-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrMKsWRmVeSWpSXmKPExsWy7bCmlm72nS9xBu/bdS1+b3vEYvF7+hRW izmrtjFarL7bz2bR9W8Li0Vr+zcmi9MTFjFZvGs9x2Lx+M5ndouj/9+yWUyZ1sRosfeWtsWe vSdZLC7vmsNmsWL7ERaLbb/nM1tcmbKI2eL1j5NsFuf/Hmd1EPbYOesuu8fmFVoel8+Wemz6 NIndo/vqD0aPvi2rGD0+b5LzaD/QzeSx6clbpgDOKC6blNSczLLUIn27BK6Mjtv3WAreaVR8 3zuZvYFxgmIXIyeHhICJxNbVj1m6GLk4hAR2M0q8/jyfCcL5xCjR/vchK0iVkMA3Ronj76Jg OnYuuMEOUbSXUWJJ91dGCOczo8T0fQ+BHA4ONgFNiQuTS0FMEQEbiZ1LVEB6mQW+Mkm8OlcC YgsLxEjcbTnGDGKzCKhK3Gl6xAZi8wo4S6xqeMUKsUtO4ua5TmaQMZwCLhLb7oCtlRDYwyEx +eh1RogaF4nfO98xQ9jCEq+Ob2GHsKUkPr/bywZhF0v8unOUGaK5g1HiesNMFoiEvcTFPX+Z QBYwA528fpc+xJ18Er2/n4CFJQR4JTrahCCqFSXuTXoKdZq4xMMZS6BsD4lj+/vZIKEwnVHi S+ML9gmMsrMQpi5gZFzFKJlaUJybnlpsWmCUl1quV5yYW1yal66XnJ+7iRGcjrS8djA+fP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xxeV5qQWH2KU5mBREue9UbgwTkggPbEkNTs1tSC1CCbLxMEp1cDUcTGzLePUV9vZr6Rf OyTGXjw06cna7fMm78t32jDFWP2r1HrHCTrSnEmnRRzWtDayGCabXtzQcprrzqsD69ZF1+1X 2rw3SyTbKWPPPV/BmU/PbOizfHxPqqunXeDSjLvexreubCqdst16t9m9y7NCIm2SShS6zvAv YBZvmj5Lqlev2UjWUHCPfdo30+i0hw0C8xSZX+Vq8K7ly9vM4H7dftrpiE1xitkl0mcatjjw lSxb6iLxSGvH1oL9rHf3fa38/HTZ1d+n3r7Nr841vyq34p7fQxY2v8sr7u5fn1Wp+PFEQug7 02amfsmHwQ/dQy8y2d9M/DFdKNqS+2BZhmK39hHX4zYJi5en8hS4a/5QYinOSDTUYi4qTgQA BhpFJPQCAAA= X-CMS-MailID: 20200625171834epcas5p226a24dfcb84cfa83fe29a2bd17795d85 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200625171834epcas5p226a24dfcb84cfa83fe29a2bd17795d85 References: <1593105349-19270-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 RWF_ZONE_APPEND flag to represent zone-append. User-space sends this with write. Add IOCB_ZONE_APPEND which is set in kiocb->ki_flags on receiving RWF_ZONE_APPEND. Make direct IO submission path use IOCB_ZONE_APPEND to send bio with append op. Direct IO completion returns zone-relative offset, in sector unit, to upper layer using kiocb->ki_complete interface. Report error if zone-append is requested on regular file or on sync kiocb (i.e. one without ki_complete). Signed-off-by: Kanchan Joshi Signed-off-by: SelvaKumar S Signed-off-by: Arnav Dawn Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/block_dev.c | 28 ++++++++++++++++++++++++---- include/linux/fs.h | 9 +++++++++ include/uapi/linux/fs.h | 5 ++++- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 47860e5..5180268 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; + + if (iocb->ki_flags & IOCB_ZONE_APPEND) + op |= REQ_OP_ZONE_APPEND; + 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); } +static inline long blkdev_bio_end_io_append(struct bio *bio) +{ + sector_t zone_sectors = blk_queue_zone_sectors(bio->bi_disk->queue); + + /* calculate zone relative offset for zone append */ + return bio->bi_iter.bi_sector & (zone_sectors - 1); +} + static void blkdev_bio_end_io(struct bio *bio) { struct blkdev_dio *dio = bio->bi_private; @@ -307,15 +319,19 @@ static void blkdev_bio_end_io(struct bio *bio) if (!dio->is_sync) { struct kiocb *iocb = dio->iocb; ssize_t ret; + long res2 = 0; if (likely(!dio->bio.bi_status)) { ret = dio->size; iocb->ki_pos += ret; + + if (iocb->ki_flags & IOCB_ZONE_APPEND) + res2 = blkdev_bio_end_io_append(bio); } else { ret = blk_status_to_errno(dio->bio.bi_status); } - dio->iocb->ki_complete(iocb, ret, 0); + dio->iocb->ki_complete(iocb, ret, res2); if (dio->multi_bio) bio_put(&dio->bio); } else { @@ -382,6 +398,7 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) bio->bi_private = dio; bio->bi_end_io = blkdev_bio_end_io; bio->bi_ioprio = iocb->ki_ioprio; + bio->bi_opf = is_read ? REQ_OP_READ : dio_bio_write_op(iocb); ret = bio_iov_iter_get_pages(bio, iter); if (unlikely(ret)) { @@ -391,11 +408,9 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) } if (is_read) { - bio->bi_opf = REQ_OP_READ; if (dio->should_dirty) bio_set_pages_dirty(bio); } else { - bio->bi_opf = dio_bio_write_op(iocb); task_io_account_write(bio->bi_iter.bi_size); } @@ -465,12 +480,17 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) { + bool is_sync = is_sync_kiocb(iocb); int nr_pages; + /* zone-append is supported only on async-kiocb */ + if (is_sync && iocb->ki_flags & IOCB_ZONE_APPEND) + return -EINVAL; + nr_pages = iov_iter_npages(iter, BIO_MAX_PAGES + 1); if (!nr_pages) return 0; - if (is_sync_kiocb(iocb) && nr_pages <= BIO_MAX_PAGES) + if (is_sync && nr_pages <= BIO_MAX_PAGES) return __blkdev_direct_IO_simple(iocb, iter, nr_pages); return __blkdev_direct_IO(iocb, iter, min(nr_pages, BIO_MAX_PAGES)); diff --git a/include/linux/fs.h b/include/linux/fs.h index 6c4ab4d..3202d9a 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; @@ -3456,6 +3457,14 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC); if (flags & RWF_APPEND) ki->ki_flags |= IOCB_APPEND; + if (flags & RWF_ZONE_APPEND) { + /* currently support block device only */ + umode_t mode = file_inode(ki->ki_filp)->i_mode; + + if (!(S_ISBLK(mode))) + return -EOPNOTSUPP; + ki->ki_flags |= IOCB_ZONE_APPEND; + } return 0; } diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 379a612..1ce06e9 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -299,8 +299,11 @@ typedef int __bitwise __kernel_rwf_t; /* per-IO O_APPEND */ #define RWF_APPEND ((__force __kernel_rwf_t)0x00000010) +/* per-IO O_APPEND */ +#define RWF_ZONE_APPEND ((__force __kernel_rwf_t)0x00000020) + /* mask of flags supported by the kernel */ #define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT |\ - RWF_APPEND) + RWF_APPEND | RWF_ZONE_APPEND) #endif /* _UAPI_LINUX_FS_H */ From patchwork Thu Jun 25 17:15: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: 11625801 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 1BD6A618 for ; Thu, 25 Jun 2020 17:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F1A5A20773 for ; Thu, 25 Jun 2020 17:18:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="TUEHGmmP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406716AbgFYRSp (ORCPT ); Thu, 25 Jun 2020 13:18:45 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:37685 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406664AbgFYRSo (ORCPT ); Thu, 25 Jun 2020 13:18:44 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200625171841epoutp04ce3f18c524d1df4c11aeef38f835a203~b2QgB_mib2771027710epoutp04Z for ; Thu, 25 Jun 2020 17:18:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200625171841epoutp04ce3f18c524d1df4c11aeef38f835a203~b2QgB_mib2771027710epoutp04Z DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593105521; bh=HQ3oW5/y/qIsAd2fPg9vdYDB3D3VLLAhMflX2Yb0t+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TUEHGmmPNroX/tjbmiAffrwjXaIasd4rGN6XqzhCYPKIr55/zZN7IbQ8D8CATi3QW MvToDZ2/zoYn82ru0B8RgVDUdliHs0MXpAid+1wp+GpOHSCkenU/H7yaAzhQYZN4p4 9vInzb1gJV4gKAicxeG8NfM5OO5LKJbHE0eCeWVo= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20200625171840epcas5p3174975f291cba500e7a66006fa08b72d~b2QevPGXa2161421614epcas5p3W; Thu, 25 Jun 2020 17:18:40 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id B4.AA.09703.07CD4FE5; Fri, 26 Jun 2020 02:18:40 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20200625171838epcas5p449183e12770187142d8d55a9bf422a8d~b2QdfKmNw2789327893epcas5p4F; Thu, 25 Jun 2020 17:18:38 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200625171838epsmtrp1931ab9d87e36f85f6419629057796c65~b2QdeXyeQ1577615776epsmtrp1J; Thu, 25 Jun 2020 17:18:38 +0000 (GMT) X-AuditID: b6c32a4a-4cbff700000025e7-ec-5ef4dc70d9f4 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id AC.1A.08303.E6CD4FE5; Fri, 26 Jun 2020 02:18:38 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200625171836epsmtip24aad812c1b8b4d3aaf07072aa0407e22~b2Qa-iYUC1929119291epsmtip2d; Thu, 25 Jun 2020 17:18:36 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: asml.silence@gmail.com, Damien.LeMoal@wdc.com, hch@infradead.org, 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, selvakuma.s1@samsung.com, nj.shetty@samsung.com, javier.gonz@samsung.com, Kanchan Joshi Subject: [PATCH v2 2/2] io_uring: add support for zone-append Date: Thu, 25 Jun 2020 22:45:49 +0530 Message-Id: <1593105349-19270-3-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593105349-19270-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe1BMYRjGfeecPXtqZs1xLPvJ1ExLTBkht89MyBTOMGZcSjKKxZlldFl7 5LJFCau2SUkIIWnIZmpkFbuVLiqXSCRqWqORbZSKrViadTl2jf9+7/s+z/O+881H4cwlkRu1 M3oPp45WRMpJV6K01nvqdFXHUMTMnEoKjZzNEqEcfSlAheZ0Eul+Ggh07PhXDD3JyMNQ/7Fn BHrfMShGdb/6SJR1JgmgivZpqLziEYFeGnNIVFD2gEClI5dx1JKVh6Ne2yMSNdkbRAEMe++8 WczeLvBhXz6NZUusmWI29ZUNsCcMesAOlniwx6tSMbakqw9b7bLR1X87F7lzL6eesWiL646L aZ6qW5776z61kokgZaIOuFCQngPfHL1E6IArxdAmAKvOGJ2FFcDs4geYoGLoQQCvvJ/3z2HN GSEdIiOAFnMS7ij+iJ5oa0U6QFEk7Q2fn4oVUEr7w3v5kwUJTrdgsDv7gkgIGksvhNcz8wiB CdoLfn/ciwssoQNhVVmGyLHMA7Y9S8GFHBc6CJZ2iIUcSBso2HO9nnBogmB96mHcwWNhT4NB 7GA3+DFd62Qe/uiowx3mZABfJ55zmh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jAyLeAkWEVo2RqQXFuem6xYYFRXmq5 XnFibnFpXrpecn7uJkZwBGhp7WDcs+qD3iFGJg7GQ4wSHMxKIrwhbp/ihHhTEiurUovy44tK c1KLDzFKc7AoifN+nbUwTkggPbEkNTs1tSC1CCbLxMEp1cA0rZN33/M4I74NEkfOqT00zLju 8is0c/+VoDNBS30nBkRU9FodZS21Wte06v405QWbyy9terpFcUJYYBG7Q81DpQWTre92xn/L n7DN8e7qY3e8nJtUDAPOMn6+wHKysHPyDkMG5em2bLdPRf5k+3O7OebFqc+RVbenMBsncLdU KJ3qfJ2c07b0+rPiCtXzW9iyjO4lbGntuvHcaM3pq+W8JyJmO9btcpPV29Sxpu21bf2tmT/i eH8YRRh78vxP5FENFTj9IGo738UdL+NESwzkN9/nM7p8d+vbk8uXC+xYOF3uU5uVEte/PSfl rueyv1yraMxkrLDkxYneKtbDWy6/eNAyL0/WgS/n/PU372eaKrEUZyQaajEXFScCAA0hLezv AgAA X-CMS-MailID: 20200625171838epcas5p449183e12770187142d8d55a9bf422a8d X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200625171838epcas5p449183e12770187142d8d55a9bf422a8d References: <1593105349-19270-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 For zone-append, block-layer will return zone-relative offset via ret2 of ki_complete interface. Make changes to collect it, and send to user-space using ceq->flags. Detect and report early error if zone-append is requested with fixed-buffers. Signed-off-by: Selvakumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/io_uring.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 155f3d8..31a9da58 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -402,6 +402,8 @@ struct io_rw { struct kiocb kiocb; u64 addr; u64 len; + /* zone-relative offset for append, in sectors */ + u32 append_offset; }; struct io_connect { @@ -541,6 +543,7 @@ enum { REQ_F_NO_FILE_TABLE_BIT, REQ_F_QUEUE_TIMEOUT_BIT, REQ_F_WORK_INITIALIZED_BIT, + REQ_F_ZONE_APPEND_BIT, /* not a real bit, just to check we're not overflowing the space */ __REQ_F_LAST_BIT, @@ -598,6 +601,8 @@ enum { REQ_F_QUEUE_TIMEOUT = BIT(REQ_F_QUEUE_TIMEOUT_BIT), /* io_wq_work is initialized */ REQ_F_WORK_INITIALIZED = BIT(REQ_F_WORK_INITIALIZED_BIT), + /* to return zone relative offset for zone append*/ + REQ_F_ZONE_APPEND = BIT(REQ_F_ZONE_APPEND_BIT), }; struct async_poll { @@ -1745,6 +1750,8 @@ static void io_iopoll_complete(struct io_ring_ctx *ctx, unsigned int *nr_events, if (req->flags & REQ_F_BUFFER_SELECTED) cflags = io_put_kbuf(req); + if (req->flags & REQ_F_ZONE_APPEND) + cflags = req->rw.append_offset; __io_cqring_fill_event(req, req->result, cflags); (*nr_events)++; @@ -1943,7 +1950,7 @@ static inline void req_set_fail_links(struct io_kiocb *req) req->flags |= REQ_F_FAIL_LINK; } -static void io_complete_rw_common(struct kiocb *kiocb, long res) +static void io_complete_rw_common(struct kiocb *kiocb, long res, long res2) { struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); int cflags = 0; @@ -1953,8 +1960,14 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res) if (res != req->result) req_set_fail_links(req); + if (req->flags & REQ_F_BUFFER_SELECTED) cflags = io_put_kbuf(req); + + /* use cflags to return zone append completion result */ + if (req->flags & REQ_F_ZONE_APPEND) + cflags = res2; + __io_cqring_add_event(req, res, cflags); } @@ -1962,7 +1975,7 @@ static void io_complete_rw(struct kiocb *kiocb, long res, long res2) { struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); - io_complete_rw_common(kiocb, res); + io_complete_rw_common(kiocb, res, res2); io_put_req(req); } @@ -1975,6 +1988,9 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2) if (res != req->result) req_set_fail_links(req); + if (req->flags & REQ_F_ZONE_APPEND) + req->rw.append_offset = res2; + req->result = res; if (res != -EAGAIN) WRITE_ONCE(req->iopoll_completed, 1); @@ -2127,6 +2143,9 @@ static int io_prep_rw(struct io_kiocb *req, const struct io_uring_sqe *sqe, if (kiocb->ki_flags & IOCB_NOWAIT) req->flags |= REQ_F_NOWAIT; + if (kiocb->ki_flags & IOCB_ZONE_APPEND) + req->flags |= REQ_F_ZONE_APPEND; + if (force_nonblock) kiocb->ki_flags |= IOCB_NOWAIT; @@ -2409,6 +2428,14 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req, opcode = req->opcode; if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) { + /* + * fixed-buffers not supported for zone-append. + * This check can be removed when block-layer starts + * supporting append with iov_iter of bvec type + */ + if (req->flags == REQ_F_ZONE_APPEND) + return -EINVAL; + *iovec = NULL; return io_import_fixed(req, rw, iter); } @@ -2704,6 +2731,7 @@ static int io_write(struct io_kiocb *req, bool force_nonblock) req->rw.kiocb.ki_flags &= ~IOCB_NOWAIT; req->result = 0; + io_size = ret; if (req->flags & REQ_F_LINK_HEAD) req->result = io_size;