From: Hengyu Liang <hengyul@cs.unc.edu>
To: slava@dubeyko.com
Cc: glaubitz@physik.fu-berlin.de, frank.li@vivo.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] hfs: remove the dead grow path from hfs_file_truncate()
Date: Fri, 30 Oct 2026 00:29:03 -0400 [thread overview]
Message-ID: <20261030042903.4160506-3-hengyul@cs.unc.edu> (raw)
In-Reply-To: <20261030042903.4160506-1-hengyul@cs.unc.edu>
hfs_file_truncate() grows the file through hfs_write_begin() when
i_size is larger than phys_size. That case no longer happens.
phys_size is set to i_size when the inode is read. After that, i_size
only grows through hfs_write_begin(), which grows phys_size first, or
through a direct write that ends within phys_size.
"hfs: report errors when extending files with setattr" made
hfs_inode_setattr() extend files with generic_cont_expand_simple(),
and "hfs: fall back to buffered I/O for direct writes past phys_size"
made direct writes past phys_size go through hfs_write_begin() too.
This patch removes the grow path, and warns and returns if i_size is
ever larger than phys_size.
Suggested-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
---
fs/hfs/extent.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c
index 26357086517f..8d04b7c0911e 100644
--- a/fs/hfs/extent.c
+++ b/fs/hfs/extent.c
@@ -491,23 +491,9 @@ void hfs_file_truncate(struct inode *inode)
hfs_dbg("ino %llu, phys_size %llu -> i_size %llu\n",
inode->i_ino, (long long)HFS_I(inode)->phys_size,
inode->i_size);
- if (inode->i_size > HFS_I(inode)->phys_size) {
- struct address_space *mapping = inode->i_mapping;
- void *fsdata = NULL;
- struct folio *folio;
-
- /* XXX: Can use generic_cont_expand? */
- size = inode->i_size - 1;
- res = hfs_write_begin(NULL, mapping, size + 1, 0, &folio,
- &fsdata);
- if (!res) {
- res = generic_write_end(NULL, mapping, size + 1, 0, 0,
- folio, fsdata);
- }
- if (res)
- inode->i_size = HFS_I(inode)->phys_size;
+ if (WARN_ON_ONCE(inode->i_size > HFS_I(inode)->phys_size))
return;
- } else if (inode->i_size == HFS_I(inode)->phys_size)
+ if (inode->i_size == HFS_I(inode)->phys_size)
return;
size = inode->i_size + HFS_SB(sb)->alloc_blksz - 1;
blk_cnt = size / HFS_SB(sb)->alloc_blksz;
--
2.53.0
next prev parent reply other threads:[~2026-10-30 4:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 4:29 [PATCH 0/2] hfs: fall back to buffered I/O for direct writes past phys_size Hengyu Liang
2026-10-30 4:29 ` [PATCH 1/2] " Hengyu Liang
2026-10-30 4:29 ` Hengyu Liang [this message]
2026-10-31 8:59 ` [syzbot ci] " syzbot ci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261030042903.4160506-3-hengyul@cs.unc.edu \
--to=hengyul@cs.unc.edu \
--cc=frank.li@vivo.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=slava@dubeyko.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®