From patchwork Fri Jul 24 15:49:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11683733 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 EC8F013B6 for ; Fri, 24 Jul 2020 16:23:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF0AE20737 for ; Fri, 24 Jul 2020 16:23:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="IRjJfvJF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726820AbgGXQW6 (ORCPT ); Fri, 24 Jul 2020 12:22:58 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:16839 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbgGXQW6 (ORCPT ); Fri, 24 Jul 2020 12:22:58 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20200724162255epoutp04ce651db373be94190d2aaace87234cba~kvNFesyIh3120231202epoutp04o for ; Fri, 24 Jul 2020 16:22:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20200724162255epoutp04ce651db373be94190d2aaace87234cba~kvNFesyIh3120231202epoutp04o DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595607775; bh=alboB0qIzBsat5Ky/WzI4KKfCDoIdRWX/zQdLs+zkJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRjJfvJF1mIZ4Urp+hhfIh6mhG65/w0mWK7e6uNfXBPpswTaJiEgiWSKi3XvCRUs+ liiogh979T9UawUYL3j42oAThoDqEM0JHGB9a2bd92R9iKlNWPOJUo/abVAal6LyoI j2wcKv0qwCUgo1+4b6FkZiZkYpkVBy/7uhPLWBik= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200724162254epcas5p1f4a3fb425b2c3ce8a1ea2996242cabc4~kvNERf2Yo0150101501epcas5p1f; Fri, 24 Jul 2020 16:22:54 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 91.CE.40333.DDA0B1F5; Sat, 25 Jul 2020 01:22:53 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200724155258epcas5p1a75b926950a18cd1e6c8e7a047e6c589~kuy8bKUF41547815478epcas5p1N; Fri, 24 Jul 2020 15:52:58 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200724155258epsmtrp2de962289c70336346aeef29d0e22e5c2~kuy8aPCoQ2867528675epsmtrp2N; Fri, 24 Jul 2020 15:52:58 +0000 (GMT) X-AuditID: b6c32a4a-991ff70000019d8d-3b-5f1b0addedfd Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E6.02.08382.AD30B1F5; Sat, 25 Jul 2020 00:52:58 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200724155256epsmtip15f08201e859c8819fb0c534a503a7287~kuy5szSx40257802578epsmtip15; Fri, 24 Jul 2020 15:52:55 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: willy@infradead.org, hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, Kanchan Joshi , Selvakumar S , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v4 1/6] fs: introduce FMODE_ZONE_APPEND and IOCB_ZONE_APPEND Date: Fri, 24 Jul 2020 21:19:17 +0530 Message-Id: <1595605762-17010-2-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNKsWRmVeSWpSXmKPExsWy7bCmhu5dLul4gzMnbCx+T5/CajFn1TZG i9V3+9ksuv5tYbFobf/GZHF6wiImi3et51gsHt/5zG5x9P9bNosp05oYLTZ/72Cz2HtL22LP 3pMsFpd3zWGz2PZ7PrPFlSmLmC1e/zjJZnH+73FWi98/5rA5CHvsnHWX3WPzCi2Py2dLPTZ9 msTu0bdlFaPH501yHu0Hupk8Nj15yxTAEcVlk5Kak1mWWqRvl8CVcbT3NGvBNLGKT61n2BsY lwh1MXJySAiYSCxfdZ2li5GLQ0hgN6PE+v5OVpCEkMAnRomv9/kgEt8YJR4t2sgM09H/fgUz RGIvo8Thj2eh2j8zSjzd9R4ow8HBJqApcWFyKYgpImAjsXOJCkgvs8ByZon1a3lBbGEBH4nH QJ+D2CwCqhLXfqwG6+QVcJbY90AHYpWcxM1znWBrOQVcJC5cvMsIsklCYAuHRNu8fWwQRS4S L38cZYSwhSVeHd/CDmFLSXx+txeqplji152jzBDNHYwS1xtmskAk7CUu7vnLBLKYGejk9bv0 IcKyElNPrWOCuJlPovf3EyaIOK/EjnkwtqLEvUlPWSFscYmHM5ZA2R4S37+2s0GCZDqjxJLJ G5gmMMrNQlixgJFxFaNkakFxbnpqsWmBUV5quV5xYm5xaV66XnJ+7iZGcHrS8trB+PDBB71D jEwcjIcYJTiYlUR4V3yTihfiTUmsrEotyo8vKs1J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Z7MnDjp2V33i27v 1dKZH6y2nHTAIfsMz9kVXq/essTdOj1Jcd0j3bUb0yQfrvjtVZb0eMPKz6teyhdpcGrr/Zit aj0vgOvp2cBO6zTfia/rsgUYFgbKr/dOmjXtMv8rmdqJ/c8Tf6TxRKac/hu8Izm4ahpH5Tzf 44FXjJIenG6a4LFGgMPU/5Xu/ST7nj159ptcVocL2bkketl6eUc4Zl2c9mTGhZtWv0Xqcs3n aurp7/Ce8Hh6h6rxf49fPI3H/J3e395d/Eo4chPrySar69kXOBeEMX3ZkcAnb52csEDtZviO R2/OKE7coizwLv8sw1OuyQrdp+bK/Xv8xtq9cuHnjmVhc9YqsRRnJBpqMRcVJwIAIwT+6e8C AAA= X-CMS-MailID: 20200724155258epcas5p1a75b926950a18cd1e6c8e7a047e6c589 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200724155258epcas5p1a75b926950a18cd1e6c8e7a047e6c589 References: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Enable zone-append using existing O_APPEND and RWF_APPEND. Zone-append is similar to appending writes, but requires written-location to be returned, in order to be effective. Returning completion-result requires bit of additional processing in common path. Also, we guarantee that zone-append does not cause a short write, which is not the case with regular appending-write. Therefore make the feature opt-in by introducing new FMODE_ZONE_APPEND mode (kernel-only) and IOCB_ZONE_APPEND flag. When a file is opened, it can opt in for zone-append by setting FMODE_ZONE_APPEND. If file has opted in, and receives write that meets file-append criteria (RWF_APPEND write or O_APPEND open), set IOCB_ZONE_APPEND in kiocb->ki_flag, apart from existing IOCB_APPEND. IOCB_ZONE_APPEND is meant to isolate the code that returns written-location with appending write. Signed-off-by: Kanchan Joshi Signed-off-by: Selvakumar S 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 Fri Jul 24 15:49:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11683737 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 7EA4D913 for ; Fri, 24 Jul 2020 16:23:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 606D6206F6 for ; Fri, 24 Jul 2020 16:23:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="iAYnurzX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgGXQXP (ORCPT ); Fri, 24 Jul 2020 12:23:15 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:11813 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726539AbgGXQXP (ORCPT ); Fri, 24 Jul 2020 12:23:15 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200724162312epoutp0114da21df7ff45e0c916d8c102034efc3~kvNU_R0LG1167511675epoutp01B for ; Fri, 24 Jul 2020 16:23:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200724162312epoutp0114da21df7ff45e0c916d8c102034efc3~kvNU_R0LG1167511675epoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595607792; bh=3/hObnOc9E+5ViVw9dw3TpFAV846dpgwS54UTPL/cw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iAYnurzXe1n9BOwoI5rbjOH3cfe1cT7XxpvXZh3qv11Sxidh9EcCHP6pklb2YTd6R s7RkhlApfPIzvKMBwKDrdh4OW6lOgHZskxnKbGQHBBKXRkREvb59R8f/EzUnMSeseT wULsLmPxkqZzRwgEpPlW2X/7MSPSBgiIlTOxuHhw= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20200724162310epcas5p2955a85236339220eef80c3dd7d31b83c~kvNTxP-Af2787827878epcas5p2i; Fri, 24 Jul 2020 16:23:10 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E3.58.09467.EEA0B1F5; Sat, 25 Jul 2020 01:23:10 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200724155324epcas5p18e1d3b4402d1e4a8eca87d0b56a3fa9b~kuzT5b_jF1547815478epcas5p1e; Fri, 24 Jul 2020 15:53:24 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200724155324epsmtrp2ac97110668ca8b26f68e5a7762bebd01~kuzT4mIS52867528675epsmtrp2Q; Fri, 24 Jul 2020 15:53:24 +0000 (GMT) X-AuditID: b6c32a49-a3fff700000024fb-11-5f1b0aee4672 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 68.02.08382.3F30B1F5; Sat, 25 Jul 2020 00:53:24 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200724155321epsmtip1282f16a93147d538ce36f0d2cea0002d~kuzROb9DX0159201592epsmtip1a; Fri, 24 Jul 2020 15:53:21 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: willy@infradead.org, hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, SelvaKumar S , Kanchan Joshi , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v4 2/6] fs: change ki_complete interface to support 64bit ret2 Date: Fri, 24 Jul 2020 21:19:18 +0530 Message-Id: <1595605762-17010-3-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDKsWRmVeSWpSXmKPExsWy7bCmuu47Lul4g08f1C1+T5/CajFn1TZG i9V3+9ksuv5tYbFobf/GZHF6wiImi3et51gsHt/5zG5x9P9bNosp05oYLTZ/72Cz2HtL22LP 3pMsFpd3zWGz2PZ7PrPFlSmLmC1e/zjJZnH+73FWi98/5rA5CHvsnHWX3WPzCi2Py2dLPTZ9 msTu0bdlFaPH501yHu0Hupk8Nj15yxTAEcVlk5Kak1mWWqRvl8CVsanxI3PBapWKS8emsDUw dst1MXJwSAiYSPyfrtDFyMUhJLCbUeLtwhnMEM4nRolba69COd8YJdav72HsYuQE62g//oMF xBYS2MsosfmVFETRZ0aJm20nmEHGsgloSlyYXApiigjYSOxcogJSwiywnFliQscPVpBeYYEA idMrXoDZLAKqEi96DoPN5xVwlpj1cSYbxC45iZvnOplBbE4BF4kLF+8yggySENjBITF/21eo IheJPY9eMEPYwhKvjm9hh7ClJD6/2wtVUyzx685RZojmDkaJ6w0zWSAS9hIX9/xlArmUGejo 9bv0IcKyElNPrWMCsZkF+CR6fz9hgojzSuyYB2MrStyb9JQVwhaXeDhjCZTtITH/zR0WSKBM Z5Q4v+UT2wRGuVkIKxYwMq5ilEwtKM5NTy02LTDMSy3XK07MLS7NS9dLzs/dxAhOUFqeOxjv Pvigd4iRiYPxEKMEB7OSCO+Kb1LxQrwpiZVVqUX58UWlOanFhxilOViUxHmVfpyJExJITyxJ zU5NLUgtgskycXBKNTBtytpZ1nb43c97XxZxWR/KKti6WvGT7Ls/C3OUfuepH5yy1TM2r+7E WuZAaWbOg443355sT3z759HSkup3zI1SRWr2ycJenToyClz2jNweBaZZtaoBskc5A+9z9jV/ ecd65d5ZK6tbBi02Cpk+Wm9284h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Y8d5nPD0nqieWvKhP+Gp+ 5MnCq381qy+oRsnriaaezqo8VVRlMGvS27T1U+xkIrr3qXFqHT6XrhydmHFpd7vm8vSJFSL3 C345C8lrZZ9g2y+mn/rmOP/BLPlTfgnOT6JaS7TubVu69M/6uRuVWIozEg21mIuKEwFpBBFV 8AIAAA== X-CMS-MailID: 20200724155324epcas5p18e1d3b4402d1e4a8eca87d0b56a3fa9b X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200724155324epcas5p18e1d3b4402d1e4a8eca87d0b56a3fa9b References: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: SelvaKumar S kiocb->ki_complete(...,long ret2) - change ret2 to long long. This becomes handy to return 64bit written-offset with appending write. Change callers using ki_complete prototype. Signed-off-by: SelvaKumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- drivers/block/loop.c | 2 +- drivers/nvme/target/io-cmd-file.c | 2 +- drivers/target/target_core_file.c | 2 +- fs/aio.c | 2 +- fs/io_uring.c | 4 ++-- fs/overlayfs/file.c | 2 +- include/linux/fs.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index c33bbbf..d41dcbd 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -512,7 +512,7 @@ static void lo_rw_aio_do_completion(struct loop_cmd *cmd) blk_mq_complete_request(rq); } -static void lo_rw_aio_complete(struct kiocb *iocb, long ret, long ret2) +static void lo_rw_aio_complete(struct kiocb *iocb, long ret, long long ret2) { struct loop_cmd *cmd = container_of(iocb, struct loop_cmd, iocb); diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c index 0abbefd..ae6e797 100644 --- a/drivers/nvme/target/io-cmd-file.c +++ b/drivers/nvme/target/io-cmd-file.c @@ -123,7 +123,7 @@ static ssize_t nvmet_file_submit_bvec(struct nvmet_req *req, loff_t pos, return call_iter(iocb, &iter); } -static void nvmet_file_io_done(struct kiocb *iocb, long ret, long ret2) +static void nvmet_file_io_done(struct kiocb *iocb, long ret, long long ret2) { struct nvmet_req *req = container_of(iocb, struct nvmet_req, f.iocb); u16 status = NVME_SC_SUCCESS; diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 7143d03..387756f2 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -243,7 +243,7 @@ struct target_core_file_cmd { struct kiocb iocb; }; -static void cmd_rw_aio_complete(struct kiocb *iocb, long ret, long ret2) +static void cmd_rw_aio_complete(struct kiocb *iocb, long ret, long long ret2) { struct target_core_file_cmd *cmd; diff --git a/fs/aio.c b/fs/aio.c index 7ecddc2..7218c8b 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1418,7 +1418,7 @@ static void aio_remove_iocb(struct aio_kiocb *iocb) spin_unlock_irqrestore(&ctx->ctx_lock, flags); } -static void aio_complete_rw(struct kiocb *kiocb, long res, long res2) +static void aio_complete_rw(struct kiocb *kiocb, long res, long long res2) { struct aio_kiocb *iocb = container_of(kiocb, struct aio_kiocb, rw); diff --git a/fs/io_uring.c b/fs/io_uring.c index 155f3d8..7809ab2 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1958,7 +1958,7 @@ static void io_complete_rw_common(struct kiocb *kiocb, long res) __io_cqring_add_event(req, res, cflags); } -static void io_complete_rw(struct kiocb *kiocb, long res, long res2) +static void io_complete_rw(struct kiocb *kiocb, long res, long long res2) { struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); @@ -1966,7 +1966,7 @@ static void io_complete_rw(struct kiocb *kiocb, long res, long res2) io_put_req(req); } -static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long res2) +static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long long res2) { struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 01820e6..614b834 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -268,7 +268,7 @@ static void ovl_aio_cleanup_handler(struct ovl_aio_req *aio_req) kmem_cache_free(ovl_aio_request_cachep, aio_req); } -static void ovl_aio_rw_complete(struct kiocb *iocb, long res, long res2) +static void ovl_aio_rw_complete(struct kiocb *iocb, long res, long long res2) { struct ovl_aio_req *aio_req = container_of(iocb, struct ovl_aio_req, iocb); diff --git a/include/linux/fs.h b/include/linux/fs.h index ef13df4..a6a5f41 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -327,7 +327,7 @@ struct kiocb { randomized_struct_fields_start loff_t ki_pos; - void (*ki_complete)(struct kiocb *iocb, long ret, long ret2); + void (*ki_complete)(struct kiocb *iocb, long ret, long long ret2); void *private; int ki_flags; u16 ki_hint; From patchwork Fri Jul 24 15:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11683739 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 6AE7113B6 for ; Fri, 24 Jul 2020 16:23:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B7EE206EB for ; Fri, 24 Jul 2020 16:23:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="RBaQ8Jv7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726852AbgGXQX3 (ORCPT ); Fri, 24 Jul 2020 12:23:29 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:59734 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726701AbgGXQX2 (ORCPT ); Fri, 24 Jul 2020 12:23:28 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200724162326epoutp0272e61b393c61eff8a224dd9310f9fe4b~kvNi4X28S1082110821epoutp02K for ; Fri, 24 Jul 2020 16:23:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200724162326epoutp0272e61b393c61eff8a224dd9310f9fe4b~kvNi4X28S1082110821epoutp02K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595607807; bh=xc9JvOoe3FCec3K3v2rO1C6IyF+36UYIKKZhwsGDQp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RBaQ8Jv7PYoipwAbpdSUV9hxaxSXI77ickTNAEtwsfFeB8jY6Y6kC2KSrsdKp0xUt igKQQdVj7GTj/xQqqmm4QM70WzofNXc49+gJreE181cz3wHU93coyNXcbQkg3Nwr7F 4e7Yc7ODESQq8oOCYmcDInh3sLL1qbq3E7rACuN8= Received: from epsmges5p3new.samsung.com (unknown [182.195.42.75]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20200724162326epcas5p20a8f7970a6a546d0acce3eabd72f4cdf~kvNiU3JHw2787827878epcas5p2z; Fri, 24 Jul 2020 16:23:26 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 7E.7B.09475.EFA0B1F5; Sat, 25 Jul 2020 01:23:26 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20200724155329epcas5p345ba6bad0b8fe18056bb4bcd26c10019~kuzYsjVlr1405014050epcas5p3t; Fri, 24 Jul 2020 15:53:29 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200724155329epsmtrp218904c25aa29bb8887fb44f9bbf1ec15~kuzYo8gB92867528675epsmtrp2V; Fri, 24 Jul 2020 15:53:29 +0000 (GMT) X-AuditID: b6c32a4b-39fff70000002503-a1-5f1b0afefb39 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 2A.02.08382.9F30B1F5; Sat, 25 Jul 2020 00:53:29 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200724155326epsmtip1a5c04dab3e98b550817addc8dc8141c6~kuzWCzzyY0434704347epsmtip17; Fri, 24 Jul 2020 15:53:26 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: willy@infradead.org, hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, SelvaKumar S , Kanchan Joshi , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v4 3/6] uio: return status with iov truncation Date: Fri, 24 Jul 2020 21:19:19 +0530 Message-Id: <1595605762-17010-4-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrLKsWRmVeSWpSXmKPExsWy7bCmpu4/Lul4gzNXBS1+T5/CajFn1TZG i9V3+9ksuv5tYbFobf/GZHF6wiImi3et51gsHt/5zG5x9P9bNosp05oYLTZ/72Cz2HtL22LP 3pMsFpd3zWGz2PZ7PrPFlSmLmC1e/zjJZnH+73FWi98/5rA5CHvsnHWX3WPzCi2Py2dLPTZ9 msTu0bdlFaPH501yHu0Hupk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gsHt/5zG5x9P9bNosp05oYLTZ/72Cz2HtL22LP 3pMsFpd3zWGz2PZ7PrPFlSmLmC1e/zjJZnH+73FWi98/5rA5CHvsnHWX3WPzCi2Py2dLPTZ9 msTu0bdlFaPH501yHu0Hupk8Nj15yxTAEcVlk5Kak1mWWqRvl8CV8exzN0vBV66KyR+3MTYw fuLoYuTkkBAwkVh2fSpjFyMXh5DAbkaJqVNXMkIkxCWar/1gh7CFJVb+e84OUfQRqOjdHKAi Dg42AU2JC5NLQWpEBBwkuo4/ZgKpYRbYziwx8+hcVpCEsICdxO1ZM9hAbBYBVYktX5vBhvIK OEvcmNLPCrFATuLmuU5mEJtTwEXiwsW7YPOFgGou/iifwMi3gJFhFaNkakFxbnpusWGBYV5q uV5xYm5xaV66XnJ+7iZGcBRoae5g3L7qg94hRiYOxkOMEhzMSiK8K75JxQvxpiRWVqUW5ccX leakFh9ilOZgURLnvVG4ME5IID2xJDU7NbUgtQgmy8TBKdXAtHaSecW85y8um2yRMzLV3fPZ om6NT1/3Ir8N9/sa9wsU9vr8LG+Ob+/ru/l3oUH8nV3J+Y13POXdr+XuOxWhwfHchKGA31Ly m2rZzPdTz9uEy/4TiXksyxbauszj6qZ1k3e77/TZvZv9yYtDCz9tefnOYZP67zUvEusEDnQv MP/5mXsnjzb3pyxnng3Oy5TrTR7zrOqvsZgSy3vq38z/3Gu8ZN3ZD/+vZGW4m1pU/WJpMOdk 2VfS7nr5Z9vjlKuMBLbqRy7eVPVbquxeI1+72s97DbMDK+6fTjycF7nm6exu018Ge60iNPvu xj0L8p00Pdc4s1qbcVt1mPb8s29nm7EcWjZX+v+v4I3pR/d9VWIpzkg01GIuKk4EAK7A5s/x AgAA X-CMS-MailID: 20200724155329epcas5p345ba6bad0b8fe18056bb4bcd26c10019 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200724155329epcas5p345ba6bad0b8fe18056bb4bcd26c10019 References: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: SelvaKumar S Make iov_iter_truncate to report whether it actually truncated. This helps callers which want to process the iov_iter in its entirety. Signed-off-by: SelvaKumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- include/linux/uio.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/linux/uio.h b/include/linux/uio.h index 9576fd8..c681a60 100644 --- a/include/linux/uio.h +++ b/include/linux/uio.h @@ -241,7 +241,7 @@ static inline size_t iov_iter_count(const struct iov_iter *i) * greater than the amount of data in iov_iter is fine - it'll just do * nothing in that case. */ -static inline void iov_iter_truncate(struct iov_iter *i, u64 count) +static inline bool iov_iter_truncate(struct iov_iter *i, u64 count) { /* * count doesn't have to fit in size_t - comparison extends both @@ -249,8 +249,11 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count) * conversion in assignement is by definition greater than all * values of size_t, including old i->count. */ - if (i->count > count) + if (i->count > count) { i->count = count; + return true; + } + return false; } /* From patchwork Fri Jul 24 15:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11683745 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 618A3913 for ; Fri, 24 Jul 2020 16:23:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 443FB206F6 for ; Fri, 24 Jul 2020 16:23:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="AxLzTI+0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726895AbgGXQXv (ORCPT ); Fri, 24 Jul 2020 12:23:51 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:11100 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgGXQXs (ORCPT ); Fri, 24 Jul 2020 12:23:48 -0400 Received: from epcas5p3.samsung.com (unknown [182.195.41.41]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200724162345epoutp034e12fa1df0c1cd6bec2d00f557b22215~kvNzuC1wi0333203332epoutp03S for ; Fri, 24 Jul 2020 16:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200724162345epoutp034e12fa1df0c1cd6bec2d00f557b22215~kvNzuC1wi0333203332epoutp03S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595607825; bh=9BUQg2MABIlQJWC0nt7qshMzg+pFZbAyE/T4bNQe5QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AxLzTI+0UUso4K7CftSf1XMuGftujRguR+MuKKt4NxOV4bMhQtwKI96jXh1Ot7Jwe qZtzXQDqKNgUrwY8nGBgjoFQTCSRbUuQZ6PGrbIzNyZkcGMOPtaWaL/LISTl4NZIEu WwhRXHE3fo+35vxHbz7CM3i5VBr6q5/G1xdYuLZE= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20200724162344epcas5p4d5cbb0a523c0df4f882569bffb230255~kvNy_-ynz1123011230epcas5p4h; Fri, 24 Jul 2020 16:23:44 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E9.58.09467.01B0B1F5; Sat, 25 Jul 2020 01:23:44 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200724155341epcas5p15bfc55927f2abb60f19784270fe8e377~kuzj1c3I61092810928epcas5p12; Fri, 24 Jul 2020 15:53:41 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200724155341epsmtrp222b7665f8f31eee093e888402a2b0f2b~kuzj0h8TD2867528675epsmtrp2W; Fri, 24 Jul 2020 15:53:41 +0000 (GMT) X-AuditID: b6c32a49-a3fff700000024fb-3d-5f1b0b10bacc Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6B.02.08382.5040B1F5; Sat, 25 Jul 2020 00:53:41 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200724155338epsmtip190d9121f4f0c9f6cc016e84f579484d3~kuzhG99OH0434604346epsmtip15; Fri, 24 Jul 2020 15:53:38 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: willy@infradead.org, hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, Kanchan Joshi , Selvakumar S , Nitesh Shetty , Arnav Dawn , Javier Gonzalez Subject: [PATCH v4 4/6] block: add zone append handling for direct I/O path Date: Fri, 24 Jul 2020 21:19:20 +0530 Message-Id: <1595605762-17010-5-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0WSe0wTWRTG985MpwNuN2NBvYtSY4MvVlBRk5uoK0Y0o0aDGhODUWxgliqU QgcUMRhASUsRxVIsEHyhRqhBTUVULK4LASLIo2J8gCBQiWSFaqBWllJYx9H43+9+57vfOefm Uri0XORHHYx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nrILMWRmVeSWpSXmKPExsWy7bCSnC4ri3S8wf0PPBa/tz1isfg9fQqr xZxV2xgtVt/tZ7Po+reFxaK1/RuTxekJi5gs3rWeY7F4fOczu8XR/2/ZLKZMa2K02Py9g81i 7y1tiz17T7JYXN41h81i2+/5zBZXpixitnj94ySbxfm/x1ktfv+Yw+Yg4rFz1l12j80rtDwu ny312PRpErtH35ZVjB6fN8l5tB/oZvLY9OQtUwBHFJdNSmpOZllqkb5dAlfGwq9vmQsu6FWs ajzH1sB4RbWLkZNDQsBE4mHzFCYQW0hgN6PEgj1yEHFxieZrP9ghbGGJlf+es0PUfGSUmLJI qYuRg4NNQFPiwuRSkLCIgINE1/HHQGO4OJgFbjFLPFrbwwaSEBbwlnh/roMFxGYRUJVY+Xcl 2C5eAWeJg92TGCHmy0ncPNfJDGJzCrhIXLh4lxFkvhBQzcUf5RMY+RYwMqxilEwtKM5Nzy02 LDDMSy3XK07MLS7NS9dLzs/dxAiOBS3NHYzbV33QO8TIxMF4iFGCg1lJhHfFN6l4Id6UxMqq 1KL8+KLSnNTiQ4zSHCxK4rw3ChfGCQmkJ5akZqemFqQWwWSZODilGpimCDh4WIV7HryzPeu9 xs5bJU/N5xXk37qed+jHBY+9rIulFR1XPhTKezH99FFplcmaWw8uvBqRLXDY5lT/YW7RI5er w86v32+TerP8ZKnhn3upuvdZvzF8urMp99urGoWkbsHyQ+xCHEKvxPP6WBgFnTMTzFOXhVdL xrqf777V5mXU1Mki+uRO65xLrhy+fRft9tu9m7cucWsti+BBbWWt3tU+2it2yu9ezr1nsoV7 UcGFO66LnJKl5TIldZyln2xfx6Ke9+/LIudN200rxEwj+6c9nPhI0/Q/H8OWrbEvNlgE99V/ E7Sd9Iz9xdv3AVtuFr1wcDtQpvJ8YajN3w01Ri9fzP9Q9e7bei+1ieeVWIozEg21mIuKEwFX wT7b9AIAAA== X-CMS-MailID: 20200724155341epcas5p15bfc55927f2abb60f19784270fe8e377 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200724155341epcas5p15bfc55927f2abb60f19784270fe8e377 References: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org For zoned block device, opt in for 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 written-offset, in bytes, to upper layer via ret2 of kiocb->ki_complete interface. Write with the flag IOCB_ZONE_APPEND are ensured not be be short. Prevent short write and instead return failure if appending write spans beyond end of device. Return failure if write is larger than max_append_limit and therefore requires formation of multiple bios. Signed-off-by: Kanchan Joshi Signed-off-by: Selvakumar S Signed-off-by: Nitesh Shetty Signed-off-by: Arnav Dawn Signed-off-by: Javier Gonzalez --- fs/block_dev.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 47860e5..3b5836b 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,14 @@ static int blkdev_iopoll(struct kiocb *kiocb, bool wait) return blk_poll(q, READ_ONCE(kiocb->ki_cookie), wait); } +static inline long long blkdev_bio_ret2(struct kiocb *iocb, struct bio *bio) +{ + /* return written-offset for zone append in bytes */ + if (op_is_write(bio_op(bio)) && iocb->ki_flags & IOCB_ZONE_APPEND) + return bio->bi_iter.bi_sector << SECTOR_SHIFT; + return 0; +} + static void blkdev_bio_end_io(struct bio *bio) { struct blkdev_dio *dio = bio->bi_private; @@ -307,15 +324,17 @@ static void blkdev_bio_end_io(struct bio *bio) if (!dio->is_sync) { struct kiocb *iocb = dio->iocb; ssize_t ret; + long long ret2; if (likely(!dio->bio.bi_status)) { ret = dio->size; iocb->ki_pos += ret; + ret2 = blkdev_bio_ret2(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, ret2); if (dio->multi_bio) bio_put(&dio->bio); } else { @@ -382,6 +401,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 +411,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 +437,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 +1865,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 +1891,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) @@ -2017,7 +2046,9 @@ ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) if ((iocb->ki_flags & (IOCB_NOWAIT | IOCB_DIRECT)) == IOCB_NOWAIT) return -EOPNOTSUPP; - iov_iter_truncate(from, size - iocb->ki_pos); + if (iov_iter_truncate(from, size - iocb->ki_pos) && + (iocb->ki_flags & IOCB_ZONE_APPEND)) + return -ENOSPC; blk_start_plug(&plug); ret = __generic_file_write_iter(iocb, from); From patchwork Fri Jul 24 15:49:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11683747 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 473C8913 for ; Fri, 24 Jul 2020 16:24:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25ABC206EB for ; Fri, 24 Jul 2020 16:24:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="NwpGOYFV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726821AbgGXQX7 (ORCPT ); Fri, 24 Jul 2020 12:23:59 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:11917 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726326AbgGXQX7 (ORCPT ); Fri, 24 Jul 2020 12:23:59 -0400 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200724162357epoutp010154f4d02021c97b8aec5e1ffc3f06ab~kvN_4MrwX1639216392epoutp01U for ; Fri, 24 Jul 2020 16:23:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200724162357epoutp010154f4d02021c97b8aec5e1ffc3f06ab~kvN_4MrwX1639216392epoutp01U DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595607837; bh=+K/IUmUogGLkZXpodowxoJ/FLK3QQNBHyElRvdThP3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NwpGOYFVSun6Onz/lxGDkmIzLhwN8dpbvVUU5XEFBXCaE/CCVz/eWhtKiCtf3VHT7 q9pwCtM5y5Ap7RaGOnVLh+z6YmZ8VExcMBLtjO3kiA2oSNwwbGTBm4CqbZhzDmlBpF 6Iz7J7QV6YqvipOJjqTvOzvDh8LK2kiLZw6GN9Mc= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200724162355epcas5p14c10449e6256a8ac7315a7916be62e96~kvN9y9akW0808308083epcas5p12; Fri, 24 Jul 2020 16:23:55 +0000 (GMT) Received: from epcas5p3.samsung.com ( [182.195.41.41]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 2F.CE.40333.B1B0B1F5; Sat, 25 Jul 2020 01:23:55 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20200724155346epcas5p2cfb383fe9904a45280c6145f4c13e1b4~kuzoV0vvb0555205552epcas5p2Z; Fri, 24 Jul 2020 15:53:46 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200724155346epsmtrp2e1e45c2609438de6fb93596d26e21103~kuzoU-y1f3047030470epsmtrp2C; Fri, 24 Jul 2020 15:53:46 +0000 (GMT) X-AuditID: b6c32a4a-9a7ff70000019d8d-86-5f1b0b1be864 Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 9A.A9.08303.9040B1F5; Sat, 25 Jul 2020 00:53:45 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200724155343epsmtip141811e600c138774385c1799ffec5e05~kuzlsG1Sv0293902939epsmtip1w; Fri, 24 Jul 2020 15:53:43 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: willy@infradead.org, hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, Kanchan Joshi , Selvakumar S , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v4 5/6] block: enable zone-append for iov_iter of bvec type Date: Fri, 24 Jul 2020 21:19:21 +0530 Message-Id: <1595605762-17010-6-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBKsWRmVeSWpSXmKPExsWy7bCmpq40t3S8wfKfhha/p09htZizahuj xeq7/WwWXf+2sFi0tn9jsjg9YRGTxbvWcywWj+98Zrc4+v8tm8WUaU2MFpu/d7BZ7L2lbbFn 70kWi8u75rBZbPs9n9niypRFzBavf5xkszj/9zirxe8fc9gchD12zrrL7rF5hZbH5bOlHps+ TWL36NuyitHj8yY5j/YD3Uwem568ZQrgiOKySUnNySxLLdK3S+DK+HB2KXPBC4GKRTd/sDUw vuftYuTkkBAwkdi+7jVbFyMXh5DAbkaJ+4fuMkE4nxglXh68CJX5zCgx7/J5ZpiWbz2zoap2 MUrMnDWLBSQBVrXwh18XIwcHm4CmxIXJpSCmiICNxM4lKiAVzALLmSXWrwXbLCzgLTH/VjMz SAmLgKrEpG5hkDCvgLPEzAk7mCA2yUncPNcJtpVTwEXiwsW7jBDxLRwSCzc5gLRKAMU3feaH CAtLvDq+hR3ClpL4/G4vG4RdLPHrzlFmkIMlBDoYJa43zGSBSNhLXNzzlwlkDjPQwet36UOE ZSWmnlrHBHExn0Tv7ydQ5/BK7JgHYytK3Jv0lBXCFpd4OGMJlO0h0XfiOCMkPKYDQ+2t+ARG uVkIGxYwMq5ilEwtKM5NTy02LTDKSy3XK07MLS7NS9dLzs/dxAhOTFpeOxgfPvigd4iRiYPx EKMEB7OSCO+Kb1LxQrwpiZVVqUX58UWlOanFhxilOViUxHmVfpyJExJITyxJzU5NLUgtgsky cXBKNTC1HdPoXGhY+Yr1zPUWX45nXfkhwRr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U5EnL3E0mXL F5OZeVksUy6oHSxL1LnUcmjeJNPI99wt63S1JPNCrk6e/f5qkKjsts17ZU02PrX8+uVBTGXg cb9d8rKBDgd46l2+Xo5bdfHVHBGBbwkduoE6KxJUna1blaZv+3S2bc2T2lN1Z6QXh9dxydyx 3SZhxPCCy5HPbVX338SYkpiGkEDTKDmBx7sK9sn3ClrOCl05+farFb80JMLUPqbYyibcnGlS UbjP/oDm0iBVoUyFUp0mjRteT098YX+R7Gpz9O4GixK21JNKLMUZiYZazEXFiQA38RbV7wIA AA== X-CMS-MailID: 20200724155346epcas5p2cfb383fe9904a45280c6145f4c13e1b4 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200724155346epcas5p2cfb383fe9904a45280c6145f4c13e1b4 References: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Fri Jul 24 15:49:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kanchan Joshi X-Patchwork-Id: 11683753 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 DF10B913 for ; Fri, 24 Jul 2020 16:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BDFB9206EB for ; Fri, 24 Jul 2020 16:24:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Yg+zRx2V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727045AbgGXQYJ (ORCPT ); Fri, 24 Jul 2020 12:24:09 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:11255 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726676AbgGXQYI (ORCPT ); Fri, 24 Jul 2020 12:24:08 -0400 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20200724162405epoutp03af065d78fe5f8e170a748959474ca45b~kvOGnHEhV0333203332epoutp03a for ; Fri, 24 Jul 2020 16:24:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20200724162405epoutp03af065d78fe5f8e170a748959474ca45b~kvOGnHEhV0333203332epoutp03a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1595607845; bh=KeFwOYrInKU609vftU4EN0rxqpWu0rMpyqf8XT/yacE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yg+zRx2VZbjcjICwEdV2cNmHtRMLHRygm2F6nzcL2xcqceT3HGdrpxLkRdAlU/SJZ bZzbNv/nyVibEkqKXU/U7Cbidd+PxC8lf3t7AaV+pKnvG4tdPU4R3YAKo0hWoCm4my YqQEtWzUb0f8N7t+YCR7+utqFyH1vyw9k9dVTBPM= Received: from epsmges5p2new.samsung.com (unknown [182.195.42.74]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20200724162404epcas5p21d4420cd725d79755515dce085c47495~kvOGFwfgZ0166301663epcas5p2l; Fri, 24 Jul 2020 16:24:04 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p2new.samsung.com (Symantec Messaging Gateway) with SMTP id F0.DE.40333.42B0B1F5; Sat, 25 Jul 2020 01:24:04 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20200724155350epcas5p3b8f1d59eda7f8fbb38c828f692d42fd6~kuzsaFGFN2159221592epcas5p3p; Fri, 24 Jul 2020 15:53:50 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200724155350epsmtrp2568e442acbfa8216b95a7bd6d4fffab5~kuzsZNZ2Z3047030470epsmtrp2I; Fri, 24 Jul 2020 15:53:50 +0000 (GMT) X-AuditID: b6c32a4a-991ff70000019d8d-93-5f1b0b24a73d Received: from epsmtip1.samsung.com ( [182.195.34.30]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.02.08382.E040B1F5; Sat, 25 Jul 2020 00:53:50 +0900 (KST) Received: from localhost.localdomain (unknown [107.110.206.5]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200724155347epsmtip1888a12b2f1b4a91068b9c468f211fa2f~kuzpxyPVc0513905139epsmtip15; Fri, 24 Jul 2020 15:53:47 +0000 (GMT) From: Kanchan Joshi To: axboe@kernel.dk, viro@zeniv.linux.org.uk, bcrl@kvack.org Cc: willy@infradead.org, hch@infradead.org, Damien.LeMoal@wdc.com, asml.silence@gmail.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-aio@kvack.org, io-uring@vger.kernel.org, linux-block@vger.kernel.org, linux-api@vger.kernel.org, SelvaKumar S , Kanchan Joshi , Nitesh Shetty , Javier Gonzalez Subject: [PATCH v4 6/6] io_uring: add support for zone-append Date: Fri, 24 Jul 2020 21:19:22 +0530 Message-Id: <1595605762-17010-7-git-send-email-joshi.k@samsung.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDKsWRmVeSWpSXmKPExsWy7bCmuq4Kt3S8weNebYvf06ewWsxZtY3R YvXdfjaLrn9bWCxa278xWZyesIjJ4l3rORaLx3c+s1sc/f+WzWLKtCZGi83fO9gs9t7Sttiz 9ySLxeVdc9gstv2ez2xxZcoiZovXP06yWZz/e5zV4vePOWwOwh47Z91l99i8Qsvj8tlSj02f JrF79G1ZxejxeZOcR/uBbiaPTU/eMgVwRHHZpKTmZJalFunbJXBl3Pn5iK3giHbFts2XmRoY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Fn 70kWi8u75rBZbPs9n9niypRFzBavf5xkszj/9zirxe8fc9gchD12zrrL7rF5hZbH5bOlHps+ TWL36NuyitHj8yY5j/YD3Uwem568ZQrgiOKySUnNySxLLdK3S+DKuPPzEVvBEe2KbZsvMzUw zlPuYuTkkBAwkVi26SlrFyMXh5DAbkaJk+/eM0EkxCWar/1gh7CFJVb+e84OUfSRUWL/3knM XYwcHGwCmhIXJpeC1IgIOEh0HX/MBFLDLLCdWWLm0bmsIAlhAVuJ0196WEDqWQRUJVY8DAEJ 8wo4S7T/2sMIMV9O4ua5TmYQm1PAReLCxbuMIOVCQDUXf5RPYORbwMiwilEytaA4Nz232LDA MC+1XK84Mbe4NC9dLzk/dxMjOAa0NHcwbl/1Qe8QIxMH4yFGCQ5mJRHeFd+k4oV4UxIrq1KL 8uOLSnNSiw8xSnOwKInz3ihcGCckkJ5YkpqdmlqQWgSTZeLglGpgkjmXmh3W+66Lw/DZQh7P m2sce9frr56q9OTjryaV2R9f/jlrkVpRmlDgJzePWcm8ZY+xLT+P+raqOwsU99cv06tjPyNj MSvE9rZV1Npr5Y48KwXZ7l3UkOLuULb705yS/0naOLqxkstBXNRx/9FD7K7eubpTNvy7YSVR wWZqYZ0Y2Ru388GnN12xwhWawRLqJWsk5tx+lzvbzcK1qWhOxD7rbC3l2cx5C/76PwmPMJo1 UUIjyGR6nnrJyc5TPWonAs9f0F4eyKH2KERzdcZ89gs6W6QUOS59PlixYNL3A6EH9QrKpf5t aC5JPM/AeahYxWgaR/OtJ4llh9W2TE35MM3E1PBYnZ1S98eHi5VYijMSDbWYi4oTAeU0e+Tw AgAA X-CMS-MailID: 20200724155350epcas5p3b8f1d59eda7f8fbb38c828f692d42fd6 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P X-CMS-RootMailID: 20200724155350epcas5p3b8f1d59eda7f8fbb38c828f692d42fd6 References: <1595605762-17010-1-git-send-email-joshi.k@samsung.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: SelvaKumar S Repurpose [cqe->res, cqe->flags] into cqe->res64 (signed) to report 64bit written-offset for zone-append. The appending-write which requires reporting written-location (conveyed by IOCB_ZONE_APPEND flag) is ensured not to be a short-write; this avoids the need to report number-of-bytes-copied. append-offset is returned by lower-layer to io-uring via ret2 of ki_complete interface. Make changes to collect it and send to user-space via cqe->res64. Signed-off-by: SelvaKumar S Signed-off-by: Kanchan Joshi Signed-off-by: Nitesh Shetty Signed-off-by: Javier Gonzalez --- fs/io_uring.c | 49 ++++++++++++++++++++++++++++++++++++------- include/uapi/linux/io_uring.h | 9 ++++++-- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 7809ab2..6510cf5 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -401,7 +401,14 @@ struct io_rw { /* NOTE: kiocb has the file as the first member, so don't do it here */ struct kiocb kiocb; u64 addr; - u64 len; + union { + /* + * len is used only during submission. + * append_offset is used only during completion. + */ + u64 len; + u64 append_offset; + }; }; struct io_connect { @@ -541,6 +548,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 +606,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 append offset */ + REQ_F_ZONE_APPEND = BIT(REQ_F_ZONE_APPEND_BIT), }; struct async_poll { @@ -1244,8 +1254,15 @@ static bool io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool force) req->flags &= ~REQ_F_OVERFLOW; if (cqe) { WRITE_ONCE(cqe->user_data, req->user_data); - WRITE_ONCE(cqe->res, req->result); - WRITE_ONCE(cqe->flags, req->cflags); + if (unlikely(req->flags & REQ_F_ZONE_APPEND)) { + if (likely(req->result > 0)) + WRITE_ONCE(cqe->res64, req->rw.append_offset); + else + WRITE_ONCE(cqe->res64, req->result); + } else { + WRITE_ONCE(cqe->res, req->result); + WRITE_ONCE(cqe->flags, req->cflags); + } } else { WRITE_ONCE(ctx->rings->cq_overflow, atomic_inc_return(&ctx->cached_cq_overflow)); @@ -1284,8 +1301,15 @@ static void __io_cqring_fill_event(struct io_kiocb *req, long res, long cflags) cqe = io_get_cqring(ctx); if (likely(cqe)) { WRITE_ONCE(cqe->user_data, req->user_data); - WRITE_ONCE(cqe->res, res); - WRITE_ONCE(cqe->flags, cflags); + if (unlikely(req->flags & REQ_F_ZONE_APPEND)) { + if (likely(res > 0)) + WRITE_ONCE(cqe->res64, req->rw.append_offset); + else + WRITE_ONCE(cqe->res64, res); + } else { + WRITE_ONCE(cqe->res, res); + WRITE_ONCE(cqe->flags, cflags); + } } else if (ctx->cq_overflow_flushed) { WRITE_ONCE(ctx->rings->cq_overflow, atomic_inc_return(&ctx->cached_cq_overflow)); @@ -1943,7 +1967,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 long res2) { struct io_kiocb *req = container_of(kiocb, struct io_kiocb, rw.kiocb); int cflags = 0; @@ -1955,6 +1979,9 @@ 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); + if (req->flags & REQ_F_ZONE_APPEND) + req->rw.append_offset = res2; + __io_cqring_add_event(req, res, cflags); } @@ -1962,7 +1989,7 @@ static void io_complete_rw(struct kiocb *kiocb, long res, long 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); } @@ -1976,8 +2003,11 @@ static void io_complete_rw_iopoll(struct kiocb *kiocb, long res, long long res2) if (res != req->result) req_set_fail_links(req); req->result = res; - if (res != -EAGAIN) + if (res != -EAGAIN) { + if (req->flags & REQ_F_ZONE_APPEND) + req->rw.append_offset = res2; WRITE_ONCE(req->iopoll_completed, 1); + } } /* @@ -2739,6 +2769,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; diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h index 92c2269..2580d93 100644 --- a/include/uapi/linux/io_uring.h +++ b/include/uapi/linux/io_uring.h @@ -156,8 +156,13 @@ enum { */ struct io_uring_cqe { __u64 user_data; /* sqe->data submission passed back */ - __s32 res; /* result code for this event */ - __u32 flags; + union { + struct { + __s32 res; /* result code for this event */ + __u32 flags; + }; + __s64 res64; /* appending offset for zone append */ + }; }; /*