[PATCH v2 10/34] exfat: use the generic emergency read-only state
Christian Brauner
brauner at kernel.org
Thu Oct 29 09:07:01 PDT 2026
Set SB_STATE_EMERGENCY_RO instead of a private bit when an error makes
the filesystem read-only. exfat_emergency_state() keeps telling a
shutdown (EIO) and the emergency state (EROFS) apart so none of its
callers change. The VFS refuses the remount to read-write now so exfat
doesn't have to, and /proc/mounts shows the filesystem read-only again.
Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>
---
fs/exfat/exfat_fs.h | 13 ++-----------
fs/exfat/misc.c | 6 ++----
fs/exfat/super.c | 7 +------
3 files changed, 5 insertions(+), 21 deletions(-)
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index c0e712d9083a..ac138f111988 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -123,7 +123,6 @@ enum {
/* Superblock flags */
#define EXFAT_FLAGS_SHUTDOWN 1
-#define EXFAT_FLAGS_EMERGENCY_RO 2 /* read-only after an error */
struct exfat_dentry_namebuf {
char *lfn;
@@ -376,20 +375,12 @@ static inline int exfat_forced_shutdown(struct super_block *sb)
return test_bit(EXFAT_FLAGS_SHUTDOWN, &EXFAT_SB(sb)->s_exfat_flags);
}
-static inline int exfat_emergency_ro(struct super_block *sb)
-{
- return test_bit(EXFAT_FLAGS_EMERGENCY_RO, &EXFAT_SB(sb)->s_exfat_flags);
-}
-
-/*
- * Modifications are refused after a forced shutdown (-EIO) and after an error
- * with errors=remount-ro (-EROFS).
- */
+/* -EIO after a forced shutdown, -EROFS after an error with errors=remount-ro */
static inline int exfat_emergency_state(struct super_block *sb)
{
if (unlikely(exfat_forced_shutdown(sb)))
return -EIO;
- if (unlikely(exfat_emergency_ro(sb)))
+ if (unlikely(sb_emergency_ro(sb)))
return -EROFS;
return 0;
}
diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
index 56dcb93ce69e..03c5c2b9a65e 100644
--- a/fs/exfat/misc.c
+++ b/fs/exfat/misc.c
@@ -25,8 +25,7 @@
*/
void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
{
- struct exfat_sb_info *sbi = EXFAT_SB(sb);
- struct exfat_mount_options *opts = &sbi->options;
+ struct exfat_mount_options *opts = &EXFAT_SB(sb)->options;
va_list args;
struct va_format vaf;
@@ -49,8 +48,7 @@ void __exfat_fs_error(struct super_block *sb, int report, const char *fmt, ...)
*/
if (!(sb->s_flags & SB_BORN))
sb->s_flags |= SB_RDONLY;
- else if (test_and_set_bit(EXFAT_FLAGS_EMERGENCY_RO,
- &sbi->s_exfat_flags))
+ else if (!sb_set_emergency_ro(sb))
return;
exfat_err(sb, "Filesystem has been set read-only");
}
diff --git a/fs/exfat/super.c b/fs/exfat/super.c
index feeda41a8074..67b34cfce247 100644
--- a/fs/exfat/super.c
+++ b/fs/exfat/super.c
@@ -100,7 +100,7 @@ static int exfat_set_vol_flags(struct super_block *sb, unsigned short new_flags)
* if this volume has been mounted with read-only,
* or an error left it read-only (it stays dirty then)
*/
- if (sb_rdonly(sb) || exfat_emergency_ro(sb))
+ if (sb_rdonly(sb) || sb_emergency_ro(sb))
return 0;
p_boot->vol_flags = cpu_to_le16(new_flags);
@@ -789,11 +789,6 @@ static int exfat_reconfigure(struct fs_context *fc)
fc->sb_flags |= SB_NODIRATIME;
- /* After an error the filesystem stays read-only until unmount. */
- if ((fc->sb_flags_mask & SB_RDONLY) && !(fc->sb_flags & SB_RDONLY) &&
- sb_rdonly(sb) && exfat_emergency_ro(sb))
- return -EROFS;
-
sync_filesystem(sb);
if ((fc->sb_flags & (SB_FORCE | SB_RDONLY)) == SB_RDONLY &&
--
2.53.0
More information about the linux-mtd
mailing list