@@ -182,19 +182,23 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
182182static void submit_one_bio (struct btrfs_bio_ctrl * bio_ctrl )
183183{
184184 struct bio * bio ;
185+ struct bio_vec * bv ;
185186 struct inode * inode ;
186187 int mirror_num ;
187188
188189 if (!bio_ctrl -> bio )
189190 return ;
190191
191192 bio = bio_ctrl -> bio ;
192- inode = bio_first_page_all (bio )-> mapping -> host ;
193+ bv = bio_first_bvec_all (bio );
194+ inode = bv -> bv_page -> mapping -> host ;
193195 mirror_num = bio_ctrl -> mirror_num ;
194196
195197 /* Caller should ensure the bio has at least some range added */
196198 ASSERT (bio -> bi_iter .bi_size );
197199
200+ btrfs_bio (bio )-> file_offset = page_offset (bv -> bv_page ) + bv -> bv_offset ;
201+
198202 if (!is_data_inode (inode ))
199203 btrfs_submit_metadata_bio (inode , bio , mirror_num );
200204 else if (btrfs_op (bio ) == BTRFS_MAP_WRITE )
@@ -2535,10 +2539,11 @@ void btrfs_free_io_failure_record(struct btrfs_inode *inode, u64 start, u64 end)
25352539}
25362540
25372541static struct io_failure_record * btrfs_get_io_failure_record (struct inode * inode ,
2538- u64 start ,
2539- int failed_mirror )
2542+ struct btrfs_bio * bbio ,
2543+ unsigned int bio_offset )
25402544{
25412545 struct btrfs_fs_info * fs_info = btrfs_sb (inode -> i_sb );
2546+ u64 start = bbio -> file_offset + bio_offset ;
25422547 struct io_failure_record * failrec ;
25432548 struct extent_map * em ;
25442549 struct extent_io_tree * failure_tree = & BTRFS_I (inode )-> io_failure_tree ;
@@ -2558,7 +2563,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
25582563 * (e.g. with a list for failed_mirror) to make
25592564 * clean_io_failure() clean all those errors at once.
25602565 */
2561- ASSERT (failrec -> this_mirror == failed_mirror );
2566+ ASSERT (failrec -> this_mirror == bbio -> mirror_num );
25622567 ASSERT (failrec -> len == fs_info -> sectorsize );
25632568 return failrec ;
25642569 }
@@ -2569,8 +2574,8 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
25692574
25702575 failrec -> start = start ;
25712576 failrec -> len = sectorsize ;
2572- failrec -> failed_mirror = failed_mirror ;
2573- failrec -> this_mirror = failed_mirror ;
2577+ failrec -> failed_mirror = bbio -> mirror_num ;
2578+ failrec -> this_mirror = bbio -> mirror_num ;
25742579 failrec -> compress_type = BTRFS_COMPRESS_NONE ;
25752580
25762581 read_lock (& em_tree -> lock );
@@ -2635,17 +2640,16 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
26352640 return failrec ;
26362641}
26372642
2638- int btrfs_repair_one_sector (struct inode * inode ,
2639- struct bio * failed_bio , u32 bio_offset ,
2640- struct page * page , unsigned int pgoff ,
2641- u64 start , int failed_mirror ,
2643+ int btrfs_repair_one_sector (struct inode * inode , struct btrfs_bio * failed_bbio ,
2644+ u32 bio_offset , struct page * page , unsigned int pgoff ,
26422645 submit_bio_hook_t * submit_bio_hook )
26432646{
2647+ u64 start = failed_bbio -> file_offset + bio_offset ;
26442648 struct io_failure_record * failrec ;
26452649 struct btrfs_fs_info * fs_info = btrfs_sb (inode -> i_sb );
26462650 struct extent_io_tree * tree = & BTRFS_I (inode )-> io_tree ;
26472651 struct extent_io_tree * failure_tree = & BTRFS_I (inode )-> io_failure_tree ;
2648- struct btrfs_bio * failed_bbio = btrfs_bio ( failed_bio ) ;
2652+ struct bio * failed_bio = & failed_bbio -> bio ;
26492653 const int icsum = bio_offset >> fs_info -> sectorsize_bits ;
26502654 struct bio * repair_bio ;
26512655 struct btrfs_bio * repair_bbio ;
@@ -2655,7 +2659,7 @@ int btrfs_repair_one_sector(struct inode *inode,
26552659
26562660 BUG_ON (bio_op (failed_bio ) == REQ_OP_WRITE );
26572661
2658- failrec = btrfs_get_io_failure_record (inode , start , failed_mirror );
2662+ failrec = btrfs_get_io_failure_record (inode , failed_bbio , bio_offset );
26592663 if (IS_ERR (failrec ))
26602664 return PTR_ERR (failrec );
26612665
@@ -2751,9 +2755,10 @@ static void end_sector_io(struct page *page, u64 offset, bool uptodate)
27512755 offset + sectorsize - 1 , & cached );
27522756}
27532757
2754- static void submit_data_read_repair (struct inode * inode , struct bio * failed_bio ,
2758+ static void submit_data_read_repair (struct inode * inode ,
2759+ struct btrfs_bio * failed_bbio ,
27552760 u32 bio_offset , const struct bio_vec * bvec ,
2756- int failed_mirror , unsigned int error_bitmap )
2761+ unsigned int error_bitmap )
27572762{
27582763 const unsigned int pgoff = bvec -> bv_offset ;
27592764 struct btrfs_fs_info * fs_info = btrfs_sb (inode -> i_sb );
@@ -2764,7 +2769,7 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio,
27642769 const int nr_bits = (end + 1 - start ) >> fs_info -> sectorsize_bits ;
27652770 int i ;
27662771
2767- BUG_ON (bio_op (failed_bio ) == REQ_OP_WRITE );
2772+ BUG_ON (bio_op (& failed_bbio -> bio ) == REQ_OP_WRITE );
27682773
27692774 /* This repair is only for data */
27702775 ASSERT (is_data_inode (inode ));
@@ -2776,7 +2781,7 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio,
27762781 * We only get called on buffered IO, thus page must be mapped and bio
27772782 * must not be cloned.
27782783 */
2779- ASSERT (page -> mapping && !bio_flagged (failed_bio , BIO_CLONED ));
2784+ ASSERT (page -> mapping && !bio_flagged (& failed_bbio -> bio , BIO_CLONED ));
27802785
27812786 /* Iterate through all the sectors in the range */
27822787 for (i = 0 ; i < nr_bits ; i ++ ) {
@@ -2793,10 +2798,9 @@ static void submit_data_read_repair(struct inode *inode, struct bio *failed_bio,
27932798 goto next ;
27942799 }
27952800
2796- ret = btrfs_repair_one_sector (inode , failed_bio ,
2797- bio_offset + offset ,
2798- page , pgoff + offset , start + offset ,
2799- failed_mirror , btrfs_submit_data_read_bio );
2801+ ret = btrfs_repair_one_sector (inode , failed_bbio ,
2802+ bio_offset + offset , page , pgoff + offset ,
2803+ btrfs_submit_data_read_bio );
28002804 if (!ret ) {
28012805 /*
28022806 * We have submitted the read repair, the page release
@@ -3130,8 +3134,8 @@ static void end_bio_extent_readpage(struct bio *bio)
31303134 * submit_data_read_repair() will handle all the good
31313135 * and bad sectors, we just continue to the next bvec.
31323136 */
3133- submit_data_read_repair (inode , bio , bio_offset , bvec ,
3134- mirror , error_bitmap );
3137+ submit_data_read_repair (inode , bbio , bio_offset , bvec ,
3138+ error_bitmap );
31353139 } else {
31363140 /* Update page status and unlock */
31373141 end_page_read (page , uptodate , start , len );
0 commit comments