@@ -493,7 +493,7 @@ static int do_one_pass(journal_t *journal,
493493 int err , success = 0 ;
494494 journal_superblock_t * sb ;
495495 journal_header_t * tmp ;
496- struct buffer_head * bh ;
496+ struct buffer_head * bh = NULL ;
497497 unsigned int sequence ;
498498 int blocktype ;
499499 int tag_bytes = journal_tag_bytes (journal );
@@ -552,6 +552,8 @@ static int do_one_pass(journal_t *journal,
552552 * record. */
553553
554554 jbd2_debug (3 , "JBD2: checking block %ld\n" , next_log_block );
555+ brelse (bh );
556+ bh = NULL ;
555557 err = jread (& bh , journal , next_log_block );
556558 if (err )
557559 goto failed ;
@@ -567,20 +569,16 @@ static int do_one_pass(journal_t *journal,
567569
568570 tmp = (journal_header_t * )bh -> b_data ;
569571
570- if (tmp -> h_magic != cpu_to_be32 (JBD2_MAGIC_NUMBER )) {
571- brelse (bh );
572+ if (tmp -> h_magic != cpu_to_be32 (JBD2_MAGIC_NUMBER ))
572573 break ;
573- }
574574
575575 blocktype = be32_to_cpu (tmp -> h_blocktype );
576576 sequence = be32_to_cpu (tmp -> h_sequence );
577577 jbd2_debug (3 , "Found magic %d, sequence %d\n" ,
578578 blocktype , sequence );
579579
580- if (sequence != next_commit_ID ) {
581- brelse (bh );
580+ if (sequence != next_commit_ID )
582581 break ;
583- }
584582
585583 /* OK, we have a valid descriptor block which matches
586584 * all of the sequence number checks. What are we going
@@ -603,7 +601,6 @@ static int do_one_pass(journal_t *journal,
603601 pr_err ("JBD2: Invalid checksum recovering block %lu in log\n" ,
604602 next_log_block );
605603 err = - EFSBADCRC ;
606- brelse (bh );
607604 goto failed ;
608605 }
609606 need_check_commit_time = true;
@@ -622,16 +619,12 @@ static int do_one_pass(journal_t *journal,
622619 !info -> end_transaction ) {
623620 if (calc_chksums (journal , bh ,
624621 & next_log_block ,
625- & crc32_sum )) {
626- put_bh (bh );
622+ & crc32_sum ))
627623 break ;
628- }
629- put_bh (bh );
630624 continue ;
631625 }
632626 next_log_block += count_tags (journal , bh );
633627 wrap (journal , next_log_block );
634- put_bh (bh );
635628 continue ;
636629 }
637630
@@ -701,7 +694,6 @@ static int do_one_pass(journal_t *journal,
701694 "JBD2: Out of memory "
702695 "during recovery.\n" );
703696 err = - ENOMEM ;
704- brelse (bh );
705697 brelse (obh );
706698 goto failed ;
707699 }
@@ -733,7 +725,6 @@ static int do_one_pass(journal_t *journal,
733725 break ;
734726 }
735727
736- brelse (bh );
737728 continue ;
738729
739730 case JBD2_COMMIT_BLOCK :
@@ -781,7 +772,6 @@ static int do_one_pass(journal_t *journal,
781772 pr_err ("JBD2: Invalid checksum found in transaction %u\n" ,
782773 next_commit_ID );
783774 err = - EFSBADCRC ;
784- brelse (bh );
785775 goto failed ;
786776 }
787777 ignore_crc_mismatch :
@@ -791,7 +781,6 @@ static int do_one_pass(journal_t *journal,
791781 */
792782 jbd2_debug (1 , "JBD2: Invalid checksum ignored in transaction %u, likely stale data\n" ,
793783 next_commit_ID );
794- brelse (bh );
795784 goto done ;
796785 }
797786
@@ -811,7 +800,6 @@ static int do_one_pass(journal_t *journal,
811800 if (info -> end_transaction ) {
812801 journal -> j_failed_commit =
813802 info -> end_transaction ;
814- brelse (bh );
815803 break ;
816804 }
817805
@@ -847,7 +835,6 @@ static int do_one_pass(journal_t *journal,
847835 if (!jbd2_has_feature_async_commit (journal )) {
848836 journal -> j_failed_commit =
849837 next_commit_ID ;
850- brelse (bh );
851838 break ;
852839 }
853840 }
@@ -856,7 +843,6 @@ static int do_one_pass(journal_t *journal,
856843 last_trans_commit_time = commit_time ;
857844 head_block = next_log_block ;
858845 }
859- brelse (bh );
860846 next_commit_ID ++ ;
861847 continue ;
862848
@@ -875,27 +861,24 @@ static int do_one_pass(journal_t *journal,
875861
876862 /* If we aren't in the REVOKE pass, then we can
877863 * just skip over this block. */
878- if (pass != PASS_REVOKE ) {
879- brelse (bh );
864+ if (pass != PASS_REVOKE )
880865 continue ;
881- }
882866
883867 err = scan_revoke_records (journal , bh ,
884868 next_commit_ID , info );
885- brelse (bh );
886869 if (err )
887870 goto failed ;
888871 continue ;
889872
890873 default :
891874 jbd2_debug (3 , "Unrecognised magic %d, end of scan.\n" ,
892875 blocktype );
893- brelse (bh );
894876 goto done ;
895877 }
896878 }
897879
898880 done :
881+ brelse (bh );
899882 /*
900883 * We broke out of the log scan loop: either we came to the
901884 * known end of the log or we found an unexpected block in the
@@ -931,6 +914,7 @@ static int do_one_pass(journal_t *journal,
931914 return success ;
932915
933916 failed :
917+ brelse (bh );
934918 return err ;
935919}
936920
0 commit comments