ext4: preserve force-fsck requests across unmount
Subsystems (2)
PATCH 1/1 ext4: preserve force-fsck requests across unmount
EXT4_TUNE_FL_FORCE_FSCK sets EXT4_ERROR_FS in the on-disk superblock but leaves s_mount_state unchanged. On a normal read-write unmount, ext4_put_super() restores s_state from s_mount_state, clearing the requested flag.
As a result, a successful EXT4_IOC_SET_TUNE_SB_PARAM call can be lost before e2fsck runs: after unmount it treats the filesystem as clean and skips the requested check.
Set EXT4_ERROR_FS in s_mount_state as well, matching the state handling in ext4_clear_journal_err(), so later superblock updates retain the request.
--- fs/ext4/ioctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/ioctl.c +3 -1
@@ -1384,8 +1384,10 @@ static void ext4_sb_setparams(struct ext4_sb_info *sbi, EXT4_FEATURE_INCOMPAT_CSUM_SEED) es->s_checksum_seed = cpu_to_le32(sbi->s_csum_seed); } -if (params->set_flags &EXT4_TUNE_FL_FORCE_FSCK ) +if (params->set_flags &EXT4_TUNE_FL_FORCE_FSCK ) { + sbi->s_mount_state |=EXT4_ERROR_FS ; es->s_state |=cpu_to_le16 (EXT4_ERROR_FS ); + } } static int ext4_ioctl_set_tune_sb(struct file *filp,
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 9 lines
EXT4_TUNE_FL_FORCE_FSCKsetsEXT4_ERROR_FSin the on-disk superblock but leavess_mount_stateunchanged. On a normal read-write unmount,ext4_put_super()restoress_statefroms_mount_state, clearing the requested flag.As a result, a successful
EXT4_IOC_SET_TUNE_SB_PARAMcall can be lost before e2fsck runs: after unmount it treats the filesystem as clean and skips the requested check.
Quoted 7 lines
Set
EXT4_ERROR_FSins_mount_stateas well, matching the state handling inext4_clear_journal_err(), so later superblock updates retain the request.Fixes 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")Signed-off-by Hungyu Lin <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi Ted,
Just following up on this patch.
Thanks,
Hungyu
Quoted 10 lines · Hungyu Lin
EXT4_TUNE_FL_FORCE_FSCKsetsEXT4_ERROR_FSin the on-disk superblock but leavess_mount_stateunchanged. On a normal read-write unmount,ext4_put_super()restoress_statefroms_mount_state, clearing the requested flag.As a result, a successful
EXT4_IOC_SET_TUNE_SB_PARAMcall can be lost before e2fsck runs: after unmount it treats the filesystem as clean and skips the requested check.[...]
Applied, thanks!
[1/1] ext4: preserve force-fsck requests across unmount
commit: fe66a3e2a6627bef578137722f430bd633dee3e5
Best regards,
Signature · 1 line
Theodore Ts'o <[email protected]>