Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216846/?format=api
{ "id": 2216846, "url": "http://patchwork.ozlabs.org/api/patches/2216846/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20260327102939.1095257-14-yi.zhang@huaweicloud.com/", "project": { "id": 8, "url": "http://patchwork.ozlabs.org/api/projects/8/?format=api", "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": "<20260327102939.1095257-14-yi.zhang@huaweicloud.com>", "list_archive_url": null, "date": "2026-03-27T10:29:39", "name": "[v4,13/13] ext4: zero post-EOF partial block before appending write", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b57779f717ef706bda70ea877f946dbd988dd293", "submitter": { "id": 85428, "url": "http://patchwork.ozlabs.org/api/people/85428/?format=api", "name": "Zhang Yi", "email": "yi.zhang@huaweicloud.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20260327102939.1095257-14-yi.zhang@huaweicloud.com/mbox/", "series": [ { "id": 497742, "url": "http://patchwork.ozlabs.org/api/series/497742/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/list/?series=497742", "date": "2026-03-27T10:29:26", "name": "ext4: refactor partial block zero-out for iomap conversion", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/497742/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216846/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216846/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <SRS0=8hnU=B3=vger.kernel.org=linux-ext4+bounces-15491-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=8hnu=b3=vger.kernel.org=linux-ext4+bounces-15491-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)", "gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c04:e001:36c::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:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15491-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 4fhy2h0kfWz1y1j\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 21:45:00 +1100 (AEDT)", "from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fhy2h0GD1z4w93\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 27 Mar 2026 21:45:00 +1100 (AEDT)", "by gandalf.ozlabs.org (Postfix)\n\tid 4fhy2h0B8xz4wB7; Fri, 27 Mar 2026 21:45:00 +1100 (AEDT)", "from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::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 4fhy2c43pCz4w93\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 27 Mar 2026 21:44:56 +1100 (AEDT)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id CE1C83160AEF\n\tfor <patchwork-incoming@ozlabs.org>; Fri, 27 Mar 2026 10:36:34 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id B088D33DEC0;\n\tFri, 27 Mar 2026 10:34:43 +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 556C43DA7DD;\n\tFri, 27 Mar 2026 10:34:40 +0000 (UTC)", "from mail.maildlp.com (unknown [172.19.163.170])\n\tby dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fhxpM2wlMzYQv8r;\n\tFri, 27 Mar 2026 18:34:19 +0800 (CST)", "from mail02.huawei.com (unknown [10.116.40.112])\n\tby mail.maildlp.com (Postfix) with ESMTP id 03C0E4056F;\n\tFri, 27 Mar 2026 18:34:33 +0800 (CST)", "from huaweicloud.com (unknown [10.50.85.155])\n\tby APP1 (Coremail) with SMTP id cCh0CgC3utouXcZp_T2cCQ--.28730S17;\n\tFri, 27 Mar 2026 18:34:32 +0800 (CST)" ], "ARC-Seal": [ "i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1774608300; cv=pass;\n\tb=e5ckLeAa+pWgfuxaYl/ARdSw0SWCVIKN2jhvZ4gRq8hAm7MvYhndz4YSWYFsTAVKyw5NVurUBUYqYmC4A9cxEeNjnZsnxvO/Xd/NMfiFxh/qwA03q57gNU5jgaIhN9GJSxBencPdXy06VJwp5R9LFimEg4wivxksvB+fOo0ss3yt64JBTPWgvFTNy+rHdh+/j6jhnUeO7qLGBf+XXuuXwNUhJO4FUGyD4OfqXJPpkaq12KzBu8v9W9sl/NE5ZBiuQkUOT3zhtjZ33BbQ0rdu6T3ugiMtlH04kSMqfj9bY4g0kljq7sZfE/JvJjGlJIcidaJh4KsPHVcd1+LDUwzHaw==", "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774607683; cv=none;\n b=dGUjYtlPlSvG8bTIck16V7taoLA3fVCiBf9cbEU5GWjff38JHEDLbXXnEu4Ds5gHqvKTX6M1XNq/K+mLZ1CwDCDkzt0LrzeBkGR5IinCUrpbGsizINQdj5d5bMzl6IpMIwJV2o61QYsqBOKIs4dxD1s1VIWXDk8ozehtOqiXQ54=" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1774608300; c=relaxed/relaxed;\n\tbh=XyL+zv19InMaLS+rUR7f8P6T3K6gkxSNREUB2PujQ2o=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=cGlqEtCIBxIfNJQmtYSmWqPlnycLTFF0i460uIwYttNEosVXGnadFJa4HTjsIiaOvSKFrZs12hybAVrCZiv2YYb8UVRZIgX+/0/Rxz5cMD5m/aAQkOwMan3arOORRaB2F6w6jPIL/Xsnj90ZzKGkwWfccmKye36X+UxnGBGO85ElPlZ84Af/3zLyhTNBGm7UzdEgRYDcwOdaxjPPSvKWqYEBV+67bebb85a02oN5X21W5AsSvfgG6297rNj/TIubCggWwJOqTX1OVDmNiMyc1ZXd5gw6okaknoMN5MXYWgzRCsXfiXnfkEq1+YK/AvuidaiPyAe8YNn5LCUEakzYuw==", "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774607683; c=relaxed/simple;\n\tbh=HWHjJwruyHq/Wbz4i5l0dAiCgRGI7Sfz7pY8baZw8Ns=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=cDpCDvZOWib5BVHRLQqkVMmw2Wx9iQX39Oqs/4P5NIKZtR7G2jj5o0idb9zMkxyU6xOsKVh0mGbePsm2d52rL+YlJAqAAbBJu6VKTA6LUJicTX+8utTG7Jp/MoZ2jJceCQVadc5ZHp5aviQyIwfQ8BOERupbxwaXIkcaPoRJwHo=" ], "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:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15491-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", "Cc": "linux-fsdevel@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\ttytso@mit.edu,\n\tadilger.kernel@dilger.ca,\n\tjack@suse.cz,\n\tojaswin@linux.ibm.com,\n\tritesh.list@gmail.com,\n\tlibaokun@linux.alibaba.com,\n\tyi.zhang@huawei.com,\n\tyi.zhang@huaweicloud.com,\n\tyizhang089@gmail.com,\n\tyangerkun@huawei.com,\n\tyukuai@fnnas.com", "Subject": "[PATCH v4 13/13] ext4: zero post-EOF partial block before appending\n write", "Date": "Fri, 27 Mar 2026 18:29:39 +0800", "Message-ID": "<20260327102939.1095257-14-yi.zhang@huaweicloud.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260327102939.1095257-1-yi.zhang@huaweicloud.com>", "References": "<20260327102939.1095257-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": "cCh0CgC3utouXcZp_T2cCQ--.28730S17", "X-Coremail-Antispam": "1UD129KBjvJXoWxGrW8WrWrtryxZr17Gr1Dtrb_yoWrWFW3pF\n\tZIkF1fuwnFgr9rW3yxGFsrX34jka48JrW7GFyfKrWfZFnxJw18KF1Iq34UtFWrtrZrXa1F\n\tqF4qkFyUG3Wjy3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\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_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI\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 cases of appending write beyond EOF, ext4_zero_partial_blocks() is\ncalled within ext4_*_write_end() to zero out the partial block beyond\nEOF. This prevents exposing stale data that might be written through\nmmap.\n\nHowever, supporting only the regular buffered write path is\ninsufficient. It is also necessary to support the DAX path as well as\nthe upcoming iomap buffered write path. Therefore, move this operation\nto ext4_write_checks().\n\nIn addition, this may introduce a race window in which a post-EOF\nbuffered write can race with an mmap write after the old EOF block has\nbeen zeroed. As a result, the data in this block written by the\nbuffer-write and the data written by the mmap-write may be mixed.\nHowever, this is safe because users should not rely on the result of the\nrace condition.\n\nSigned-off-by: Zhang Yi <yi.zhang@huawei.com>\nReviewed-by: Jan Kara <jack@suse.cz>\n---\n fs/ext4/file.c | 17 +++++++++++++++++\n fs/ext4/inode.c | 21 +++++++--------------\n 2 files changed, 24 insertions(+), 14 deletions(-)", "diff": "diff --git a/fs/ext4/file.c b/fs/ext4/file.c\nindex f1dc5ce791a7..ec0d81bea07a 100644\n--- a/fs/ext4/file.c\n+++ b/fs/ext4/file.c\n@@ -271,6 +271,8 @@ static ssize_t ext4_generic_write_checks(struct kiocb *iocb,\n \n static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from)\n {\n+\tstruct inode *inode = file_inode(iocb->ki_filp);\n+\tloff_t old_size = i_size_read(inode);\n \tssize_t ret, count;\n \n \tcount = ext4_generic_write_checks(iocb, from);\n@@ -280,6 +282,21 @@ static ssize_t ext4_write_checks(struct kiocb *iocb, struct iov_iter *from)\n \tret = file_modified(iocb->ki_filp);\n \tif (ret)\n \t\treturn ret;\n+\n+\t/*\n+\t * If the position is beyond the EOF, it is necessary to zero out the\n+\t * partial block that beyond the existing EOF, as it may contains\n+\t * stale data written through mmap.\n+\t */\n+\tif (iocb->ki_pos > old_size && !ext4_verity_in_progress(inode)) {\n+\t\tif (iocb->ki_flags & IOCB_NOWAIT)\n+\t\t\treturn -EAGAIN;\n+\n+\t\tret = ext4_block_zero_eof(inode, old_size, iocb->ki_pos);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \treturn count;\n }\n \ndiff --git a/fs/ext4/inode.c b/fs/ext4/inode.c\nindex 3b150e643ef5..7afa5fbf067b 100644\n--- a/fs/ext4/inode.c\n+++ b/fs/ext4/inode.c\n@@ -1456,10 +1456,9 @@ static int ext4_write_end(const struct kiocb *iocb,\n \tfolio_unlock(folio);\n \tfolio_put(folio);\n \n-\tif (old_size < pos && !verity) {\n+\tif (old_size < pos && !verity)\n \t\tpagecache_isize_extended(inode, old_size, pos);\n-\t\text4_block_zero_eof(inode, old_size, pos);\n-\t}\n+\n \t/*\n \t * Don't mark the inode dirty under folio lock. First, it unnecessarily\n \t * makes the holding time of folio lock longer. Second, it forces lock\n@@ -1574,10 +1573,8 @@ static int ext4_journalled_write_end(const struct kiocb *iocb,\n \tfolio_unlock(folio);\n \tfolio_put(folio);\n \n-\tif (old_size < pos && !verity) {\n+\tif (old_size < pos && !verity)\n \t\tpagecache_isize_extended(inode, old_size, pos);\n-\t\text4_block_zero_eof(inode, old_size, pos);\n-\t}\n \n \tif (size_changed) {\n \t\tret2 = ext4_mark_inode_dirty(handle, inode);\n@@ -3196,7 +3193,7 @@ static int ext4_da_do_write_end(struct address_space *mapping,\n \tstruct inode *inode = mapping->host;\n \tloff_t old_size = inode->i_size;\n \tbool disksize_changed = false;\n-\tloff_t new_i_size, zero_len = 0;\n+\tloff_t new_i_size;\n \thandle_t *handle;\n \n \tif (unlikely(!folio_buffers(folio))) {\n@@ -3240,19 +3237,15 @@ static int ext4_da_do_write_end(struct address_space *mapping,\n \tfolio_unlock(folio);\n \tfolio_put(folio);\n \n-\tif (pos > old_size) {\n+\tif (pos > old_size)\n \t\tpagecache_isize_extended(inode, old_size, pos);\n-\t\tzero_len = pos - old_size;\n-\t}\n \n-\tif (!disksize_changed && !zero_len)\n+\tif (!disksize_changed)\n \t\treturn copied;\n \n-\thandle = ext4_journal_start(inode, EXT4_HT_INODE, 2);\n+\thandle = ext4_journal_start(inode, EXT4_HT_INODE, 1);\n \tif (IS_ERR(handle))\n \t\treturn PTR_ERR(handle);\n-\tif (zero_len)\n-\t\text4_block_zero_eof(inode, old_size, pos);\n \text4_mark_inode_dirty(handle, inode);\n \text4_journal_stop(handle);\n \n", "prefixes": [ "v4", "13/13" ] }