@@ -829,13 +829,16 @@ static int get_stripe_key_trans(struct btree_trans *trans, u64 idx,
829
829
}
830
830
831
831
/* recovery read path: */
832
- int bch2_ec_read_extent (struct btree_trans * trans , struct bch_read_bio * rbio )
832
+ int bch2_ec_read_extent (struct btree_trans * trans , struct bch_read_bio * rbio ,
833
+ struct bkey_s_c orig_k )
833
834
{
834
835
struct bch_fs * c = trans -> c ;
835
- struct ec_stripe_buf * buf ;
836
+ struct ec_stripe_buf * buf = NULL ;
836
837
struct closure cl ;
837
838
struct bch_stripe * v ;
838
839
unsigned i , offset ;
840
+ const char * msg = NULL ;
841
+ struct printbuf msgbuf = PRINTBUF ;
839
842
int ret = 0 ;
840
843
841
844
closure_init_stack (& cl );
@@ -848,42 +851,36 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
848
851
849
852
ret = lockrestart_do (trans , get_stripe_key_trans (trans , rbio -> pick .ec .idx , buf ));
850
853
if (ret ) {
851
- bch_err_ratelimited (c ,
852
- "error doing reconstruct read: error %i looking up stripe" , ret );
853
- kfree (buf );
854
- return - BCH_ERR_stripe_reconstruct ;
854
+ msg = "stripe not found" ;
855
+ goto err ;
855
856
}
856
857
857
858
v = & bkey_i_to_stripe (& buf -> key )-> v ;
858
859
859
860
if (!bch2_ptr_matches_stripe (v , rbio -> pick )) {
860
- bch_err_ratelimited (c ,
861
- "error doing reconstruct read: pointer doesn't match stripe" );
862
- ret = - BCH_ERR_stripe_reconstruct ;
861
+ msg = "pointer doesn't match stripe" ;
863
862
goto err ;
864
863
}
865
864
866
865
offset = rbio -> bio .bi_iter .bi_sector - v -> ptrs [rbio -> pick .ec .block ].offset ;
867
866
if (offset + bio_sectors (& rbio -> bio ) > le16_to_cpu (v -> sectors )) {
868
- bch_err_ratelimited (c ,
869
- "error doing reconstruct read: read is bigger than stripe" );
870
- ret = - BCH_ERR_stripe_reconstruct ;
867
+ msg = "read is bigger than stripe" ;
871
868
goto err ;
872
869
}
873
870
874
871
ret = ec_stripe_buf_init (buf , offset , bio_sectors (& rbio -> bio ));
875
- if (ret )
872
+ if (ret ) {
873
+ msg = "-ENOMEM" ;
876
874
goto err ;
875
+ }
877
876
878
877
for (i = 0 ; i < v -> nr_blocks ; i ++ )
879
878
ec_block_io (c , buf , REQ_OP_READ , i , & cl );
880
879
881
880
closure_sync (& cl );
882
881
883
882
if (ec_nr_failed (buf ) > v -> nr_redundant ) {
884
- bch_err_ratelimited (c ,
885
- "error doing reconstruct read: unable to read enough blocks" );
886
- ret = - BCH_ERR_stripe_reconstruct ;
883
+ msg = "unable to read enough blocks" ;
887
884
goto err ;
888
885
}
889
886
@@ -895,10 +892,17 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
895
892
896
893
memcpy_to_bio (& rbio -> bio , rbio -> bio .bi_iter ,
897
894
buf -> data [rbio -> pick .ec .block ] + ((offset - buf -> offset ) << 9 ));
898
- err :
895
+ out :
899
896
ec_stripe_buf_exit (buf );
900
897
kfree (buf );
901
898
return ret ;
899
+ err :
900
+ bch2_bkey_val_to_text (& msgbuf , c , orig_k );
901
+ bch_err_ratelimited (c ,
902
+ "error doing reconstruct read: %s\n %s" , msg , msgbuf .buf );
903
+ printbuf_exit (& msgbuf );;
904
+ ret = - BCH_ERR_stripe_reconstruct ;
905
+ goto out ;
902
906
}
903
907
904
908
/* stripe bucket accounting: */
0 commit comments