Skip to content

Commit b2cc32a

Browse files
OjaswinMharshimogalapalli
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 <[email protected]> Reviewed-by: Baokun Li <[email protected]> Signed-off-by: Ojaswin Mujoo <[email protected]> Link: https://patch.msgid.link/c3ba78c5c419757e6d5f2d8ebb4a8ce9d21da86a.1742279837.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit c868e9306ea6fbb823c18eb96090a10dce16cc4d) Signed-off-by: Harshit Mogalapalli <[email protected]>
1 parent fe71097 commit b2cc32a

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
}
@@ -4987,8 +4986,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
49874986
out:
49884987
/* flush s_sb_upd_work before destroying the journal. */
49894988
flush_work(&sbi->s_sb_upd_work);
4990-
jbd2_journal_destroy(sbi->s_journal);
4991-
sbi->s_journal = NULL;
4989+
ext4_journal_destroy(sbi, sbi->s_journal);
49924990
return -EINVAL;
49934991
}
49944992

@@ -5680,8 +5678,7 @@ failed_mount8: __maybe_unused
56805678
if (sbi->s_journal) {
56815679
/* flush s_sb_upd_work before journal destroy. */
56825680
flush_work(&sbi->s_sb_upd_work);
5683-
jbd2_journal_destroy(sbi->s_journal);
5684-
sbi->s_journal = NULL;
5681+
ext4_journal_destroy(sbi, sbi->s_journal);
56855682
}
56865683
failed_mount3a:
56875684
ext4_es_unregister_shrinker(sbi);
@@ -5989,7 +5986,7 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,
59895986
return journal;
59905987

59915988
out_journal:
5992-
jbd2_journal_destroy(journal);
5989+
ext4_journal_destroy(EXT4_SB(sb), journal);
59935990
out_bdev:
59945991
bdev_fput(bdev_file);
59955992
return ERR_PTR(errno);
@@ -6106,8 +6103,7 @@ static int ext4_load_journal(struct super_block *sb,
61066103
EXT4_SB(sb)->s_journal = journal;
61076104
err = ext4_clear_journal_err(sb, es);
61086105
if (err) {
6109-
EXT4_SB(sb)->s_journal = NULL;
6110-
jbd2_journal_destroy(journal);
6106+
ext4_journal_destroy(EXT4_SB(sb), journal);
61116107
return err;
61126108
}
61136109

@@ -6125,7 +6121,7 @@ static int ext4_load_journal(struct super_block *sb,
61256121
return 0;
61266122

61276123
err_out:
6128-
jbd2_journal_destroy(journal);
6124+
ext4_journal_destroy(EXT4_SB(sb), journal);
61296125
return err;
61306126
}
61316127

0 commit comments

Comments
 (0)