@@ -434,12 +434,6 @@ void bch2_write_op_error(struct bch_write_op *op, u64 offset, const char *fmt, .
434434 printbuf_exit (& buf );
435435}
436436
437- static void bch2_write_csum_err_msg (struct bch_write_op * op )
438- {
439- bch2_write_op_error (op , op -> pos .offset ,
440- "error verifying existing checksum while rewriting existing data (memory corruption?)" );
441- }
442-
443437void bch2_submit_wbio_replicas (struct bch_write_bio * wbio , struct bch_fs * c ,
444438 enum bch_data_type type ,
445439 const struct bkey_i * k ,
@@ -839,6 +833,7 @@ static noinline int bch2_write_prep_encoded_data(struct bch_write_op *op, struct
839833{
840834 struct bch_fs * c = op -> c ;
841835 struct bio * bio = & op -> wbio .bio ;
836+ struct bch_csum csum ;
842837 int ret = 0 ;
843838
844839 BUG_ON (bio_sectors (bio ) != op -> crc .compressed_size );
@@ -866,7 +861,7 @@ static noinline int bch2_write_prep_encoded_data(struct bch_write_op *op, struct
866861 if (crc_is_compressed (op -> crc )) {
867862 /* Last point we can still verify checksum: */
868863 struct nonce nonce = extent_nonce (op -> version , op -> crc );
869- struct bch_csum csum = bch2_checksum_bio (c , op -> crc .csum_type , nonce , bio );
864+ csum = bch2_checksum_bio (c , op -> crc .csum_type , nonce , bio );
870865 if (bch2_crc_cmp (op -> crc .csum , csum ) && !c -> opts .no_data_io )
871866 goto csum_err ;
872867
@@ -906,7 +901,7 @@ static noinline int bch2_write_prep_encoded_data(struct bch_write_op *op, struct
906901 if (bch2_csum_type_is_encryption (op -> crc .csum_type ) &&
907902 (op -> compression_opt || op -> crc .csum_type != op -> csum_type )) {
908903 struct nonce nonce = extent_nonce (op -> version , op -> crc );
909- struct bch_csum csum = bch2_checksum_bio (c , op -> crc .csum_type , nonce , bio );
904+ csum = bch2_checksum_bio (c , op -> crc .csum_type , nonce , bio );
910905 if (bch2_crc_cmp (op -> crc .csum , csum ) && !c -> opts .no_data_io )
911906 goto csum_err ;
912907
@@ -920,7 +915,16 @@ static noinline int bch2_write_prep_encoded_data(struct bch_write_op *op, struct
920915
921916 return 0 ;
922917csum_err :
923- bch2_write_csum_err_msg (op );
918+ bch2_write_op_error (op , op -> pos .offset ,
919+ "error verifying existing checksum while moving existing data (memory corruption?)\n"
920+ " expected %0llx:%0llx got %0llx:%0llx type %s" ,
921+ op -> crc .csum .hi ,
922+ op -> crc .csum .lo ,
923+ csum .hi ,
924+ csum .lo ,
925+ op -> crc .csum_type < BCH_CSUM_NR
926+ ? __bch2_csum_types [op -> crc .csum_type ]
927+ : "(unknown)" );
924928 return - BCH_ERR_data_write_csum ;
925929}
926930
@@ -1047,12 +1051,13 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
10471051 * data can't be modified (by userspace) while it's in
10481052 * flight.
10491053 */
1050- if ( bch2_rechecksum_bio (c , src , version , op -> crc ,
1054+ ret = bch2_rechecksum_bio (c , src , version , op -> crc ,
10511055 & crc , & op -> crc ,
10521056 src_len >> 9 ,
10531057 bio_sectors (src ) - (src_len >> 9 ),
1054- op -> csum_type ))
1055- goto csum_err ;
1058+ op -> csum_type );
1059+ if (ret )
1060+ goto err ;
10561061 /*
10571062 * rchecksum_bio sets compression_type on crc from op->crc,
10581063 * this isn't always correct as sometimes we're changing
@@ -1062,12 +1067,12 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
10621067 crc .nonce = nonce ;
10631068 } else {
10641069 if ((op -> flags & BCH_WRITE_data_encoded ) &&
1065- bch2_rechecksum_bio (c , src , version , op -> crc ,
1070+ ( ret = bch2_rechecksum_bio (c , src , version , op -> crc ,
10661071 NULL , & op -> crc ,
10671072 src_len >> 9 ,
10681073 bio_sectors (src ) - (src_len >> 9 ),
1069- op -> crc .csum_type ))
1070- goto csum_err ;
1074+ op -> crc .csum_type )))
1075+ goto err ;
10711076
10721077 crc .compressed_size = dst_len >> 9 ;
10731078 crc .uncompressed_size = src_len >> 9 ;
@@ -1126,9 +1131,6 @@ static int bch2_write_extent(struct bch_write_op *op, struct write_point *wp,
11261131do_write :
11271132 * _dst = dst ;
11281133 return more ;
1129- csum_err :
1130- bch2_write_csum_err_msg (op );
1131- ret = - BCH_ERR_data_write_csum ;
11321134err :
11331135 if (to_wbio (dst )-> bounce )
11341136 bch2_bio_free_pages_pool (c , dst );
0 commit comments