From: Yichong Chen <chenyichong@uniontech.com>
To: tytso@mit.edu
Cc: adilger.kernel@dilger.ca, libaokun@linux.alibaba.com,
jack@suse.cz, ojaswin@linux.ibm.com, ritesh.list@gmail.com,
yi.zhang@huawei.com, linux-ext4@vger.kernel.org,
linux-kernel@vger.kernel.org,
Yichong Chen <chenyichong@uniontech.com>
Subject: [PATCH v2] ext4: drop tmp inode ownership before migration cleanup
Date: Thu, 22 Oct 2026 15:02:35 +0800 [thread overview]
Message-ID: <20261022070235.17849-1-chenyichong@uniontech.com> (raw)
After the extent tree is transferred to the original inode,
ext4_journal_ensure_credits() can fail before tmp_inode is cleared. The
subsequent iput(tmp_inode) may then free the transferred tree.
Move the existing resets of tmp_inode's size, block count and checksum
seed before ext4_journal_ensure_credits(). This leaves the temporary inode
ready for eviction even if obtaining journal credits fails. Keep
ext4_ext_tree_init(), which marks the inode dirty, after the credits check.
Fixes: a413036791d0 ("ext4: Provide function to handle transaction restarts")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
---
Notes:
Changes in v2:
- Move the existing i_size, i_blocks and i_csum_seed resets before
ext4_journal_ensure_credits() instead of adding a conditional duplicate,
as suggested by Jan Kara.
v1: https://lore.kernel.org/all/20260930080241.414973-1-chenyichong@uniontech.com/
fs/ext4/migrate.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index 09931d3ba2c6..cf5239c42693 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -566,10 +566,6 @@ int ext4_ext_migrate(struct inode *inode)
free_ext_block(handle, tmp_inode);
}
- /* We mark the tmp_inode dirty via ext4_ext_tree_init. */
- retval = ext4_journal_ensure_credits(handle, 1, 0);
- if (retval < 0)
- goto out_stop;
/*
* Mark the tmp_inode as of size zero
*/
@@ -586,6 +582,11 @@ int ext4_ext_migrate(struct inode *inode)
tmp_inode->i_blocks = 0;
EXT4_I(tmp_inode)->i_csum_seed = tmp_csum_seed;
+ /* We mark the tmp_inode dirty via ext4_ext_tree_init. */
+ retval = ext4_journal_ensure_credits(handle, 1, 0);
+ if (retval < 0)
+ goto out_stop;
+
/* Reset the extent details */
ext4_ext_tree_init(handle, tmp_inode);
out_stop:
base-commit: 9a482184d910775cf648863148944945b74e2815
--
2.51.0
next reply other threads:[~2026-10-22 7:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 7:02 Yichong Chen [this message]
2026-10-22 7:16 ` [PATCH v2] ext4: drop tmp inode ownership before migration cleanup sashiko-bot
2026-10-22 10:59 ` Jan Kara
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=20261022070235.17849-1-chenyichong@uniontech.com \
--to=chenyichong@uniontech.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.