Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: enable the lazy init thread when remounting read/write

In commit a44be64bbecb ("ext4: don't clear SB_RDONLY when remounting
r/w until quota is re-enabled") we defer clearing tyhe SB_RDONLY flag
in struct super. However, we didn't defer when we checked sb_rdonly()
to determine the lazy itable init thread should be enabled, with the
next result that the lazy inode table initialization would not be
properly started. This can cause generic/231 to fail in ext4's
nojournal mode.

Fix this by moving when we decide to start or stop the lazy itable
init thread to after we clear the SB_RDONLY flag when we are
remounting the file system read/write.

Fixes a44be64bbecb ("ext4: don't clear SB_RDONLY when remounting r/w until...")

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20230527035729.1001605-1-tytso@mit.edu
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

+12 -12
+12 -12
fs/ext4/super.c
··· 6589 6589 } 6590 6590 6591 6591 /* 6592 - * Reinitialize lazy itable initialization thread based on 6593 - * current settings 6594 - */ 6595 - if (sb_rdonly(sb) || !test_opt(sb, INIT_INODE_TABLE)) 6596 - ext4_unregister_li_request(sb); 6597 - else { 6598 - ext4_group_t first_not_zeroed; 6599 - first_not_zeroed = ext4_has_uninit_itable(sb); 6600 - ext4_register_li_request(sb, first_not_zeroed); 6601 - } 6602 - 6603 - /* 6604 6592 * Handle creation of system zone data early because it can fail. 6605 6593 * Releasing of existing data is done when we are sure remount will 6606 6594 * succeed. ··· 6624 6636 6625 6637 if (enable_rw) 6626 6638 sb->s_flags &= ~SB_RDONLY; 6639 + 6640 + /* 6641 + * Reinitialize lazy itable initialization thread based on 6642 + * current settings 6643 + */ 6644 + if (sb_rdonly(sb) || !test_opt(sb, INIT_INODE_TABLE)) 6645 + ext4_unregister_li_request(sb); 6646 + else { 6647 + ext4_group_t first_not_zeroed; 6648 + first_not_zeroed = ext4_has_uninit_itable(sb); 6649 + ext4_register_li_request(sb, first_not_zeroed); 6650 + } 6627 6651 6628 6652 if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb)) 6629 6653 ext4_stop_mmpd(sbi);