]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: spot check clean journals
authorDarrick J. Wong <djwong@kernel.org>
Tue, 7 Oct 2025 21:10:18 +0000 (14:10 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 17 Oct 2025 23:34:22 +0000 (16:34 -0700)
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: <linux-ext4@vger.kernel.org> # v1.43
Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
debugfs/journal.c
debugfs/journal.h
misc/fuse2fs.c

index a6d8d4c5adf9cf9119b47f627986fea55e5c919c..f79abcccf6adead3da886907364eba83a94d5ab3 100644 (file)
@@ -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;
index 10b638ebaab5db658f3d794275ff82393d24fbb1..67b8c99828bb0d795828e78ffd3e3e2c8c978726 100644 (file)
@@ -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);
index 210807ea493f51954229cb3495934c78ca72ee18..e33b09de08a11fcee975e5ec7d00076d2d09cc1e 100644 (file)
@@ -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) {