{"id":2226020,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2226020/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260422021042.4157510-20-yi.zhang@huaweicloud.com/","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.2/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260422021042.4157510-20-yi.zhang@huaweicloud.com>","list_archive_url":null,"date":"2026-04-22T02:10:39","name":"[v3,19/22] ext4: submit zeroed post-EOF data immediately in the iomap buffered I/O path","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"1de830d5a1517b36a1a8df1c058f6ef11e34bc5c","submitter":{"id":85428,"url":"http://patchwork.ozlabs.org/api/1.2/people/85428/?format=json","name":"Zhang Yi","email":"yi.zhang@huaweicloud.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/20260422021042.4157510-20-yi.zhang@huaweicloud.com/mbox/","series":[{"id":500911,"url":"http://patchwork.ozlabs.org/api/1.2/series/500911/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-ext4/list/?series=500911","date":"2026-04-22T02:10:23","name":"ext4: use iomap for regular file's buffered I/O path","version":3,"mbox":"http://patchwork.ozlabs.org/series/500911/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2226020/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2226020/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <SRS0=wqXB=CV=vger.kernel.org=linux-ext4+bounces-15978-patchwork-incoming=ozlabs.org@ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-ext4@vger.kernel.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","patchwork-incoming@ozlabs.org"],"Authentication-Results":["legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org\n (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org;\n envelope-from=srs0=wqxb=cv=vger.kernel.org=linux-ext4+bounces-15978-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)","gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c0a:e001:db::12fc:5321\"\n arc.chain=subspace.kernel.org","gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com","gandalf.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15978-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org)","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=45.249.212.51","smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=huaweicloud.com"],"Received":["from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0jhM4qlsz1yD5\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:23:47 +1000 (AEST)","from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4g0jhM4Psjz4w1l\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 12:23:47 +1000 (AEST)","by gandalf.ozlabs.org (Postfix)\n\tid 4g0jhM4MGWz4wKJ; Wed, 22 Apr 2026 12:23:47 +1000 (AEST)","from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby gandalf.ozlabs.org (Postfix) with ESMTPS id 4g0jhJ1JmWz4w1l\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 22 Apr 2026 12:23:44 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 8247D30B5B9B\n\tfor <patchwork-incoming@ozlabs.org>; Wed, 22 Apr 2026 02:17:54 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id EA11036405C;\n\tWed, 22 Apr 2026 02:17:07 +0000 (UTC)","from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com\n [45.249.212.51])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 596B43537D2;\n\tWed, 22 Apr 2026 02:17:04 +0000 (UTC)","from mail.maildlp.com (unknown [172.19.163.198])\n\tby dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4g0jWN1YmtzYQts7;\n\tWed, 22 Apr 2026 10:16:00 +0800 (CST)","from mail02.huawei.com (unknown [10.116.40.252])\n\tby mail.maildlp.com (Postfix) with ESMTP id 677A540609;\n\tWed, 22 Apr 2026 10:16:57 +0800 (CST)","from huaweicloud.com (unknown [10.50.85.155])\n\tby APP3 (Coremail) with SMTP id _Ch0CgB3JL6PL+hpqkgUBQ--.2635S23;\n\tWed, 22 Apr 2026 10:16:57 +0800 (CST)"],"ARC-Seal":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1776824627; cv=pass;\n\tb=SY6Ky/pogcBGcV0otQu9jFEz5LBRYEuIQAhCOa22+ocqMczAlP/h/4Q39OPBGrPjuzDVp2VcnbmdmsQRzWubwIKjDh6O0osFodEbxNbzarMEJicXK6fa8uH0E1OqdB84X7eizqoKSJOD5Yf+nlg8S3MQOTpzuzWBpmYNPMyu7UkQCOuI57kRysFcyLEdWT/+m2YnucyZwQ09MsAzOvfDyyOB2vd/qazmCoHJNyB0jampkAtbsinYF97993cegWqv/ig2OioLcntk2QeZH9AvzSDpuwvwCSSfW6pgRZjZG4GcxRDgRj5hubVqK9qEenbEaUY8JT05MLQPoOpC4Nq5VQ==","i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776824227; cv=none;\n b=TWrdYo7IJE/MAsRUOJzNceIJz5qz5kMdPMiVLUoyfqd5JRbIyCoYi3jKjG1xEqSCQ49IpPwNEhbHZbMOYZ/0v/RrChJymDxwSaE2ahSY9vGNktujOy0pOtYA9SrFvgrBgpHYOWjo4XOHqpVv/Y99ZYJw6RliRUmR2BvdSpxLaKY="],"ARC-Message-Signature":["i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1776824627; c=relaxed/relaxed;\n\tbh=x9hwU2CSagfmq7b9uXxPXwhcsQQLONXmtu9J3V7zLlc=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=l1RLg6ZCzCJUFVQ/qG1BW2bctPxbBD+nwy/aeAMSP5aYjGTnSXXLCUb1+RVALYrfvxm4ICYfTdgFxldB7vx6kGaPIix+5TQGae+m954fLm7iKdkfsxjoXPcbMe+ZzNh70W1z2CXJmc+7ps5U+XhsPa78v8qa1jNQYIWgu31lyDCAbFfWGS18Y6uXYcRtODA5wz2D+WX4PCNGec6/NSUt95thw5vHaLXBj8zM54Nh+sNT2Na1gF4ATI82RqUCVnybY3HIF4kmaOLAWTDhOY5J9zs943Fm7bxbj6p7iW2uG3FezD0keCTz6DoKsfMLHQLIycF7IPsfExZFGIWZAl4Ulw==","i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776824227; c=relaxed/simple;\n\tbh=YXZHG7P9OY/dRX5x+8FscTuosfa5/dTxnRRQxgnAInY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=H85vH6KuXpCQzZN4o7I2zmIhl6QjlOPpe1Opg6Q7W1rcHNj5yzmsiTWUyB9vYGBbb2FFnAUiSdylLNFCC3WRRRF07z1CZVo8W4YEoR+KK5J6qo5OFCS/xt4RioLlhygHMbRULDTWOu5cGCL/iLzpTB73HAgluyLpj5V5bYisdQQ="],"ARC-Authentication-Results":["i=2; gandalf.ozlabs.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com;\n spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15978-patchwork-incoming=ozlabs.org@vger.kernel.org;\n receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org","i=1; smtp.subspace.kernel.org;\n dmarc=none (p=none dis=none) header.from=huaweicloud.com;\n spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51"],"From":"Zhang Yi <yi.zhang@huaweicloud.com>","To":"linux-ext4@vger.kernel.org,\n\tlinux-fsdevel@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org,\n\ttytso@mit.edu,\n\tadilger.kernel@dilger.ca,\n\tlibaokun@linux.alibaba.com,\n\tjack@suse.cz,\n\tojaswin@linux.ibm.com,\n\tritesh.list@gmail.com,\n\tdjwong@kernel.org,\n\thch@infradead.org,\n\tyi.zhang@huawei.com,\n\tyi.zhang@huaweicloud.com,\n\tyizhang089@gmail.com,\n\tyangerkun@huawei.com,\n\tyukuai@fnnas.com","Subject":"[PATCH v3 19/22] ext4: submit zeroed post-EOF data immediately in the\n iomap buffered I/O path","Date":"Wed, 22 Apr 2026 10:10:39 +0800","Message-ID":"<20260422021042.4157510-20-yi.zhang@huaweicloud.com>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20260422021042.4157510-1-yi.zhang@huaweicloud.com>","References":"<20260422021042.4157510-1-yi.zhang@huaweicloud.com>","Precedence":"bulk","X-Mailing-List":"linux-ext4@vger.kernel.org","List-Id":"<linux-ext4.vger.kernel.org>","List-Subscribe":"<mailto:linux-ext4+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-ext4+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-CM-TRANSID":"_Ch0CgB3JL6PL+hpqkgUBQ--.2635S23","X-Coremail-Antispam":"1UD129KBjvJXoWxuF1UKr1rKr1fAry8uFyUJrb_yoW5ZrWxpr\n\tW3Kw1rAw4q9F9F9r4SqF17Xr1aka1rGw48GFWxWr40vay3X3WrKFy2k34rAFWUtr45Way2\n\tqF45JFWDWF1UArJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0\n\trVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI\n\tkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2\n\tz4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F\n\t4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq\n\t3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7\n\tIYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U\n\tM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2\n\tkIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE\n\tbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67\n\tAF67kF1VAFwI0_GFv_WrylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI\n\t42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF\n\t4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI\n\tdaVFxhVjvjDU0xZFpf9x0JUWMKtUUUUU=","X-CM-SenderInfo":"d1lo6xhdqjqx5xdzvxpfor3voofrz/","X-Spam-Status":"No, score=-1.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,\n\tDMARC_MISSING,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,\n\tSPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org"},"content":"From: Zhang Yi <yi.zhang@huawei.com>\n\nIn the generic buffered_head I/O path, we rely on the data=order mode to\nensure that the zeroed EOF block data is written before updating\ni_disksize, thus preventing stale data from being exposed.\n\nHowever, the iomap buffered I/O path cannot use this mechanism. Instead,\nwe issue the I/O immediately after performing the zero operation\n(without synchronous waiting). This can reduce the risk of exposing\nstale data, but it does not guarantee that the zero data will be flushed\nto disk before the metadata of i_disksize is updated. The subsequent\npatches will wait for this I/O to complete before updating i_disksize.\n\nSuggested-by: Jan Kara <jack@suse.cz>\nSigned-off-by: Zhang Yi <yi.zhang@huawei.com>\n---\n fs/ext4/inode.c | 58 +++++++++++++++++++++++++++++++++++++++----------\n 1 file changed, 47 insertions(+), 11 deletions(-)","diff":"diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\nindex d2f7af7922d7..d55899c1ef4c 100644\n--- a/fs/ext4/inode.c\n+++ b/fs/ext4/inode.c\n@@ -4766,8 +4766,10 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end)\n \tif (IS_ENCRYPTED(inode) && !fscrypt_has_encryption_key(inode))\n \t\treturn 0;\n \n-\tif (length > blocksize - offset)\n+\tif (length > blocksize - offset) {\n \t\tlength = blocksize - offset;\n+\t\tend = from + length;\n+\t}\n \n \terr = ext4_block_zero_range(inode, from, length,\n \t\t\t\t    &did_zero, &zero_written);\n@@ -4782,18 +4784,52 @@ int ext4_block_zero_eof(struct inode *inode, loff_t from, loff_t end)\n \t * TODO: In the iomap path, handle this by updating i_disksize to\n \t * i_size after the zeroed data has been written back.\n \t */\n-\tif (ext4_should_order_data(inode) &&\n-\t    did_zero && zero_written && !IS_DAX(inode)) {\n-\t\thandle_t *handle;\n+\tif (did_zero && zero_written && !IS_DAX(inode)) {\n+\t\tif (ext4_should_order_data(inode)) {\n+\t\t\thandle_t *handle;\n \n-\t\thandle = ext4_journal_start(inode, EXT4_HT_MISC, 1);\n-\t\tif (IS_ERR(handle))\n-\t\t\treturn PTR_ERR(handle);\n+\t\t\thandle = ext4_journal_start(inode, EXT4_HT_MISC, 1);\n+\t\t\tif (IS_ERR(handle))\n+\t\t\t\treturn PTR_ERR(handle);\n \n-\t\terr = ext4_jbd2_inode_add_write(handle, inode, from, length);\n-\t\text4_journal_stop(handle);\n-\t\tif (err)\n-\t\t\treturn err;\n+\t\t\terr = ext4_jbd2_inode_add_write(handle, inode, from,\n+\t\t\t\t\t\t\tlength);\n+\t\t\text4_journal_stop(handle);\n+\t\t\tif (err)\n+\t\t\t\treturn err;\n+\t\t/*\n+\t\t * inodes using the iomap buffered I/O path do not use the\n+\t\t * data=ordered mode. We submit zeroed range here.\n+\t\t *\n+\t\t * TODO: The end_io process needs to wait for I/O to completes\n+\t\t * before updating i_disksize.\n+\t\t */\n+\t\t} else if (ext4_inode_buffered_iomap(inode)) {\n+\t\t\tstruct folio *folio;\n+\t\t\tbool do_submit = false;\n+\n+\t\t\tfolio = filemap_lock_folio(inode->i_mapping,\n+\t\t\t\t\t\t   from >> PAGE_SHIFT);\n+\t\t\tif (IS_ERR(folio))\n+\t\t\t\t/* Already writeback and clear? */\n+\t\t\t\treturn PTR_ERR(folio) == -ENOENT ? 0 :\n+\t\t\t\t\t\tPTR_ERR(folio);\n+\n+\t\t\tfolio_wait_writeback(folio);\n+\t\t\tWARN_ON_ONCE(folio_test_writeback(folio));\n+\n+\t\t\tif (likely(folio_test_dirty(folio)))\n+\t\t\t\tdo_submit = true;\n+\t\t\tfolio_unlock(folio);\n+\t\t\tfolio_put(folio);\n+\n+\t\t\tif (do_submit) {\n+\t\t\t\terr = filemap_fdatawrite_range(inode->i_mapping,\n+\t\t\t\t\t\t\t       from, end - 1);\n+\t\t\t\tif (err)\n+\t\t\t\t\treturn err;\n+\t\t\t}\n+\t\t}\n \t}\n \n \treturn 0;\n","prefixes":["v3","19/22"]}