Skip to contentSkip to conversation

ext4: preserve force-fsck requests across unmount

PATCH Applied Hungyu Lin 3 participants 4 messages Oct 27 – Nov 19

Subsystems (2)
lore
Share & tools
lore

Hungyu Lin

author
#0 lore raw

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.

Fixes 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")
---
 fs/ext4/ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/ioctl.c +3 -1
index e8e579498c99..3e444e245c98 100644
@@ -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
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 9 lines

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.

Quoted 7 lines

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.

Fixes 04a91570ac67 ("ext4: implemet new ioctls to set and get superblock parameters")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author
#2 lore raw

Hi Ted,

Just following up on this patch.

Thanks,
Hungyu

maintainer Applied
#3 lore raw
In reply to Hungyu Lin
Quoted 10 lines · Hungyu Lin

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.

[...]

Applied, thanks!

[1/1] ext4: preserve force-fsck requests across unmount

      commit: fe66a3e2a6627bef578137722f430bd633dee3e5

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>