@@ -829,13 +829,16 @@ static int get_stripe_key_trans(struct btree_trans *trans, u64 idx,
829829}
830830
831831/* 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 )
833834{
834835 struct bch_fs * c = trans -> c ;
835- struct ec_stripe_buf * buf ;
836+ struct ec_stripe_buf * buf = NULL ;
836837 struct closure cl ;
837838 struct bch_stripe * v ;
838839 unsigned i , offset ;
840+ const char * msg = NULL ;
841+ struct printbuf msgbuf = PRINTBUF ;
839842 int ret = 0 ;
840843
841844 closure_init_stack (& cl );
@@ -848,42 +851,36 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
848851
849852 ret = lockrestart_do (trans , get_stripe_key_trans (trans , rbio -> pick .ec .idx , buf ));
850853 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 ;
855856 }
856857
857858 v = & bkey_i_to_stripe (& buf -> key )-> v ;
858859
859860 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" ;
863862 goto err ;
864863 }
865864
866865 offset = rbio -> bio .bi_iter .bi_sector - v -> ptrs [rbio -> pick .ec .block ].offset ;
867866 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" ;
871868 goto err ;
872869 }
873870
874871 ret = ec_stripe_buf_init (buf , offset , bio_sectors (& rbio -> bio ));
875- if (ret )
872+ if (ret ) {
873+ msg = "-ENOMEM" ;
876874 goto err ;
875+ }
877876
878877 for (i = 0 ; i < v -> nr_blocks ; i ++ )
879878 ec_block_io (c , buf , REQ_OP_READ , i , & cl );
880879
881880 closure_sync (& cl );
882881
883882 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" ;
887884 goto err ;
888885 }
889886
@@ -895,10 +892,17 @@ int bch2_ec_read_extent(struct btree_trans *trans, struct bch_read_bio *rbio)
895892
896893 memcpy_to_bio (& rbio -> bio , rbio -> bio .bi_iter ,
897894 buf -> data [rbio -> pick .ec .block ] + ((offset - buf -> offset ) << 9 ));
898- err :
895+ out :
899896 ec_stripe_buf_exit (buf );
900897 kfree (buf );
901898 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 ;
902906}
903907
904908/* stripe bucket accounting: */
0 commit comments