@@ -735,6 +735,40 @@ bch2_trans_commit_write_locked(struct btree_trans *trans, unsigned flags,
735735 goto fatal_err ;
736736 }
737737
738+ trans_for_each_update (trans , i ) {
739+ enum bch_validate_flags invalid_flags = 0 ;
740+
741+ if (!(flags & BCH_TRANS_COMMIT_no_journal_res ))
742+ invalid_flags |= BCH_VALIDATE_write |BCH_VALIDATE_commit ;
743+
744+ ret = bch2_bkey_validate (c , bkey_i_to_s_c (i -> k ),
745+ i -> bkey_type , invalid_flags );
746+ if (unlikely (ret )){
747+ bch2_trans_inconsistent (trans , "invalid bkey on insert from %s -> %ps\n" ,
748+ trans -> fn , (void * ) i -> ip_allocated );
749+ goto fatal_err ;
750+ }
751+ btree_insert_entry_checks (trans , i );
752+ }
753+
754+ for (struct jset_entry * i = trans -> journal_entries ;
755+ i != (void * ) ((u64 * ) trans -> journal_entries + trans -> journal_entries_u64s );
756+ i = vstruct_next (i )) {
757+ enum bch_validate_flags invalid_flags = 0 ;
758+
759+ if (!(flags & BCH_TRANS_COMMIT_no_journal_res ))
760+ invalid_flags |= BCH_VALIDATE_write |BCH_VALIDATE_commit ;
761+
762+ ret = bch2_journal_entry_validate (c , NULL , i ,
763+ bcachefs_metadata_version_current ,
764+ CPU_BIG_ENDIAN , invalid_flags );
765+ if (unlikely (ret )) {
766+ bch2_trans_inconsistent (trans , "invalid journal entry on insert from %s\n" ,
767+ trans -> fn );
768+ goto fatal_err ;
769+ }
770+ }
771+
738772 if (likely (!(flags & BCH_TRANS_COMMIT_no_journal_res ))) {
739773 struct journal * j = & c -> journal ;
740774 struct jset_entry * entry ;
@@ -1019,40 +1053,6 @@ int __bch2_trans_commit(struct btree_trans *trans, unsigned flags)
10191053 if (ret )
10201054 goto out_reset ;
10211055
1022- trans_for_each_update (trans , i ) {
1023- enum bch_validate_flags invalid_flags = 0 ;
1024-
1025- if (!(flags & BCH_TRANS_COMMIT_no_journal_res ))
1026- invalid_flags |= BCH_VALIDATE_write |BCH_VALIDATE_commit ;
1027-
1028- ret = bch2_bkey_validate (c , bkey_i_to_s_c (i -> k ),
1029- i -> bkey_type , invalid_flags );
1030- if (unlikely (ret )){
1031- bch2_trans_inconsistent (trans , "invalid bkey on insert from %s -> %ps\n" ,
1032- trans -> fn , (void * ) i -> ip_allocated );
1033- return ret ;
1034- }
1035- btree_insert_entry_checks (trans , i );
1036- }
1037-
1038- for (struct jset_entry * i = trans -> journal_entries ;
1039- i != (void * ) ((u64 * ) trans -> journal_entries + trans -> journal_entries_u64s );
1040- i = vstruct_next (i )) {
1041- enum bch_validate_flags invalid_flags = 0 ;
1042-
1043- if (!(flags & BCH_TRANS_COMMIT_no_journal_res ))
1044- invalid_flags |= BCH_VALIDATE_write |BCH_VALIDATE_commit ;
1045-
1046- ret = bch2_journal_entry_validate (c , NULL , i ,
1047- bcachefs_metadata_version_current ,
1048- CPU_BIG_ENDIAN , invalid_flags );
1049- if (unlikely (ret )) {
1050- bch2_trans_inconsistent (trans , "invalid journal entry on insert from %s\n" ,
1051- trans -> fn );
1052- return ret ;
1053- }
1054- }
1055-
10561056 if (unlikely (!test_bit (BCH_FS_may_go_rw , & c -> flags ))) {
10571057 ret = do_bch2_trans_commit_to_journal_replay (trans );
10581058 goto out_reset ;
0 commit comments