From patchwork Sun Jul 5 18:47:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11644571 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 BF2C36C1 for ; Sun, 5 Jul 2020 18:52:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E1CC2073E for ; Sun, 5 Jul 2020 18:52:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="TCGvSGVy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728110AbgGESwQ (ORCPT ); Sun, 5 Jul 2020 14:52:16 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:31836 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbgGESwP (ORCPT ); Sun, 5 Jul 2020 14:52:15 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200705185214epoutp0231987a20cbd6c67473f9c867d08ca4a5~e7-BrIVj13075530755epoutp02- for ; Sun, 5 Jul 2020 18:52:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200705185214epoutp0231987a20cbd6c67473f9c867d08ca4a5~e7-BrIVj13075530755epoutp02- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593975134; bh=EdQAf5+zw6N5J2+HOrsvrQfxx8kc7JZeLZVVK6M6PcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TCGvSGVyqOKSya2EEIuudSvnZj5fnJRrSwoTnr5kY4jH09H83B+QgsK0iBJcrOiAi PNhxyOeKwO5R1lWtfF/DzJ/mHJ+Wma5Gw/8kDUD84szYoe9LttBuX0NhA2tsU9hvNY Bag031VVnUjczQb3NDjpYsXQqftHbSBpkWOoBU44= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p3.samsung.com (KnoxPortal) with ESMTP id 20200705185212epcas5p3f7db3dbbf75a909dbc5d85f66b033014~e7-AqOR6C0482204822epcas5p3x; Sun, 5 Jul 2020 18:52:12 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 4F.B7.09703.C51220F5; Mon, 6 Jul 2020 03:52:12 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p4.samsung.com (KnoxPortal) with ESMTPA id 20200705185211epcas5p4059d05d2fcedb91829300a7a7d03fda3~e7_-ewc7F1418914189epcas5p45; Sun, 5 Jul 2020 18:52:11 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200705185211epsmtrp1bb12d193d2271b7451da13042d046c6d~e7_-dwRAV0303903039epsmtrp10; Sun, 5 Jul 2020 18:52:11 +0000 (GMT) X-AuditID: b6c32a4a-4cbff700000025e7-37-5f02215c0cd3 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id D9.37.08303.B51220F5; Mon, 6 Jul 2020 03:52:11 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200705185209epsmtip2b4cf5e349418fb0b9c4ddd3670b42090~e7_9FQgN73204832048epsmtip2s; Sun, 5 Jul 2020 18:52:08 +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 1/4] fs: introduce FMODE_ZONE_APPEND and IOCB_ZONE_APPEND Date: Mon, 6 Jul 2020 00:17:47 +0530 Message-Id: <1593974870-18919-2-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: H4sIAAAAAAAAA0WSaUwTURSFfTPTdopWJ8XEJ+JCgRhqRBE0z7jgho5GAvpLCYpVxkKEgi11 qxhAKaUNgkpksW5AFDGKFoJQBE21YkGoFmRLJaJFBXdwISAopVX/ffeec899uXkkzr/AciOj JQmMVCKKEbBdiIoHPsL54R5YxEJzmx8azslmIW1JBUDXX2SykXq0nECpaT8w1JBVgKFPqU0E em0d4CDj749slH02BaCaznnobo2JQM16LRsV33lIoIrhizhqyS7A0ftBExuZR+pYq/h0Vf4L Dl1WLKSbG+W0rv80h9Y8HwT0yfISQA/oZtFp9zUYrbN9xEK5YS7LI5mY6AOMdMHKXS5RhZ15 WLze9VDbryxWEkih1IBLQioAGqsfse3Mp6oBHLwfqAYuY9wP4NtXD4CjGAAwrcDG+jvRbqti OQQ9gPW1mcQ/182Ox5gakCSb8oFPz8jtOJVaDquKvOwWnErDYavJMh7kSm2GQw3vMDsTlDds vNgI7Myj1sJ6UynbsWwW7GhKx+3MpdZBZXUDbg+CVCUJW5Lfju+CY4LmK+3wu8K+unKOg91g b6bSyTI4ZDU6Z1UAtiXlEQ4hED67OzKeg4+9uVS/wN7GqckwY9jmjOdBlZLvcHvArtM9zjtM g925RU6m4dO8IuC4Yg6Ayfo5WWBm/v/QSwCUgOlMvCxWzMgWxy+SMAd9ZaJYmVwi9t0TF6sD 419IuKkSdL/84msAGAkMAJK4YCovYx6I4PMiRYePMNK4CKk8hp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DyU8CV3rWrA3vmZK5dPeyD45JALV98m3sVaQVHNOx0X6Rk0P79SEfuyQ4PH/0wJ Q5zipqszFjhOTGWZWXu96e6dLTdv5dot/2gqsk0tUGWqTXihZfLnbYJLC9TMCzcKaDBW/e3l 1pedyLhrJZ+PiJ+hvMH7o7/nss/3D5rS0nuQ6btzw5mCVkY/kWMt/1Xmfr183W7GidqE5TMz C9c1/tqyMuZEvX7kO5cU+RUSL/uv8c2cq+XYNefknsLVYX9kanh2PdPpUL0X5lpcsubk6swb XTlN3TuuxdTemrf/0RpP8ZzdqZauva8rhDUT11qd2My+z3KCuy+TEktxRqKhFnNRcSIAqAaK GPACAAA= X-CMS-MailID: 20200705185211epcas5p4059d05d2fcedb91829300a7a7d03fda3 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200705185211epcas5p4059d05d2fcedb91829300a7a7d03fda3 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 Enable zone-append using existing O_APPEND and RWF_APPEND infra. Unlike file-append, zone-apppend requires bit of additional processing in common path to send completion-result to upper layer. To skip that for non-zoned block-devices/files, introduce FMODE_ZONE_APPEND and IOCB_ZONE_APPEND. When a file is opened, it can subscribe to zone-append by setting FMODE_ZONE_APPEND. Add IOCB_ZONE_APPEND which is set in kiocb->ki_flags if write meets existing file-append critera, and file has subscribed to zone-append. Signed-off-by: Selvakumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- include/linux/fs.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 6c4ab4d..ef13df4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -175,6 +175,9 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, /* File does not contribute to nr_files count */ #define FMODE_NOACCOUNT ((__force fmode_t)0x20000000) +/* File can support zone-append */ +#define FMODE_ZONE_APPEND ((__force fmode_t)0x40000000) + /* * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector * that indicates that they should check the contents of the iovec are @@ -315,6 +318,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; @@ -3427,8 +3431,11 @@ static inline bool vma_is_fsdax(struct vm_area_struct *vma) static inline int iocb_flags(struct file *file) { int res = 0; - if (file->f_flags & O_APPEND) + if (file->f_flags & O_APPEND) { res |= IOCB_APPEND; + if (file->f_mode & FMODE_ZONE_APPEND) + res |= IOCB_ZONE_APPEND; + } if (file->f_flags & O_DIRECT) res |= IOCB_DIRECT; if ((file->f_flags & O_DSYNC) || IS_SYNC(file->f_mapping->host)) @@ -3454,8 +3461,11 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) ki->ki_flags |= IOCB_DSYNC; if (flags & RWF_SYNC) ki->ki_flags |= (IOCB_DSYNC | IOCB_SYNC); - if (flags & RWF_APPEND) + if (flags & RWF_APPEND) { ki->ki_flags |= IOCB_APPEND; + if (ki->ki_filp->f_mode & FMODE_ZONE_APPEND) + ki->ki_flags |= IOCB_ZONE_APPEND; + } return 0; } From patchwork Sun Jul 5 18:47: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: 11644587 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 18B75913 for ; Sun, 5 Jul 2020 18:52:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E505A2084C for ; Sun, 5 Jul 2020 18:52:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="nsNCWCzK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728146AbgGESwZ (ORCPT ); Sun, 5 Jul 2020 14:52:25 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:40488 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728121AbgGESwW (ORCPT ); Sun, 5 Jul 2020 14:52:22 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200705185219epoutp0358392432eac9aa210b108952db1cf9a6~e7-Gas_gS2669326693epoutp03G for ; Sun, 5 Jul 2020 18:52:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200705185219epoutp0358392432eac9aa210b108952db1cf9a6~e7-Gas_gS2669326693epoutp03G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593975139; bh=o9X0/DRGhOiQAeeouZvDE/Hf3lYVHbd1pPCwPfh4oTA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nsNCWCzK63+qWyYDE4QkfeOCXbGb0RczV8vpBz6Zi03PF77nJ/j69qW//6qeux39j i67CsoW7PvZoUZleslD7kADS0my2x8W6bZCk2xtIrYS9VwWf/eqn7uDM92Kd2Le88t v9biNQGLKX6FKMBKjLVeTYqyVqkxoD9sdfqg/eL0= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200705185218epcas5p13f0f63e2276c1542beebf9c323633bce~e7-FrCPVo2311023110epcas5p16; Sun, 5 Jul 2020 18:52:18 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 82.C7.09703.261220F5; Mon, 6 Jul 2020 03:52:18 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200705185217epcas5p1cc12d4b892f057a1fe06d73a00869daa~e7-Eg1lv30734507345epcas5p1d; Sun, 5 Jul 2020 18:52:17 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200705185217epsmtrp2b1eda7d6b157d43bd4a3e1756bf6c6ce~e7-Ef8QyP1855618556epsmtrp20; Sun, 5 Jul 2020 18:52:17 +0000 (GMT) X-AuditID: b6c32a4a-4b5ff700000025e7-42-5f022162852b Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 6B.37.08303.061220F5; Mon, 6 Jul 2020 03:52:16 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200705185214epsmtip2d532bc57741d334bd3d8583d01ff37ee~e7-B8VoeE3260032600epsmtip2z; Sun, 5 Jul 2020 18:52:14 +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, Selvakumar S , Kanchan Joshi , Nitesh Shetty , Arnav Dawn , Javier Gonzalez Subject: [PATCH v3 2/4] block: add zone append handling for direct I/O path Date: Mon, 6 Jul 2020 00:17:48 +0530 Message-Id: <1593974870-18919-3-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+NgFlrKKsWRmVeSWpSXmKPExsWy7bCmum6SIlO8wcf5vBa/tz1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wIAOO9 /971AgAA X-CMS-MailID: 20200705185217epcas5p1cc12d4b892f057a1fe06d73a00869daa X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200705185217epcas5p1cc12d4b892f057a1fe06d73a00869daa 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 From: Selvakumar S For zoned block device, subscribe to zone-append by setting FMODE_ZONE_APPEND during open. Make direct IO submission path use IOCB_ZONE_APPEND to send bio with append op. Make direct IO completion return zone-relative offset, in sector unit, to upper layer using kiocb->ki_complete interface. Return failure if write is larger than max_append_limit and therefore requires formation of multiple bios. Signed-off-by: Selvakumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Arnav Dawn Signed-off-by: Javier Gonzalez --- fs/block_dev.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 47860e5..941fb22 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -178,10 +178,19 @@ static struct inode *bdev_file_inode(struct file *file) return file->f_mapping->host; } -static unsigned int dio_bio_write_op(struct kiocb *iocb) +static unsigned int dio_bio_op(bool is_read, struct kiocb *iocb) { - unsigned int op = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE; + unsigned int op; + if (is_read) + return REQ_OP_READ; + + if (iocb->ki_flags & IOCB_ZONE_APPEND) + op = REQ_OP_ZONE_APPEND; + else + op = REQ_OP_WRITE; + + op |= REQ_SYNC | REQ_IDLE; /* avoid the need for a I/O completion work item */ if (iocb->ki_flags & IOCB_DSYNC) op |= REQ_FUA; @@ -207,6 +216,7 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, struct bio_vec inline_vecs[DIO_INLINE_BIO_VECS], *vecs; loff_t pos = iocb->ki_pos; bool should_dirty = false; + bool is_read = (iov_iter_rw(iter) == READ); struct bio bio; ssize_t ret; blk_qc_t qc; @@ -231,18 +241,17 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, bio.bi_private = current; bio.bi_end_io = blkdev_bio_end_io_simple; bio.bi_ioprio = iocb->ki_ioprio; + bio.bi_opf = dio_bio_op(is_read, iocb); ret = bio_iov_iter_get_pages(&bio, iter); if (unlikely(ret)) goto out; ret = bio.bi_iter.bi_size; - if (iov_iter_rw(iter) == READ) { - bio.bi_opf = REQ_OP_READ; + if (is_read) { if (iter_is_iovec(iter)) should_dirty = true; } else { - bio.bi_opf = dio_bio_write_op(iocb); task_io_account_write(ret); } if (iocb->ki_flags & IOCB_HIPRI) @@ -295,6 +304,16 @@ static int blkdev_iopoll(struct kiocb *kiocb, bool wait) return blk_poll(q, READ_ONCE(kiocb->ki_cookie), wait); } +static inline long blkdev_bio_res2(struct kiocb *iocb, struct bio *bio) +{ + /* calculate zone relative offset for zone append */ + if (op_is_write(bio_op(bio)) && iocb->ki_flags & IOCB_ZONE_APPEND) { + sector_t zone_sec = blk_queue_zone_sectors(bio->bi_disk->queue); + return bio->bi_iter.bi_sector & (zone_sec - 1); + } + return 0; +} + static void blkdev_bio_end_io(struct bio *bio) { struct blkdev_dio *dio = bio->bi_private; @@ -307,15 +326,17 @@ static void blkdev_bio_end_io(struct bio *bio) if (!dio->is_sync) { struct kiocb *iocb = dio->iocb; ssize_t ret; + long res2; if (likely(!dio->bio.bi_status)) { ret = dio->size; iocb->ki_pos += ret; + res2 = blkdev_bio_res2(iocb, 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 +403,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 = dio_bio_op(is_read, iocb); ret = bio_iov_iter_get_pages(bio, iter); if (unlikely(ret)) { @@ -391,11 +413,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); } @@ -419,6 +439,12 @@ __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, int nr_pages) } if (!dio->multi_bio) { + /* zone-append cannot work with multi bio*/ + if (!is_read && iocb->ki_flags & IOCB_ZONE_APPEND) { + bio->bi_status = BLK_STS_IOERR; + bio_endio(bio); + break; + } /* * AIO needs an extra reference to ensure the dio * structure which is embedded into the first bio @@ -1841,6 +1867,7 @@ EXPORT_SYMBOL(blkdev_get_by_dev); static int blkdev_open(struct inode * inode, struct file * filp) { struct block_device *bdev; + int ret; /* * Preserve backwards compatibility and allow large file access @@ -1866,7 +1893,11 @@ static int blkdev_open(struct inode * inode, struct file * filp) filp->f_mapping = bdev->bd_inode->i_mapping; filp->f_wb_err = filemap_sample_wb_err(filp->f_mapping); - return blkdev_get(bdev, filp->f_mode, filp); + ret = blkdev_get(bdev, filp->f_mode, filp); + if (blk_queue_is_zoned(bdev->bd_disk->queue)) + filp->f_mode |= FMODE_ZONE_APPEND; + + return ret; } static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) 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+N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pTgj0VCLuag4EQCG1RVp8AIA 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); From patchwork Sun Jul 5 18:47: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: 11644585 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 EABF96C1 for ; Sun, 5 Jul 2020 18:52:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD31A20874 for ; Sun, 5 Jul 2020 18:52:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="h0vCiK0v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728173AbgGESwe (ORCPT ); Sun, 5 Jul 2020 14:52:34 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:40530 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728168AbgGESwb (ORCPT ); Sun, 5 Jul 2020 14:52:31 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200705185228epoutp03f79931b297b2601675b69661e5ea7df3~e7-Pb9wFx2669326693epoutp03L for ; Sun, 5 Jul 2020 18:52:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200705185228epoutp03f79931b297b2601675b69661e5ea7df3~e7-Pb9wFx2669326693epoutp03L DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1593975148; bh=EDeoKzff2L3XGHadZi/OIFUby3HIdjDpDQcs/wY5K7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h0vCiK0vfynf7uS3gvJlWms2MQeu8M+FS+SHtQUQvyafvenqgHCZAmcoXOB9EryHX g0o5FTw/BJ7ecm3vKmE8M4/PLFDnUakZZZlR21BhHKAegbJkXAPA2JAB+aQEXA90bi /Uwb6T6y989qhkukq4YITiC1rW6ouyz7ApWmsyOk= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20200705185228epcas5p4d63536fb4ff71ca1a9d91322c2aec8b2~e7-O7A85D1418914189epcas5p4D; Sun, 5 Jul 2020 18:52:28 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id D5.C7.09703.C61220F5; Mon, 6 Jul 2020 03:52:28 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200705185227epcas5p16fba3cb92561794b960184c89fdf2bb7~e7-OS5KwJ2311023110epcas5p1E; Sun, 5 Jul 2020 18:52:27 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200705185227epsmtrp1958b2733946f97338ab9ed5a3835c095~e7-OSHD770303903039epsmtrp1_; Sun, 5 Jul 2020 18:52:27 +0000 (GMT) X-AuditID: b6c32a4a-4b5ff700000025e7-54-5f02216c3ddb Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 4D.37.08303.B61220F5; Mon, 6 Jul 2020 03:52:27 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200705185224epsmtip27b31b5b2d629a5e08596d2873cb48d57~e7-Ln6_Kc3204432044epsmtip2i; Sun, 5 Jul 2020 18:52:24 +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, Selvakumar S , Kanchan Joshi , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v3 4/4] io_uring: add support for zone-append Date: Mon, 6 Jul 2020 00:17:50 +0530 Message-Id: <1593974870-18919-5-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+NgFprHKsWRmVeSWpSXmKPExsWy7bCmlm6OIlO8wY0OTovf06ewWsxZtY3R YvXdfjaLrn9bWCxa278xWZyesIjJ4l3rORaLx3c+s1sc/f+WzWLKtCZGi723tC327D3JYnF5 1xw2ixXbj7BYbPs9n9niypRFzBavf5xkszj/9zirg5DHzll32T02r9DyuHy21GPTp0nsHt1X fzB69G1ZxejxeZOcR/uBbiaPTU/eMgVwRnHZpKTmZJalFunbJXBlzJm1gb1grnRFzzexBsaF Yl2MHBwSAiYSL9uluhi5OIQEdjNKTNmxhgXC+cQosat7IhOE85lR4uepl8xdjJxgHX1Pb7NB JHYBJVYdQqg6/qeTEWQum4CmxIXJpSCmiICNxM4lKiAlzALtzBIndt5hAhkkLGArce7PKnYQ m0VAVeLOmUlgNq+As8TGi+dZIZbJSdw81wm2mFPARaJt92lmkEESAls4JI6encYGUeQi8f7g OyhbWOLV8S3sELaUxMv+Nii7WOLXnaNQzR2MEtcbZrJAJOwlLu75ywRyKTPQ0et36YOEmQX4 JHp/P2GChBGvREebEES1osS9SU+hbhOXeDhjCZTtIXGs+QLYX0IC0xkl5pwvmcAoOwth6AJ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RCjBAezkghvrzZjvBBvSmJlVWpRfnxR aU5q8SFGaQ4WJXHer7MWxgkJpCeWpGanphakFsFkmTg4pRqYavVfztGIPcy9oVLt6qZ9Mrnf bX27pzp3/rs8L9b/Su7V1VXMtVxqLx33Tn532udU1wNWYRXdk4nLzVrfvrly4tAq6zO+cYY+ ebu8zmYZfWx6Wjrj+LU/3YontPXqE2vk/N60zxd5/3pPZ4u6gNfMNx9uu36p2xDucLw7psj3 /IQ/1QYnWkrzfWz/t9jUuT5IMJY3OexyqtYi4fHW5J+WP/588a2Mfchyso9tX5rUpXS1X7Vf JVvW//WfO+nsfvmSxtXcLfxnvlza/6Uj2/HLZct+R57HhetaWXz+H8mtFNof9EhKd3pX2T/m NZ0xD39/v1LiE8WyzemW/r78yTdceOU/exy78ftaUepS611flFiKMxINtZiLihMBLkoc7vAC AAA= X-CMS-MailID: 20200705185227epcas5p16fba3cb92561794b960184c89fdf2bb7 X-Msg-Generator: CA CMS-TYPE: 105P X-CMS-RootMailID: 20200705185227epcas5p16fba3cb92561794b960184c89fdf2bb7 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 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 cqe->flags. Signed-off-by: Selvakumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/io_uring.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 155f3d8..cbde4df 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; @@ -1955,6 +1962,10 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res) 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 +1973,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 +1986,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); @@ -2739,6 +2753,9 @@ static int io_write(struct io_kiocb *req, bool force_nonblock) SB_FREEZE_WRITE); } kiocb->ki_flags |= IOCB_WRITE; + /* zone-append requires few extra steps during completion */ + if (kiocb->ki_flags & IOCB_ZONE_APPEND) + req->flags |= REQ_F_ZONE_APPEND; if (!force_nonblock) current->signal->rlim[RLIMIT_FSIZE].rlim_cur = req->fsize;