Skip to contentSkip to conversation

ext4: don't save the error information if the block device is read-only

PATCH In review Theodore Ts'o 1 participant 2 messages May 14, 2015 – May 15, 2015 1 message not in the archive ext4 file system

lore
Share & tools
lore

Theodore Ts'o

author maintainer
#0 lore raw

PATCH 1/1 ext4: don't save the error information if the block device is read-only

Google-Bug-Id: 20939131

---
 fs/ext4/super.c | 2 ++
 1 file changed, 2 insertions(+)
fs/ext4/super.c +2 -0
index f06d058..ca9d4a2 100644
@@ -294,6 +294,8 @@ static void __save_error_info(struct super_block *sb, const char *func,
 	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
 
 	EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
+	if (bdev_read_only(sb->s_bdev))
+		return;
 	es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
 	es->s_last_error_time = cpu_to_le32(get_seconds());
 	strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func));
Signature · 1 line
2.3.0
author maintainer
#2 lore raw
In reply to a message not in the archive
Quoted 2 lines · Mohamad Ayyash

I wonder if there should be some similar protection at other callers of ext4_commit_super like ext4_mark_recovery_complete?

We do have protections already before we start replaying the journal, and before we process the orphaned inode list. See the bdev_read_only() calls in ext4_orphan_cleanup() and ext4_load_journal().

So I think we have them all covered, but let me know if you find one that we've missed. Something that's probably worth doing is to putting in a debugging patch that notices when thre are writes sent down from the file systems when the block device is marked read-only, and then running xfstests and seeing if it trips anywhere.

Cheers,

- Ted