]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ext4: define ext4_journal_destroy wrapper
authorOjaswin Mujoo <ojaswin@linux.ibm.com>
Tue, 18 Mar 2025 07:52:55 +0000 (13:22 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Sep 2025 16:58:20 +0000 (18:58 +0200)
commit 5a02a6204ca37e7c22fbb55a789c503f05e8e89a upstream.

Define an ext4 wrapper over jbd2_journal_destroy to make sure we
have consistent behavior during journal destruction. This will also
come useful in the next patch where we add some ext4 specific logic
in the destroy path.

Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Baokun Li <libaokun1@huawei.com>
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Link: https://patch.msgid.link/c3ba78c5c419757e6d5f2d8ebb4a8ce9d21da86a.1742279837.git.ojaswin@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/ext4_jbd2.h
fs/ext4/super.c

index 0c77697d5e90d075364bb67dbc281a7fde89ea9d..930778e507cc46c863304a8a28f83e671170ae0e 100644 (file)
@@ -513,4 +513,18 @@ static inline int ext4_should_dioread_nolock(struct inode *inode)
        return 1;
 }
 
+/*
+ * Pass journal explicitly as it may not be cached in the sbi->s_journal in some
+ * cases
+ */
+static inline int ext4_journal_destroy(struct ext4_sb_info *sbi, journal_t *journal)
+{
+       int err = 0;
+
+       err = jbd2_journal_destroy(journal);
+       sbi->s_journal = NULL;
+
+       return err;
+}
+
 #endif /* _EXT4_JBD2_H */
index 722ac723f49b6e8dc880e003f042f60cadd05a3c..d0500f19bf51c6cd5af952165c8b37d429b090c2 100644 (file)
@@ -1312,8 +1312,7 @@ static void ext4_put_super(struct super_block *sb)
 
        if (sbi->s_journal) {
                aborted = is_journal_aborted(sbi->s_journal);
-               err = jbd2_journal_destroy(sbi->s_journal);
-               sbi->s_journal = NULL;
+               err = ext4_journal_destroy(sbi, sbi->s_journal);
                if ((err < 0) && !aborted) {
                        ext4_abort(sb, -err, "Couldn't clean up the journal");
                }
@@ -4957,8 +4956,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
 out:
        /* flush s_sb_upd_work before destroying the journal. */
        flush_work(&sbi->s_sb_upd_work);
-       jbd2_journal_destroy(sbi->s_journal);
-       sbi->s_journal = NULL;
+       ext4_journal_destroy(sbi, sbi->s_journal);
        return -EINVAL;
 }
 
@@ -5649,8 +5647,7 @@ failed_mount_wq:
        if (sbi->s_journal) {
                /* flush s_sb_upd_work before journal destroy. */
                flush_work(&sbi->s_sb_upd_work);
-               jbd2_journal_destroy(sbi->s_journal);
-               sbi->s_journal = NULL;
+               ext4_journal_destroy(sbi, sbi->s_journal);
        }
 failed_mount3a:
        ext4_es_unregister_shrinker(sbi);
@@ -5958,7 +5955,7 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,
        return journal;
 
 out_journal:
-       jbd2_journal_destroy(journal);
+       ext4_journal_destroy(EXT4_SB(sb), journal);
 out_bdev:
        bdev_fput(bdev_file);
        return ERR_PTR(errno);
@@ -6075,8 +6072,7 @@ static int ext4_load_journal(struct super_block *sb,
        EXT4_SB(sb)->s_journal = journal;
        err = ext4_clear_journal_err(sb, es);
        if (err) {
-               EXT4_SB(sb)->s_journal = NULL;
-               jbd2_journal_destroy(journal);
+               ext4_journal_destroy(EXT4_SB(sb), journal);
                return err;
        }
 
@@ -6094,7 +6090,7 @@ static int ext4_load_journal(struct super_block *sb,
        return 0;
 
 err_out:
-       jbd2_journal_destroy(journal);
+       ext4_journal_destroy(EXT4_SB(sb), journal);
        return err;
 }