Skip to content

Commit 5a02a62

Browse files
OjaswinMtytso
authored andcommitted
ext4: define ext4_journal_destroy wrapper
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>
1 parent 1e93d6f commit 5a02a62

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
@@ -429,4 +429,18 @@ static inline int ext4_should_dioread_nolock(struct inode *inode)
429429
return 1;
430430
}
431431

432+
/*
433+
* Pass journal explicitly as it may not be cached in the sbi->s_journal in some
434+
* cases
435+
*/
436+
static inline int ext4_journal_destroy(struct ext4_sb_info *sbi, journal_t *journal)
437+
{
438+
int err = 0;
439+
440+
err = jbd2_journal_destroy(journal);
441+
sbi->s_journal = NULL;
442+
443+
return err;
444+
}
445+
432446
#endif /* _EXT4_JBD2_H */

fs/ext4/super.c

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

12971297
if (sbi->s_journal) {
12981298
aborted = is_journal_aborted(sbi->s_journal);
1299-
err = jbd2_journal_destroy(sbi->s_journal);
1300-
sbi->s_journal = NULL;
1299+
err = ext4_journal_destroy(sbi, sbi->s_journal);
13011300
if ((err < 0) && !aborted) {
13021301
ext4_abort(sb, -err, "Couldn't clean up the journal");
13031302
}
@@ -4974,8 +4973,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
49744973
out:
49754974
/* flush s_sb_upd_work before destroying the journal. */
49764975
flush_work(&sbi->s_sb_upd_work);
4977-
jbd2_journal_destroy(sbi->s_journal);
4978-
sbi->s_journal = NULL;
4976+
ext4_journal_destroy(sbi, sbi->s_journal);
49794977
return -EINVAL;
49804978
}
49814979

@@ -5673,8 +5671,7 @@ failed_mount8: __maybe_unused
56735671
if (sbi->s_journal) {
56745672
/* flush s_sb_upd_work before journal destroy. */
56755673
flush_work(&sbi->s_sb_upd_work);
5676-
jbd2_journal_destroy(sbi->s_journal);
5677-
sbi->s_journal = NULL;
5674+
ext4_journal_destroy(sbi, sbi->s_journal);
56785675
}
56795676
failed_mount3a:
56805677
ext4_es_unregister_shrinker(sbi);
@@ -5975,7 +5972,7 @@ static journal_t *ext4_open_dev_journal(struct super_block *sb,
59755972
return journal;
59765973

59775974
out_journal:
5978-
jbd2_journal_destroy(journal);
5975+
ext4_journal_destroy(EXT4_SB(sb), journal);
59795976
out_bdev:
59805977
bdev_fput(bdev_file);
59815978
return ERR_PTR(errno);
@@ -6092,8 +6089,7 @@ static int ext4_load_journal(struct super_block *sb,
60926089
EXT4_SB(sb)->s_journal = journal;
60936090
err = ext4_clear_journal_err(sb, es);
60946091
if (err) {
6095-
EXT4_SB(sb)->s_journal = NULL;
6096-
jbd2_journal_destroy(journal);
6092+
ext4_journal_destroy(EXT4_SB(sb), journal);
60976093
return err;
60986094
}
60996095

@@ -6111,7 +6107,7 @@ static int ext4_load_journal(struct super_block *sb,
61116107
return 0;
61126108

61136109
err_out:
6114-
jbd2_journal_destroy(journal);
6110+
ext4_journal_destroy(EXT4_SB(sb), journal);
61156111
return err;
61166112
}
61176113

0 commit comments

Comments
 (0)