[Devel] [PATCH RH9 05/12] ext4: Fix error handling after filesystem abort

Kirill Tkhai ktkhai at virtuozzo.com
Thu Oct 7 13:20:21 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>
Signed-off-by: Kirill Tkhai <ktkhai 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 685686f5b849..6cf2d3e0ed8f 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5784,8 +5784,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);




More information about the Devel mailing list