Skip to content

Commit a805ae3

Browse files
Ye Bintytso
authored andcommitted
jbd2: refactor JBD2_COMMIT_BLOCK process in do_one_pass()
To make JBD2_COMMIT_BLOCK process more clean, no functional change. Signed-off-by: Ye Bin <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Zhang Yi <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 4c19924 commit a805ae3

File tree

1 file changed

+29
-26
lines changed

1 file changed

+29
-26
lines changed

fs/jbd2/recovery.c

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,11 @@ static int do_one_pass(journal_t *journal,
728728
continue;
729729

730730
case JBD2_COMMIT_BLOCK:
731+
if (pass != PASS_SCAN) {
732+
next_commit_ID++;
733+
continue;
734+
}
735+
731736
/* How to differentiate between interrupted commit
732737
* and journal corruption ?
733738
*
@@ -790,8 +795,7 @@ static int do_one_pass(journal_t *journal,
790795
* much to do other than move on to the next sequence
791796
* number.
792797
*/
793-
if (pass == PASS_SCAN &&
794-
jbd2_has_feature_checksum(journal)) {
798+
if (jbd2_has_feature_checksum(journal)) {
795799
struct commit_header *cbh =
796800
(struct commit_header *)bh->b_data;
797801
unsigned found_chksum =
@@ -815,34 +819,33 @@ static int do_one_pass(journal_t *journal,
815819
goto chksum_error;
816820

817821
crc32_sum = ~0;
822+
goto chksum_ok;
818823
}
819-
if (pass == PASS_SCAN &&
820-
!jbd2_commit_block_csum_verify(journal,
821-
bh->b_data)) {
822-
if (jbd2_commit_block_csum_verify_partial(
823-
journal,
824-
bh->b_data)) {
825-
pr_notice("JBD2: Find incomplete commit block in transaction %u block %lu\n",
826-
next_commit_ID, next_log_block);
827-
goto chksum_ok;
828-
}
829-
chksum_error:
830-
if (commit_time < last_trans_commit_time)
831-
goto ignore_crc_mismatch;
832-
info->end_transaction = next_commit_ID;
833-
info->head_block = head_block;
834824

835-
if (!jbd2_has_feature_async_commit(journal)) {
836-
journal->j_failed_commit =
837-
next_commit_ID;
838-
break;
839-
}
825+
if (jbd2_commit_block_csum_verify(journal, bh->b_data))
826+
goto chksum_ok;
827+
828+
if (jbd2_commit_block_csum_verify_partial(journal,
829+
bh->b_data)) {
830+
pr_notice("JBD2: Find incomplete commit block in transaction %u block %lu\n",
831+
next_commit_ID, next_log_block);
832+
goto chksum_ok;
840833
}
841-
if (pass == PASS_SCAN) {
842-
chksum_ok:
843-
last_trans_commit_time = commit_time;
844-
head_block = next_log_block;
834+
835+
chksum_error:
836+
if (commit_time < last_trans_commit_time)
837+
goto ignore_crc_mismatch;
838+
info->end_transaction = next_commit_ID;
839+
info->head_block = head_block;
840+
841+
if (!jbd2_has_feature_async_commit(journal)) {
842+
journal->j_failed_commit = next_commit_ID;
843+
break;
845844
}
845+
846+
chksum_ok:
847+
last_trans_commit_time = commit_time;
848+
head_block = next_log_block;
846849
next_commit_ID++;
847850
continue;
848851

0 commit comments

Comments
 (0)