Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216391/?format=api
{ "id": 2216391, "url": "http://patchwork.ozlabs.org/api/patches/2216391/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/patch/20260326111054.907252-12-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": "<20260326111054.907252-12-yi.zhang@huaweicloud.com>", "list_archive_url": null, "date": "2026-03-26T11:10:54", "name": "[v3,11/11] ext4: zero post-EOF partial block before appending write", "commit_ref": null, "pull_url": null, "state": "superseded", "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/20260326111054.907252-12-yi.zhang@huaweicloud.com/mbox/", "series": [ { "id": 497571, "url": "http://patchwork.ozlabs.org/api/series/497571/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-ext4/list/?series=497571", "date": "2026-03-26T11:10:46", "name": "ext4: refactor partial block zero-out for iomap conversion", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/497571/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216391/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216391/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <SRS0=8XpC=B2=vger.kernel.org=linux-ext4+bounces-15450-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=150.107.74.76; helo=mail.ozlabs.org;\n envelope-from=srs0=8xpc=b2=vger.kernel.org=linux-ext4+bounces-15450-patchwork-incoming=ozlabs.org@ozlabs.org;\n receiver=patchwork.ozlabs.org)", "gandalf.ozlabs.org;\n arc=pass smtp.remote-ip=\"2600:3c09:e001:a7::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:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15450-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=none smtp.mailfrom=huaweicloud.com" ], "Received": [ "from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76])\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 4fhLyD2KHJz1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 22:24:04 +1100 (AEDT)", "from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3])\n\tby gandalf.ozlabs.org (Postfix) with ESMTP id 4fhLyD1rzbz4wHX\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 22:24:04 +1100 (AEDT)", "by gandalf.ozlabs.org (Postfix)\n\tid 4fhLyD1mHNz4wM0; Thu, 26 Mar 2026 22:24:04 +1100 (AEDT)", "from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::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 4fhLy85P3vz4wHX\n\tfor <patchwork-incoming@ozlabs.org>; Thu, 26 Mar 2026 22:24:00 +1100 (AEDT)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id A7E5930BE40F\n\tfor <patchwork-incoming@ozlabs.org>; Thu, 26 Mar 2026 11:18:09 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 65D993EAC63;\n\tThu, 26 Mar 2026 11:16:01 +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 55D8B3DD51C;\n\tThu, 26 Mar 2026 11:15:57 +0000 (UTC)", "from mail.maildlp.com (unknown [172.19.163.170])\n\tby dggsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fhLmV3n4MzYQv7p;\n\tThu, 26 Mar 2026 19:15:38 +0800 (CST)", "from mail02.huawei.com (unknown [10.116.40.112])\n\tby mail.maildlp.com (Postfix) with ESMTP id 7655D40571;\n\tThu, 26 Mar 2026 19:15:50 +0800 (CST)", "from huaweicloud.com (unknown [10.50.85.155])\n\tby APP1 (Coremail) with SMTP id cCh0CgD3+NhWFcVprDInCQ--.2580S15;\n\tThu, 26 Mar 2026 19:15:50 +0800 (CST)" ], "ARC-Seal": [ "i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1774524244; cv=pass;\n\tb=QqLgB4uonOyUjytwMAsBSiwg+GESHkGRs/OCymifYQ7x8fXYdSZ41saUz1YgAfZc49wqAjXS0dH/w2cI6kWJvs1gpNO2Z2qm5+ypfJSbJXotlmokj8Kiahd7HoiFVBT1SG8g7Y7F44phJG6Ef/UW8ImnEuKQ5/pBtx3jC7wxtH0/DJBnI88UPfdqvuafdFi+ho6tmr/s/jLiJC+aC1Dpx7zRRBf/KCXv4ns6jJjJosSl/ntdnFuIEr6TMMBJjCDr8ju95UTJszwODUg9Q/nEB7oKcVl7Q6BJ+w1gVH7spxq/uUWoeSwka7uRxXSCjUM8og2ZMG6PgzDDkc/rJZuabg==", "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1774523761; cv=none;\n b=HfoGjGkFKVGM2EpC4OEqT6SPJfuvN7ycdTttrVgwDGuUSjdWKV1++uWHUtDO+Z+BgqFsxW+wAqp55ZPUFUVuKcdGk1fhffpokVwhpv1ezrXjOO5nkft3JCTGOfKeqJU9Zw0vj8QGqt3JeYYdizDQrxiXSjPIc4R5swahOm2Bny8=" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; d=ozlabs.org; s=201707;\n\tt=1774524244; c=relaxed/relaxed;\n\tbh=OKMe1idvURzR3QmB6DnRkRvC0jb/uDUgiPrdTSmnCCY=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=orpvTwSgqc4WlcXqd/n///b9K13tN5HKiSJlqQ5n+SJZ5ZvXQ154HpbjaxKweSFUYhrRjFfJyT3zm/N0zXKkPNwPvAYWQeetfEUUIrRgvsoVEiWcW6Nl3GehkyBEfwuRMZjsNKFwftKUL1euv2MGUVzuzceXADWQeCwyc2ERhQv8droPC6+2mNXFfDclNnqYJNkjNlYliFg8MpSuBwX+2p59HqCcTWaKqd9duabB6AUh2jraA9+Ic+jFhUxpJDGUTTR2uu4KGugc0C6E23IKb2SEl/QaAANyM50T+sUSdufdh/YdRTjDKf534neuwgap7zKfVc0vA/ftTEERE8mdPg==", "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1774523761; c=relaxed/simple;\n\tbh=PV1n1q++orzKmCP/4t60hYR9COeJK/6LFBf/ldOzWFE=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=jZSXeJTWXQy/WE4YHtLu0ROrXBuEgfJrCTmluDvQvOEFgdEXtubREg9LERwk6W1flt6T6HkedE/9tNtaLTJC5aDnhcFY+SJp8MHDdJWSaVaWOjMQsvxDSQ1w8Ye+wmJix5BAhvQBSr8RlO9WkYBwGTYC4aENqxzQq+z6DNvOodw=" ], "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:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-ext4+bounces-15450-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=none 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 v3 11/11] ext4: zero post-EOF partial block before appending\n write", "Date": "Thu, 26 Mar 2026 19:10:54 +0800", "Message-ID": "<20260326111054.907252-12-yi.zhang@huaweicloud.com>", "X-Mailer": "git-send-email 2.52.0", "In-Reply-To": "<20260326111054.907252-1-yi.zhang@huaweicloud.com>", "References": "<20260326111054.907252-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": "cCh0CgD3+NhWFcVprDInCQ--.2580S15", "X-Coremail-Antispam": "1UD129KBjvJXoWxGrW8WrWrtryxZr17Gr1Dtrb_yoWrWFW3pF\n\tZIkF1fWwnFgr9rW3yxKFsrX34jka48JrW7GFyfKrWfZFnxAw18KF12q34UtFWrtrZrXa1F\n\tqF4q9FyUG3Wjy3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDU0xBIdaVrnRJUUUmS14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0\n\trVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI\n\tkIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2\n\tz4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F\n\t4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq\n\t3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7\n\tIYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U\n\tM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2\n\tkIc2xKxwCY1x0262kKe7AKxVWUtVW8ZwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE\n\tbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67\n\tAF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI\n\t42IY6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF\n\t4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBI\n\tdaVFxhVjvjDU0xZFpf9x0JUQFxUUUUUU=", "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 5c54d5c6fdfe..d52cffdea635 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": [ "v3", "11/11" ] }