[PATCH 0/7] ext4: correct behaviors under errors=remount-ro mode
From: libaokun
Date: Fri Jan 17 2025 - 03:28:59 EST
From: Baokun Li <libaokun1@xxxxxxxxxx>
After commit d3476f3dad4a ("ext4: don't set SB_RDONLY after filesystem
errors") in v6.12-rc1, the 'errors=remount-ro' mode no longer sets
SB_RDONLY on errors, which results in us seeing the filesystem is still
in rw state after errors.
What's worse is that after commit
95257987a638 ("ext4: drop EXT4_MF_FS_ABORTED flag")
was merged in v6.6-rc1, the EXT4_FLAGS_SHUTDOWN bit is set in
ext4_handle_error(). This causes the file system to not be read-only
when an error is triggered in "errors=remount-ro" mode, because
EXT4_FLAGS_SHUTDOWN prevents both writing and reading.
This patch set fixes the above behavior change. See the link[1] for the
previous discussion:
Link: https://lore.kernel.org/all/22d652f6-cb3c-43f5-b2fe-0a4bb6516a04@xxxxxxxxxx [1]
Comments and questions are, as always, welcome.
Thanks,
Baokun
Baokun Li (7):
ext4: convert EXT4_FLAGS_* defines to enum
ext4: add EXT4_FLAGS_EMERGENCY_RO bit
ext4: add ext4_is_emergency() helper function
ext4: add ext4_sb_rdonly() helper function
ext4: correct behavior under errors=remount-ro mode
ext4: show 'emergency_ro' when EXT4_FLAGS_EMERGENCY_RO is set
ext4: show 'shutdown' hint when ext4 is forced to shutdown
fs/ext4/ext4.h | 28 ++++++++++++++++++++---
fs/ext4/ext4_jbd2.c | 6 +++--
fs/ext4/file.c | 26 ++++++++++++++-------
fs/ext4/fsync.c | 12 ++++------
fs/ext4/ialloc.c | 5 +++--
fs/ext4/inline.c | 2 +-
fs/ext4/inode.c | 47 +++++++++++++++++++++-----------------
fs/ext4/ioctl.c | 2 +-
fs/ext4/mballoc.c | 4 ++--
fs/ext4/mmp.c | 2 +-
fs/ext4/namei.c | 20 ++++++++++-------
fs/ext4/page-io.c | 2 +-
fs/ext4/super.c | 55 ++++++++++++++++++++++-----------------------
13 files changed, 126 insertions(+), 85 deletions(-)
--
2.39.2