@@ -541,7 +541,6 @@ static void __bch2_read_endio(struct work_struct *work)
541541 struct bch_read_bio * rbio =
542542 container_of (work , struct bch_read_bio , work );
543543 struct bch_fs * c = rbio -> c ;
544- struct bch_dev * ca = bch2_dev_bkey_exists (c , rbio -> pick .ptr .dev );
545544 struct bio * src = & rbio -> bio ;
546545 struct bio * dst = & bch2_rbio_parent (rbio )-> bio ;
547546 struct bvec_iter dst_iter = rbio -> bvec_iter ;
@@ -647,13 +646,15 @@ static void __bch2_read_endio(struct work_struct *work)
647646 prt_str (& buf , "data " );
648647 bch2_csum_err_msg (& buf , crc .csum_type , rbio -> pick .crc .csum , csum );
649648
650- bch_err_inum_offset_ratelimited (ca ,
651- rbio -> read_pos .inode ,
652- rbio -> read_pos .offset << 9 ,
653- "data %s" , buf .buf );
649+ struct bch_dev * ca = rbio -> have_ioref ? bch2_dev_have_ref (c , rbio -> pick .ptr .dev ) : NULL ;
650+ if (ca ) {
651+ bch_err_inum_offset_ratelimited (ca ,
652+ rbio -> read_pos .inode ,
653+ rbio -> read_pos .offset << 9 ,
654+ "data %s" , buf .buf );
655+ bch2_io_error (ca , BCH_MEMBER_ERROR_checksum );
656+ }
654657 printbuf_exit (& buf );
655-
656- bch2_io_error (ca , BCH_MEMBER_ERROR_checksum );
657658 bch2_rbio_error (rbio , READ_RETRY_AVOID , BLK_STS_IOERR );
658659 goto out ;
659660decompression_err :
@@ -675,7 +676,7 @@ static void bch2_read_endio(struct bio *bio)
675676 struct bch_read_bio * rbio =
676677 container_of (bio , struct bch_read_bio , bio );
677678 struct bch_fs * c = rbio -> c ;
678- struct bch_dev * ca = bch2_dev_bkey_exists (c , rbio -> pick .ptr .dev );
679+ struct bch_dev * ca = rbio -> have_ioref ? bch2_dev_have_ref (c , rbio -> pick .ptr .dev ) : NULL ;
679680 struct workqueue_struct * wq = NULL ;
680681 enum rbio_context context = RBIO_CONTEXT_NULL ;
681682
@@ -687,17 +688,21 @@ static void bch2_read_endio(struct bio *bio)
687688 if (!rbio -> split )
688689 rbio -> bio .bi_end_io = rbio -> end_io ;
689690
690- if (bch2_dev_inum_io_err_on (bio -> bi_status , ca , BCH_MEMBER_ERROR_read ,
691- rbio -> read_pos .inode ,
692- rbio -> read_pos .offset ,
693- "data read error: %s" ,
694- bch2_blk_status_to_str (bio -> bi_status ))) {
691+ if (bio -> bi_status ) {
692+ if (ca ) {
693+ bch_err_inum_offset_ratelimited (ca ,
694+ rbio -> read_pos .inode ,
695+ rbio -> read_pos .offset ,
696+ "data read error: %s" ,
697+ bch2_blk_status_to_str (bio -> bi_status ));
698+ bch2_io_error (ca , BCH_MEMBER_ERROR_read );
699+ }
695700 bch2_rbio_error (rbio , READ_RETRY_AVOID , bio -> bi_status );
696701 return ;
697702 }
698703
699704 if (((rbio -> flags & BCH_READ_RETRY_IF_STALE ) && race_fault ()) ||
700- dev_ptr_stale (ca , & rbio -> pick .ptr )) {
705+ ( ca && dev_ptr_stale (ca , & rbio -> pick .ptr ) )) {
701706 trace_and_count (c , read_reuse_race , & rbio -> bio );
702707
703708 if (rbio -> flags & BCH_READ_RETRY_IF_STALE )
0 commit comments