@@ -53,7 +53,7 @@ void btrfs_bio_init(struct btrfs_bio *bbio, struct btrfs_fs_info *fs_info,
5353
5454/*
5555 * Allocate a btrfs_bio structure. The btrfs_bio is the main I/O container for
56- * btrfs, and is used for all I/O submitted through btrfs_submit_bio .
56+ * btrfs, and is used for all I/O submitted through btrfs_submit_bbio() .
5757 *
5858 * Just like the underlying bio_alloc_bioset it will not fail as it is backed by
5959 * a mempool.
@@ -120,12 +120,6 @@ static void __btrfs_bio_end_io(struct btrfs_bio *bbio)
120120 }
121121}
122122
123- void btrfs_bio_end_io (struct btrfs_bio * bbio , blk_status_t status )
124- {
125- bbio -> bio .bi_status = status ;
126- __btrfs_bio_end_io (bbio );
127- }
128-
129123static void btrfs_orig_write_end_io (struct bio * bio );
130124
131125static void btrfs_bbio_propagate_error (struct btrfs_bio * bbio ,
@@ -147,8 +141,9 @@ static void btrfs_bbio_propagate_error(struct btrfs_bio *bbio,
147141 }
148142}
149143
150- static void btrfs_orig_bbio_end_io (struct btrfs_bio * bbio )
144+ void btrfs_bio_end_io (struct btrfs_bio * bbio , blk_status_t status )
151145{
146+ bbio -> bio .bi_status = status ;
152147 if (bbio -> bio .bi_pool == & btrfs_clone_bioset ) {
153148 struct btrfs_bio * orig_bbio = bbio -> private ;
154149
@@ -179,7 +174,7 @@ static int prev_repair_mirror(struct btrfs_failed_bio *fbio, int cur_mirror)
179174static void btrfs_repair_done (struct btrfs_failed_bio * fbio )
180175{
181176 if (atomic_dec_and_test (& fbio -> repair_count )) {
182- btrfs_orig_bbio_end_io (fbio -> bbio );
177+ btrfs_bio_end_io (fbio -> bbio , fbio -> bbio -> bio . bi_status );
183178 mempool_free (fbio , & btrfs_failed_bio_pool );
184179 }
185180}
@@ -211,7 +206,7 @@ static void btrfs_end_repair_bio(struct btrfs_bio *repair_bbio,
211206 goto done ;
212207 }
213208
214- btrfs_submit_bio (repair_bbio , mirror );
209+ btrfs_submit_bbio (repair_bbio , mirror );
215210 return ;
216211 }
217212
@@ -280,7 +275,7 @@ static struct btrfs_failed_bio *repair_one_sector(struct btrfs_bio *failed_bbio,
280275
281276 mirror = next_repair_mirror (fbio , failed_bbio -> mirror_num );
282277 btrfs_debug (fs_info , "submitting repair read to mirror %d" , mirror );
283- btrfs_submit_bio (repair_bbio , mirror );
278+ btrfs_submit_bbio (repair_bbio , mirror );
284279 return fbio ;
285280}
286281
@@ -326,7 +321,7 @@ static void btrfs_check_read_bio(struct btrfs_bio *bbio, struct btrfs_device *de
326321 if (fbio )
327322 btrfs_repair_done (fbio );
328323 else
329- btrfs_orig_bbio_end_io (bbio );
324+ btrfs_bio_end_io (bbio , bbio -> bio . bi_status );
330325}
331326
332327static void btrfs_log_dev_io_error (struct bio * bio , struct btrfs_device * dev )
@@ -360,7 +355,7 @@ static void btrfs_end_bio_work(struct work_struct *work)
360355 if (is_data_bbio (bbio ))
361356 btrfs_check_read_bio (bbio , bbio -> bio .bi_private );
362357 else
363- btrfs_orig_bbio_end_io (bbio );
358+ btrfs_bio_end_io (bbio , bbio -> bio . bi_status );
364359}
365360
366361static void btrfs_simple_end_io (struct bio * bio )
@@ -380,7 +375,7 @@ static void btrfs_simple_end_io(struct bio *bio)
380375 } else {
381376 if (bio_op (bio ) == REQ_OP_ZONE_APPEND && !bio -> bi_status )
382377 btrfs_record_physical_zoned (bbio );
383- btrfs_orig_bbio_end_io (bbio );
378+ btrfs_bio_end_io (bbio , bbio -> bio . bi_status );
384379 }
385380}
386381
@@ -394,7 +389,7 @@ static void btrfs_raid56_end_io(struct bio *bio)
394389 if (bio_op (bio ) == REQ_OP_READ && is_data_bbio (bbio ))
395390 btrfs_check_read_bio (bbio , NULL );
396391 else
397- btrfs_orig_bbio_end_io (bbio );
392+ btrfs_bio_end_io (bbio , bbio -> bio . bi_status );
398393
399394 btrfs_put_bioc (bioc );
400395}
@@ -424,7 +419,7 @@ static void btrfs_orig_write_end_io(struct bio *bio)
424419 if (bio_op (bio ) == REQ_OP_ZONE_APPEND && !bio -> bi_status )
425420 stripe -> physical = bio -> bi_iter .bi_sector << SECTOR_SHIFT ;
426421
427- btrfs_orig_bbio_end_io (bbio );
422+ btrfs_bio_end_io (bbio , bbio -> bio . bi_status );
428423 btrfs_put_bioc (bioc );
429424}
430425
@@ -502,8 +497,8 @@ static void btrfs_submit_mirrored_bio(struct btrfs_io_context *bioc, int dev_nr)
502497 btrfs_submit_dev_bio (bioc -> stripes [dev_nr ].dev , bio );
503498}
504499
505- static void __btrfs_submit_bio (struct bio * bio , struct btrfs_io_context * bioc ,
506- struct btrfs_io_stripe * smap , int mirror_num )
500+ static void btrfs_submit_bio (struct bio * bio , struct btrfs_io_context * bioc ,
501+ struct btrfs_io_stripe * smap , int mirror_num )
507502{
508503 if (!bioc ) {
509504 /* Single mirror read/write fast path. */
@@ -593,7 +588,7 @@ static void run_one_async_done(struct btrfs_work *work, bool do_free)
593588
594589 /* If an error occurred we just want to clean up the bio and move on. */
595590 if (bio -> bi_status ) {
596- btrfs_orig_bbio_end_io (async -> bbio );
591+ btrfs_bio_end_io (async -> bbio , async -> bbio -> bio . bi_status );
597592 return ;
598593 }
599594
@@ -603,7 +598,7 @@ static void run_one_async_done(struct btrfs_work *work, bool do_free)
603598 * context. This changes nothing when cgroups aren't in use.
604599 */
605600 bio -> bi_opf |= REQ_BTRFS_CGROUP_PUNT ;
606- __btrfs_submit_bio (bio , async -> bioc , & async -> smap , async -> mirror_num );
601+ btrfs_submit_bio (bio , async -> bioc , & async -> smap , async -> mirror_num );
607602}
608603
609604static bool should_async_write (struct btrfs_bio * bbio )
@@ -678,7 +673,10 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
678673 blk_status_t ret ;
679674 int error ;
680675
681- smap .is_scrub = !bbio -> inode ;
676+ if (!bbio -> inode || btrfs_is_data_reloc_root (inode -> root ))
677+ smap .rst_search_commit_root = true;
678+ else
679+ smap .rst_search_commit_root = false;
682680
683681 btrfs_bio_counter_inc_blocked (fs_info );
684682 error = btrfs_map_block (fs_info , btrfs_op (bio ), logical , & map_length ,
@@ -749,7 +747,7 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
749747 }
750748 }
751749
752- __btrfs_submit_bio (bio , bioc , & smap , mirror_num );
750+ btrfs_submit_bio (bio , bioc , & smap , mirror_num );
753751done :
754752 return map_length == length ;
755753
@@ -765,16 +763,14 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio, int mirror_num)
765763 ASSERT (bbio -> bio .bi_pool == & btrfs_clone_bioset );
766764 ASSERT (remaining );
767765
768- remaining -> bio .bi_status = ret ;
769- btrfs_orig_bbio_end_io (remaining );
766+ btrfs_bio_end_io (remaining , ret );
770767 }
771- bbio -> bio .bi_status = ret ;
772- btrfs_orig_bbio_end_io (bbio );
768+ btrfs_bio_end_io (bbio , ret );
773769 /* Do not submit another chunk */
774770 return true;
775771}
776772
777- void btrfs_submit_bio (struct btrfs_bio * bbio , int mirror_num )
773+ void btrfs_submit_bbio (struct btrfs_bio * bbio , int mirror_num )
778774{
779775 /* If bbio->inode is not populated, its file_offset must be 0. */
780776 ASSERT (bbio -> inode || bbio -> file_offset == 0 );
@@ -786,7 +782,7 @@ void btrfs_submit_bio(struct btrfs_bio *bbio, int mirror_num)
786782/*
787783 * Submit a repair write.
788784 *
789- * This bypasses btrfs_submit_bio deliberately, as that writes all copies in a
785+ * This bypasses btrfs_submit_bbio() deliberately, as that writes all copies in a
790786 * RAID setup. Here we only want to write the one bad copy, so we do the
791787 * mapping ourselves and submit the bio directly.
792788 *
@@ -875,7 +871,7 @@ void btrfs_submit_repair_write(struct btrfs_bio *bbio, int mirror_num, bool dev_
875871 ASSERT (smap .dev == fs_info -> dev_replace .srcdev );
876872 smap .dev = fs_info -> dev_replace .tgtdev ;
877873 }
878- __btrfs_submit_bio (& bbio -> bio , NULL , & smap , mirror_num );
874+ btrfs_submit_bio (& bbio -> bio , NULL , & smap , mirror_num );
879875 return ;
880876
881877fail :
0 commit comments