Skip to contentSkip to conversation

ext4: test if inode's all dirty pages are submitted to disk

PATCH Applied Ye Bin 3 participants 3 messages Mar 3 – Mar 27 ext4 file system

lore
Share & tools
lore

Ye Bin

author
#0 lore raw

PATCH v3 1/1 ext4: test if inode's all dirty pages are submitted to disk

From: Ye Bin <[email protected]>

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.

---
 fs/ext4/inode.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/ext4/inode.c +8 -0
index 396dc3a5d16b..d4d65593bce2 100644
@@ -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;
Signature · 1 line
2.34.1
reviewer Reviewed-by on v3 1/1
#1 lore raw
Quoted 14 lines · Ye Bin

From: Ye Bin <[email protected]>

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.

Quoted 1 line

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:

Honza

Quoted 26 lines
---
 fs/ext4/inode.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/ext4/inode.c +8 -0
index 396dc3a5d16b..d4d65593bce2 100644
@@ -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;
Signature · 1 line
2.34.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
In reply to Ye Bin
Quoted 12 lines · Ye Bin

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.

Quoted 1 line

[...]

Applied, thanks!

[1/1] ext4: test if inode's all dirty pages are submitted to disk

      commit: 7d7ddac60e99f0506ad0dc6ce9138e0c8f9cee94

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>