From: Darrick J. Wong Date: Tue, 7 Oct 2025 21:10:18 +0000 (-0700) Subject: fuse2fs: spot check clean journals X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cc09f5bb67474e2b2f29f0a6211552757707ce6e;p=thirdparty%2Fe2fsprogs.git fuse2fs: spot check clean journals Even though fuse2fs doesn't (yet) support writing new transactions to the journal, we ought at least to check that the superblock is ok when we mount a clean filesystem. This fixes complaints by ext4/012 about mount failing to notice a corrupt journal. Cc: # v1.43 Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs") Signed-off-by: "Darrick J. Wong" --- diff --git a/debugfs/journal.c b/debugfs/journal.c index a6d8d4c5..f79abccc 100644 --- a/debugfs/journal.c +++ b/debugfs/journal.c @@ -681,7 +681,7 @@ static void ext2fs_journal_release(ext2_filsys fs, journal_t *journal, * This function makes sure that the superblock fields regarding the * journal are consistent. */ -static errcode_t ext2fs_check_ext3_journal(ext2_filsys fs) +errcode_t ext2fs_check_ext3_journal(ext2_filsys fs) { struct ext2_super_block *sb = fs->super; journal_t *journal; diff --git a/debugfs/journal.h b/debugfs/journal.h index 10b638eb..67b8c998 100644 --- a/debugfs/journal.h +++ b/debugfs/journal.h @@ -18,6 +18,8 @@ errcode_t ext2fs_open_journal(ext2_filsys fs, journal_t **j); errcode_t ext2fs_close_journal(ext2_filsys fs, journal_t **j); errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs); +errcode_t ext2fs_check_ext3_journal(ext2_filsys fs); + void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh); void jbd2_revoke_csum_set(journal_t *j, struct buffer_head *bh); void jbd2_descr_block_csum_set(journal_t *j, struct buffer_head *bh); diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 210807ea..e33b09de 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -192,6 +192,7 @@ static inline uint64_t round_down(uint64_t b, unsigned int align) # define FL_ZERO_RANGE_FLAG (0) #endif +errcode_t ext2fs_check_ext3_journal(ext2_filsys fs); errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs); #ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jbd-debug */ @@ -4819,6 +4820,12 @@ int main(int argc, char *argv[]) ext2fs_clear_feature_journal_needs_recovery(global_fs->super); ext2fs_mark_super_dirty(global_fs); } + } else if (ext2fs_has_feature_journal(global_fs->super)) { + err = ext2fs_check_ext3_journal(global_fs); + if (err) { + translate_error(global_fs, 0, err); + goto out; + } } if (global_fs->flags & EXT2_FLAG_RW) {