[PATCH v2 0/7] ext4: correct behaviors under errors=remount-ro mode

libaokun@huaweicloud.com posted 7 patches 11 months ago
fs/ext4/ext4.h      | 23 +++++++++++++--
fs/ext4/ext4_jbd2.c |  6 ++--
fs/ext4/file.c      | 27 +++++++++++------
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     | 70 +++++++++++++++++++++++++--------------------
13 files changed, 134 insertions(+), 88 deletions(-)
[PATCH v2 0/7] ext4: correct behaviors under errors=remount-ro mode
Posted by libaokun@huaweicloud.com 11 months ago
From: Baokun Li <libaokun1@huawei.com>

Changes since v1:
 * Patch 1,2: Add comma after the last enum member.
 * Patch 3: Rename ext4_is_emergency() to ext4_emergency_state().
 * Patch 4: Instead of adding an ext4_sb_rdonly() helper, add additional
            ext4_emergency_state() checks.
 * Patch 5: Replace sb_rdonly() with ext4_emergency_ro() in
            ext4_handle_error() and keep the SB_RDONLY comments.
 * Collect RVB from Jan Kara and Zhang Yi.(Thanks for your review!)
 * Rebased on link[2] to avoid context conflicts with Patch 3.
  (ext4_forced_shutdown() -> ext4_emergency_state() in ext4_end_io_end()).

[v1]: https://lore.kernel.org/r/20250117082315.2869996-1-libaokun@huaweicloud.com
Link: https://lore.kernel.org/r/20250122110533.4116662-1-libaokun@huaweicloud.com [2]

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/r/22d652f6-cb3c-43f5-b2fe-0a4bb6516a04@huawei.com [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_emergency_state() helper function
  ext4: add more ext4_emergency_state() checks around sb_rdonly()
  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      | 23 +++++++++++++--
 fs/ext4/ext4_jbd2.c |  6 ++--
 fs/ext4/file.c      | 27 +++++++++++------
 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     | 70 +++++++++++++++++++++++++--------------------
 13 files changed, 134 insertions(+), 88 deletions(-)

-- 
2.39.2
Re: [PATCH v2 0/7] ext4: correct behaviors under errors=remount-ro mode
Posted by Theodore Ts'o 9 months ago
On Wed, 22 Jan 2025 19:41:23 +0800, libaokun@huaweicloud.com wrote:
> Changes since v1:
>  * Patch 1,2: Add comma after the last enum member.
>  * Patch 3: Rename ext4_is_emergency() to ext4_emergency_state().
>  * Patch 4: Instead of adding an ext4_sb_rdonly() helper, add additional
>             ext4_emergency_state() checks.
>  * Patch 5: Replace sb_rdonly() with ext4_emergency_ro() in
>             ext4_handle_error() and keep the SB_RDONLY comments.
>  * Collect RVB from Jan Kara and Zhang Yi.(Thanks for your review!)
>  * Rebased on link[2] to avoid context conflicts with Patch 3.
>   (ext4_forced_shutdown() -> ext4_emergency_state() in ext4_end_io_end()).
> 
> [...]

Applied, thanks!

[1/7] ext4: convert EXT4_FLAGS_* defines to enum
      commit: 99708f8a9d30081a71638d6f4e216350a4340cc3
[2/7] ext4: add EXT4_FLAGS_EMERGENCY_RO bit
      commit: f3054e53c2f367bd3cf6535afe9ab13198d2d739
[3/7] ext4: add ext4_emergency_state() helper function
      commit: 0a1b2f5ea98764221ccc1043b8dc27a8c0225476
[4/7] ext4: add more ext4_emergency_state() checks around sb_rdonly()
      commit: 5bc27f4d73d3dadc5c71fb47ea741d31d92f41b1
[5/7] ext4: correct behavior under errors=remount-ro mode
      commit: 8f984530c242c569bafecfa35bce969a9b8fb0dd
[6/7] ext4: show 'emergency_ro' when EXT4_FLAGS_EMERGENCY_RO is set
      commit: 6b76715d5e41fc332b0b879e66fad6ef3db07a3f
[7/7] ext4: show 'shutdown' hint when ext4 is forced to shutdown
      commit: 5855c3519463e9ac4d10424bb49953047a04c602

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>