jbd2: fix invalid descriptor block checksum
authorluojiajun <luojiajun3@huawei.com>
Fri, 1 Mar 2019 05:30:00 +0000 (00:30 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 1 Mar 2019 05:30:00 +0000 (00:30 -0500)
In jbd2_journal_commit_transaction(), if we are in abort mode,
we may flush the buffer without setting descriptor block checksum
by goto start_journal_io. Then fs is mounted,
jbd2_descriptor_block_csum_verify() failed.

[  271.379811] EXT4-fs (vdd): shut down requested (2)
[  271.381827] Aborting journal on device vdd-8.
[  271.597136] JBD2: Invalid checksum recovering block 22199 in log
[  271.598023] JBD2: recovery failed
[  271.598484] EXT4-fs (vdd): error loading journal

Fix this problem by keep setting descriptor block checksum if the
descriptor buffer is not NULL.

This checksum problem can be reproduced by xfstests generic/388.

Signed-off-by: luojiajun <luojiajun3@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>
fs/jbd2/commit.c

index 2eb55c3361a8b170afd64bc807c28408d24127e7..efd0ce9489ae9d453d37abd4a66b8ad574fa5b4b 100644 (file)
@@ -694,9 +694,11 @@ void jbd2_journal_commit_transaction(journal_t *journal)
                            the last tag we set up. */
 
                        tag->t_flags |= cpu_to_be16(JBD2_FLAG_LAST_TAG);
-
-                       jbd2_descriptor_block_csum_set(journal, descriptor);
 start_journal_io:
+                       if (descriptor)
+                               jbd2_descriptor_block_csum_set(journal,
+                                                       descriptor);
+
                        for (i = 0; i < bufs; i++) {
                                struct buffer_head *bh = wbuf[i];
                                /*