From: Li Dongyang Date: Tue, 19 Dec 2023 01:00:15 +0000 (+1100) Subject: LU-17332 ldiskfs: do no update superblock after journal destroy X-Git-Tag: 2.15.60~16 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=8cdfa1d50806ff5ef165909956201592e4f11b9b;p=fs%2Flustre-release.git LU-17332 ldiskfs: do no update superblock after journal destroy Trying to start a transaction after journal destroy during umount will lead to a crash. This patch is adding the same checks from 041340404e LU-16982 ldiskfs: Fix crash after "umount -d -f /mnt/..." for el9 series. Change-Id: Ibb89e9f5104b0980a8d9543561ac643322e3724d Fixes: e27a7b33d6 ("LU-16298 ldiskfs: Periodically write ldiskfs superblock") Signed-off-by: Li Dongyang Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53499 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Vitaliy Kuznetsov Reviewed-by: Oleg Drokin --- diff --git a/ldiskfs/kernel_patches/patches/rhel9/ext4-add-periodic-superblock-update.patch b/ldiskfs/kernel_patches/patches/rhel9/ext4-add-periodic-superblock-update.patch index 19ff1a1..ac65574 100644 --- a/ldiskfs/kernel_patches/patches/rhel9/ext4-add-periodic-superblock-update.patch +++ b/ldiskfs/kernel_patches/patches/rhel9/ext4-add-periodic-superblock-update.patch @@ -24,7 +24,7 @@ diff --git a/fs/ext4/super.c b/fs/ext4/super.c index dfa09a277b56..0d2bf85cee34 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c -@@ -439,6 +439,55 @@ static int block_device_ejected(struct super_block *sb) +@@ -439,6 +439,57 @@ static int block_device_ejected(struct super_block *sb) return bdi->dev == NULL; } @@ -47,12 +47,14 @@ index dfa09a277b56..0d2bf85cee34 100644 +{ + struct ext4_sb_info *sbi = EXT4_SB(sb); + struct ext4_super_block *es = sbi->s_es; ++ journal_t *journal = sbi->s_journal; + time64_t now; + __u64 last_update; + __u64 lifetime_write_kbytes; + __u64 diff_size; + -+ if (sb_rdonly(sb)) ++ if (sb_rdonly(sb) || !(sb->s_flags & SB_ACTIVE) || ++ !journal || (journal->j_flags & JBD2_UNMOUNT)) + return; + + now = ktime_get_real_seconds(); @@ -88,6 +90,16 @@ index dfa09a277b56..0d2bf85cee34 100644 spin_lock(&sbi->s_md_lock); while (!list_empty(&txn->t_private_list)) { +@@ -714,7 +766,8 @@ static void flush_stashed_error_work(str + * We use directly jbd2 functions here to avoid recursing back into + * ext4 error handling code during handling of previous errors. + */ +- if (!sb_rdonly(sbi->s_sb) && journal) { ++ if (!sb_rdonly(sbi->s_sb) && journal && ++ !(journal->j_flags & JBD2_UNMOUNT)) { + struct buffer_head *sbh = sbi->s_sbh; + handle = jbd2_journal_start(journal, 1); + if (IS_ERR(handle)) diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index 2314f7446592..a7219cc2fdc5 100644 --- a/fs/ext4/sysfs.c