Skip to content

Commit 73bf12a

Browse files
Ye Bintytso
authored andcommitted
ext4: test if inode's all dirty pages are submitted to disk
The commit aa373cf ("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 d921098 ("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> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://patch.msgid.link/20260303012242.3206465-1-yebin@huaweicloud.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent c4a48e9 commit 73bf12a

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

fs/ext4/inode.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ void ext4_evict_inode(struct inode *inode)
186186
if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)
187187
ext4_evict_ea_inode(inode);
188188
if (inode->i_nlink) {
189+
/*
190+
* If there's dirty page will lead to data loss, user
191+
* could see stale data.
192+
*/
193+
if (unlikely(!ext4_emergency_state(inode->i_sb) &&
194+
mapping_tagged(&inode->i_data, PAGECACHE_TAG_DIRTY)))
195+
ext4_warning_inode(inode, "data will be lost");
196+
189197
truncate_inode_pages_final(&inode->i_data);
190198

191199
goto no_delete;

0 commit comments

Comments
 (0)