Skip to content

Commit 69a2f79

Browse files
author
Brian Foster
committed
ext4: define ext4_journal_destroy wrapper
JIRA: https://issues.redhat.com/browse/RHEL-93593 commit 5a02a62 Author: Ojaswin Mujoo <ojaswin@linux.ibm.com> Date: Tue Mar 18 13:22:55 2025 +0530 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> Signed-off-by: Brian Foster <bfoster@redhat.com>
1 parent 6e54f33 commit 69a2f79

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
@@ -1242,8 +1242,7 @@ static void ext4_put_super(struct super_block *sb)
12421242

12431243
if (sbi->s_journal) {
12441244
aborted = is_journal_aborted(sbi->s_journal);
1245-
err = jbd2_journal_destroy(sbi->s_journal);
1246-
sbi->s_journal = NULL;
1245+
err = ext4_journal_destroy(sbi, sbi->s_journal);
12471246
if ((err < 0) && !aborted) {
12481247
ext4_abort(sb, -err, "Couldn't clean up the journal");
12491248
}
@@ -4909,8 +4908,7 @@ static int ext4_load_and_init_journal(struct super_block *sb,
49094908
out:
49104909
/* flush s_sb_upd_work before destroying the journal. */
49114910
flush_work(&sbi->s_sb_upd_work);
4912-
jbd2_journal_destroy(sbi->s_journal);
4913-
sbi->s_journal = NULL;
4911+
ext4_journal_destroy(sbi, sbi->s_journal);
49144912
return -EINVAL;
49154913
}
49164914

@@ -5674,8 +5672,7 @@ failed_mount8: __maybe_unused
56745672
if (sbi->s_journal) {
56755673
/* flush s_sb_upd_work before journal destroy. */
56765674
flush_work(&sbi->s_sb_upd_work);
5677-
jbd2_journal_destroy(sbi->s_journal);
5678-
sbi->s_journal = NULL;
5675+
ext4_journal_destroy(sbi, sbi->s_journal);
56795676
}
56805677
failed_mount3a:
56815678
ext4_es_unregister_shrinker(sbi);
@@ -5962,7 +5959,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
59625959
return journal;
59635960

59645961
out_journal:
5965-
jbd2_journal_destroy(journal);
5962+
ext4_journal_destroy(EXT4_SB(sb), journal);
59665963
out_bdev:
59675964
bdev_fput(bdev_file);
59685965
return NULL;
@@ -6079,8 +6076,7 @@ static int ext4_load_journal(struct super_block *sb,
60796076
EXT4_SB(sb)->s_journal = journal;
60806077
err = ext4_clear_journal_err(sb, es);
60816078
if (err) {
6082-
EXT4_SB(sb)->s_journal = NULL;
6083-
jbd2_journal_destroy(journal);
6079+
ext4_journal_destroy(EXT4_SB(sb), journal);
60846080
return err;
60856081
}
60866082

@@ -6098,7 +6094,7 @@ static int ext4_load_journal(struct super_block *sb,
60986094
return 0;
60996095

61006096
err_out:
6101-
jbd2_journal_destroy(journal);
6097+
ext4_journal_destroy(EXT4_SB(sb), journal);
61026098
return err;
61036099
}
61046100

0 commit comments

Comments
 (0)