* [PATCH -next v3] ext4: test if inode's all dirty pages are submitted to disk
@ 2026-03-03 1:22 Ye Bin
2026-03-04 10:19 ` Jan Kara
2026-03-27 4:06 ` Theodore Ts'o
0 siblings, 2 replies; 3+ messages in thread
From: Ye Bin @ 2026-03-03 1:22 UTC (permalink / raw)
To: tytso, adilger.kernel, linux-ext4; +Cc: jack
From: Ye Bin <yebin10@huawei.com>
The commit aa373cf55099 ("writeback: stop background/kupdate works from
livelocking other works") introduced an issue where unmounting a filesystem
in a multi-logical-partition scenario could lead to batch file data loss.
This problem was not fixed until the commit d92109891f21 ("fs/writeback:
bail out if there is no more inodes for IO and queued once"). It took
considerable time to identify the root cause. Additionally, in actual
production environments, we frequently encountered file data loss after
normal system reboots. Therefore, we are adding a check in the inode
release flow to verify whether all dirty pages have been flushed to disk,
in order to determine whether the data loss is caused by a logic issue in
the filesystem code.
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
fs/ext4/inode.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 396dc3a5d16b..d4d65593bce2 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -184,6 +184,14 @@ void ext4_evict_inode(struct inode *inode)
if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)
ext4_evict_ea_inode(inode);
if (inode->i_nlink) {
+ /*
+ * If there's dirty page will lead to data loss, user
+ * could see stale data.
+ */
+ if (unlikely(!ext4_emergency_state(inode->i_sb) &&
+ mapping_tagged(&inode->i_data, PAGECACHE_TAG_DIRTY)))
+ ext4_warning_inode(inode, "data will be lost");
+
truncate_inode_pages_final(&inode->i_data);
goto no_delete;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH -next v3] ext4: test if inode's all dirty pages are submitted to disk
2026-03-03 1:22 [PATCH -next v3] ext4: test if inode's all dirty pages are submitted to disk Ye Bin
@ 2026-03-04 10:19 ` Jan Kara
2026-03-27 4:06 ` Theodore Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2026-03-04 10:19 UTC (permalink / raw)
To: Ye Bin; +Cc: tytso, adilger.kernel, linux-ext4, jack
On Tue 03-03-26 09:22:42, Ye Bin wrote:
> From: Ye Bin <yebin10@huawei.com>
>
> The commit aa373cf55099 ("writeback: stop background/kupdate works from
> livelocking other works") introduced an issue where unmounting a filesystem
> in a multi-logical-partition scenario could lead to batch file data loss.
> This problem was not fixed until the commit d92109891f21 ("fs/writeback:
> bail out if there is no more inodes for IO and queued once"). It took
> considerable time to identify the root cause. Additionally, in actual
> production environments, we frequently encountered file data loss after
> normal system reboots. Therefore, we are adding a check in the inode
> release flow to verify whether all dirty pages have been flushed to disk,
> in order to determine whether the data loss is caused by a logic issue in
> the filesystem code.
>
> Signed-off-by: Ye Bin <yebin10@huawei.com>
OK, I guess the warning is better than the stacktrace. BTW, what did
trigger the false positive warnings this time (I didn't really look at
syzbot reproducers)? Anyway, feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ext4/inode.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 396dc3a5d16b..d4d65593bce2 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -184,6 +184,14 @@ void ext4_evict_inode(struct inode *inode)
> if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)
> ext4_evict_ea_inode(inode);
> if (inode->i_nlink) {
> + /*
> + * If there's dirty page will lead to data loss, user
> + * could see stale data.
> + */
> + if (unlikely(!ext4_emergency_state(inode->i_sb) &&
> + mapping_tagged(&inode->i_data, PAGECACHE_TAG_DIRTY)))
> + ext4_warning_inode(inode, "data will be lost");
> +
> truncate_inode_pages_final(&inode->i_data);
>
> goto no_delete;
> --
> 2.34.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH -next v3] ext4: test if inode's all dirty pages are submitted to disk
2026-03-03 1:22 [PATCH -next v3] ext4: test if inode's all dirty pages are submitted to disk Ye Bin
2026-03-04 10:19 ` Jan Kara
@ 2026-03-27 4:06 ` Theodore Ts'o
1 sibling, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2026-03-27 4:06 UTC (permalink / raw)
To: adilger.kernel, linux-ext4, Ye Bin; +Cc: Theodore Ts'o, jack
On Tue, 03 Mar 2026 09:22:42 +0800, Ye Bin wrote:
> The commit aa373cf55099 ("writeback: stop background/kupdate works from
> livelocking other works") introduced an issue where unmounting a filesystem
> in a multi-logical-partition scenario could lead to batch file data loss.
> This problem was not fixed until the commit d92109891f21 ("fs/writeback:
> bail out if there is no more inodes for IO and queued once"). It took
> considerable time to identify the root cause. Additionally, in actual
> production environments, we frequently encountered file data loss after
> normal system reboots. Therefore, we are adding a check in the inode
> release flow to verify whether all dirty pages have been flushed to disk,
> in order to determine whether the data loss is caused by a logic issue in
> the filesystem code.
>
> [...]
Applied, thanks!
[1/1] ext4: test if inode's all dirty pages are submitted to disk
commit: 7d7ddac60e99f0506ad0dc6ce9138e0c8f9cee94
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-27 4:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03 1:22 [PATCH -next v3] ext4: test if inode's all dirty pages are submitted to disk Ye Bin
2026-03-04 10:19 ` Jan Kara
2026-03-27 4:06 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox