Skip to content

Commit 452d061

Browse files
OjaswinMopsiff
authored andcommitted
ext4: define ext4_journal_destroy wrapper
commit 5a02a62 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> (cherry picked from commit c868e9306ea6fbb823c18eb96090a10dce16cc4d)
1 parent bd331d3 commit 452d061

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

fs/ext4/ext4_jbd2.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,4 +513,18 @@ static inline int ext4_should_dioread_nolock(struct inode *inode)
513513
return 1;
514514
}
515515

516+
/*
517+
* Pass journal explicitly as it may not be cached in the sbi->s_journal in some
518+
* cases
519+
*/
520+
static inline int ext4_journal_destroy(struct ext4_sb_info *sbi, journal_t *journal)
521+
{
522+
int err = 0;
523+
524+
err = jbd2_journal_destroy(journal);
525+
sbi->s_journal = NULL;
526+
527+
return err;
528+
}
529+
516530
#endif /* _EXT4_JBD2_H */

fs/ext4/super.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,7 @@ static void ext4_put_super(struct super_block *sb)
13121312

13131313
if (sbi->s_journal) {
13141314
aborted = is_journal_aborted(sbi->s_journal);
1315-
err = jbd2_journal_destroy(sbi->s_journal);
1316-
sbi->s_journal = NULL;
1315+
err = ext4_journal_destroy(sbi, sbi->s_journal);
13171316
if ((err < 0) && !aborted) {
13181317
ext4_abort(sb, -err, "Couldn't clean up the journal");
13191318
}
@@ -4957,8 +4956,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
49574956
out:
49584957
/* flush s_sb_upd_work before destroying the journal. */
49594958
flush_work(&sbi->s_sb_upd_work);
4960-
jbd2_journal_destroy(sbi->s_journal);
4961-
sbi->s_journal = NULL;
4959+
ext4_journal_destroy(sbi, sbi->s_journal);
49624960
return -EINVAL;
49634961
}
49644962

@@ -5649,8 +5647,7 @@ failed_mount8: __maybe_unused
56495647
if (sbi->s_journal) {
56505648
/* flush s_sb_upd_work before journal destroy. */
56515649
flush_work(&sbi->s_sb_upd_work);
5652-
jbd2_journal_destroy(sbi->s_journal);
5653-
sbi->s_journal = NULL;
5650+
ext4_journal_destroy(sbi, sbi->s_journal);
56545651
}
56555652
failed_mount3a:
56565653
ext4_es_unregister_shrinker(sbi);
@@ -5958,7 +5955,7 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,
59585955
return journal;
59595956

59605957
out_journal:
5961-
jbd2_journal_destroy(journal);
5958+
ext4_journal_destroy(EXT4_SB(sb), journal);
59625959
out_bdev:
59635960
bdev_fput(bdev_file);
59645961
return ERR_PTR(errno);
@@ -6075,8 +6072,7 @@ static int ext4_load_journal(struct super_block *sb,
60756072
EXT4_SB(sb)->s_journal = journal;
60766073
err = ext4_clear_journal_err(sb, es);
60776074
if (err) {
6078-
EXT4_SB(sb)->s_journal = NULL;
6079-
jbd2_journal_destroy(journal);
6075+
ext4_journal_destroy(EXT4_SB(sb), journal);
60806076
return err;
60816077
}
60826078

@@ -6094,7 +6090,7 @@ static int ext4_load_journal(struct super_block *sb,
60946090
return 0;
60956091

60966092
err_out:
6097-
jbd2_journal_destroy(journal);
6093+
ext4_journal_destroy(EXT4_SB(sb), journal);
60986094
return err;
60996095
}
61006096

0 commit comments

Comments
 (0)