[PATCH v2 2/7] ext4: add EXT4_FLAGS_EMERGENCY_RO bit
From: libaokun
Date: Wed Jan 22 2025 - 06:48:14 EST
From: Baokun Li <libaokun1@xxxxxxxxxx>
EXT4_FLAGS_EMERGENCY_RO Indicates that the current file system has become
read-only due to some error. Compared to SB_RDONLY, setting it does not
require a lock because we won't clear it, which avoids over-coupling with
vfs freeze. Also, add a helper function ext4_emergency_ro() to check if
the bit is set.
Signed-off-by: Baokun Li <libaokun1@xxxxxxxxxx>
Reviewed-by: Jan Kara <jack@xxxxxxx>
Reviewed-by: Zhang Yi <yi.zhang@xxxxxxxxxx>
---
fs/ext4/ext4.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 4491e82cfa6f..207510b0b0af 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -2237,6 +2237,7 @@ enum {
EXT4_FLAGS_RESIZING, /* Avoid superblock update and resize race */
EXT4_FLAGS_SHUTDOWN, /* Prevent access to the file system */
EXT4_FLAGS_BDEV_IS_DAX, /* Current block device support DAX */
+ EXT4_FLAGS_EMERGENCY_RO,/* Emergency read-only due to fs errors */
};
static inline int ext4_forced_shutdown(struct super_block *sb)
@@ -2244,6 +2245,11 @@ static inline int ext4_forced_shutdown(struct super_block *sb)
return test_bit(EXT4_FLAGS_SHUTDOWN, &EXT4_SB(sb)->s_ext4_flags);
}
+static inline int ext4_emergency_ro(struct super_block *sb)
+{
+ return test_bit(EXT4_FLAGS_EMERGENCY_RO, &EXT4_SB(sb)->s_ext4_flags);
+}
+
/*
* Default values for user and/or group using reserved blocks
*/
--
2.39.2