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

Submitted by Konstantin Khorenko on March 3, 2021, 4:31 p.m.

Details

Message ID 20210303163118.294216-10-khorenko@virtuozzo.com
State New
Series "ext4: Port balloon code and other ext4 fixes"
Headers show

Commit Message

Konstantin Khorenko March 3, 2021, 4:31 p.m.
From: Dmitry Monakhov <dmonakhov@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@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@openvz.org>

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

Patch hide | download patch | download mbox

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);