@@ -493,7 +493,7 @@ static int do_one_pass(journal_t *journal,
493
493
int err , success = 0 ;
494
494
journal_superblock_t * sb ;
495
495
journal_header_t * tmp ;
496
- struct buffer_head * bh ;
496
+ struct buffer_head * bh = NULL ;
497
497
unsigned int sequence ;
498
498
int blocktype ;
499
499
int tag_bytes = journal_tag_bytes (journal );
@@ -552,6 +552,8 @@ static int do_one_pass(journal_t *journal,
552
552
* record. */
553
553
554
554
jbd2_debug (3 , "JBD2: checking block %ld\n" , next_log_block );
555
+ brelse (bh );
556
+ bh = NULL ;
555
557
err = jread (& bh , journal , next_log_block );
556
558
if (err )
557
559
goto failed ;
@@ -567,20 +569,16 @@ static int do_one_pass(journal_t *journal,
567
569
568
570
tmp = (journal_header_t * )bh -> b_data ;
569
571
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 ))
572
573
break ;
573
- }
574
574
575
575
blocktype = be32_to_cpu (tmp -> h_blocktype );
576
576
sequence = be32_to_cpu (tmp -> h_sequence );
577
577
jbd2_debug (3 , "Found magic %d, sequence %d\n" ,
578
578
blocktype , sequence );
579
579
580
- if (sequence != next_commit_ID ) {
581
- brelse (bh );
580
+ if (sequence != next_commit_ID )
582
581
break ;
583
- }
584
582
585
583
/* OK, we have a valid descriptor block which matches
586
584
* all of the sequence number checks. What are we going
@@ -603,7 +601,6 @@ static int do_one_pass(journal_t *journal,
603
601
pr_err ("JBD2: Invalid checksum recovering block %lu in log\n" ,
604
602
next_log_block );
605
603
err = - EFSBADCRC ;
606
- brelse (bh );
607
604
goto failed ;
608
605
}
609
606
need_check_commit_time = true;
@@ -622,16 +619,12 @@ static int do_one_pass(journal_t *journal,
622
619
!info -> end_transaction ) {
623
620
if (calc_chksums (journal , bh ,
624
621
& next_log_block ,
625
- & crc32_sum )) {
626
- put_bh (bh );
622
+ & crc32_sum ))
627
623
break ;
628
- }
629
- put_bh (bh );
630
624
continue ;
631
625
}
632
626
next_log_block += count_tags (journal , bh );
633
627
wrap (journal , next_log_block );
634
- put_bh (bh );
635
628
continue ;
636
629
}
637
630
@@ -701,7 +694,6 @@ static int do_one_pass(journal_t *journal,
701
694
"JBD2: Out of memory "
702
695
"during recovery.\n" );
703
696
err = - ENOMEM ;
704
- brelse (bh );
705
697
brelse (obh );
706
698
goto failed ;
707
699
}
@@ -733,7 +725,6 @@ static int do_one_pass(journal_t *journal,
733
725
break ;
734
726
}
735
727
736
- brelse (bh );
737
728
continue ;
738
729
739
730
case JBD2_COMMIT_BLOCK :
@@ -781,7 +772,6 @@ static int do_one_pass(journal_t *journal,
781
772
pr_err ("JBD2: Invalid checksum found in transaction %u\n" ,
782
773
next_commit_ID );
783
774
err = - EFSBADCRC ;
784
- brelse (bh );
785
775
goto failed ;
786
776
}
787
777
ignore_crc_mismatch :
@@ -791,7 +781,6 @@ static int do_one_pass(journal_t *journal,
791
781
*/
792
782
jbd2_debug (1 , "JBD2: Invalid checksum ignored in transaction %u, likely stale data\n" ,
793
783
next_commit_ID );
794
- brelse (bh );
795
784
goto done ;
796
785
}
797
786
@@ -811,7 +800,6 @@ static int do_one_pass(journal_t *journal,
811
800
if (info -> end_transaction ) {
812
801
journal -> j_failed_commit =
813
802
info -> end_transaction ;
814
- brelse (bh );
815
803
break ;
816
804
}
817
805
@@ -847,7 +835,6 @@ static int do_one_pass(journal_t *journal,
847
835
if (!jbd2_has_feature_async_commit (journal )) {
848
836
journal -> j_failed_commit =
849
837
next_commit_ID ;
850
- brelse (bh );
851
838
break ;
852
839
}
853
840
}
@@ -856,7 +843,6 @@ static int do_one_pass(journal_t *journal,
856
843
last_trans_commit_time = commit_time ;
857
844
head_block = next_log_block ;
858
845
}
859
- brelse (bh );
860
846
next_commit_ID ++ ;
861
847
continue ;
862
848
@@ -875,27 +861,24 @@ static int do_one_pass(journal_t *journal,
875
861
876
862
/* If we aren't in the REVOKE pass, then we can
877
863
* just skip over this block. */
878
- if (pass != PASS_REVOKE ) {
879
- brelse (bh );
864
+ if (pass != PASS_REVOKE )
880
865
continue ;
881
- }
882
866
883
867
err = scan_revoke_records (journal , bh ,
884
868
next_commit_ID , info );
885
- brelse (bh );
886
869
if (err )
887
870
goto failed ;
888
871
continue ;
889
872
890
873
default :
891
874
jbd2_debug (3 , "Unrecognised magic %d, end of scan.\n" ,
892
875
blocktype );
893
- brelse (bh );
894
876
goto done ;
895
877
}
896
878
}
897
879
898
880
done :
881
+ brelse (bh );
899
882
/*
900
883
* We broke out of the log scan loop: either we came to the
901
884
* 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,
931
914
return success ;
932
915
933
916
failed :
917
+ brelse (bh );
934
918
return err ;
935
919
}
936
920
0 commit comments