[Devel] [PATCH rh8 9/9] ext4: Fix error handling after filesystem abort

Konstantin Khorenko khorenko at virtuozzo.com
Wed Mar 3 19:31:18 MSK 2021


From: Dmitry Monakhov <dmonakhov at openvz.org>

If filesystem was aborted after inode's write back is complete
but before its metadata was updated we may return success
results in data loss.
In order to handle fs abort correctly we have to check
fs state once we discover that it is in MS_RDONLY state

Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>

+++
ext4: fix broken fsync for dirs/symlink

mFixes commit 6a63db16da84fe
("ext4: Fix error handling after filesystem abort").

xfstests: generic/321 generic/335 generic/348
Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>

(cherry picked from vz7 commit 00399757c828ee82941123f6c67e7c96d906ce2b)
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 fs/ext4/super.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7a41751364ab..74cad98d6bfd 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5318,8 +5318,12 @@ int ext4_force_commit(struct super_block *sb)
 {
 	journal_t *journal;
 
-	if (sb_rdonly(sb))
+	if (sb_rdonly(sb)) {
+		smp_rmb();
+		if (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)
+			return -EROFS;
 		return 0;
+	}
 
 	journal = EXT4_SB(sb)->s_journal;
 	return ext4_journal_force_commit(journal);
-- 
2.28.0



More information about the Devel mailing list