@@ -208,7 +208,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
208208 int is_metadata , int have_csum ,
209209 const u8 * csum , u64 generation ,
210210 u16 csum_size );
211- static void scrub_complete_bio_end_io (struct bio * bio , int err );
212211static int scrub_repair_block_from_good_copy (struct scrub_block * sblock_bad ,
213212 struct scrub_block * sblock_good ,
214213 int force_write );
@@ -1294,7 +1293,6 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
12941293 for (page_num = 0 ; page_num < sblock -> page_count ; page_num ++ ) {
12951294 struct bio * bio ;
12961295 struct scrub_page * page = sblock -> pagev [page_num ];
1297- DECLARE_COMPLETION_ONSTACK (complete );
12981296
12991297 if (page -> dev -> bdev == NULL ) {
13001298 page -> io_error = 1 ;
@@ -1311,18 +1309,11 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
13111309 }
13121310 bio -> bi_bdev = page -> dev -> bdev ;
13131311 bio -> bi_sector = page -> physical >> 9 ;
1314- bio -> bi_end_io = scrub_complete_bio_end_io ;
1315- bio -> bi_private = & complete ;
13161312
13171313 bio_add_page (bio , page -> page , PAGE_SIZE , 0 );
1318- btrfsic_submit_bio (READ , bio );
1319-
1320- /* this will also unplug the queue */
1321- wait_for_completion (& complete );
1322-
1323- page -> io_error = !test_bit (BIO_UPTODATE , & bio -> bi_flags );
1324- if (!test_bit (BIO_UPTODATE , & bio -> bi_flags ))
1314+ if (btrfsic_submit_bio_wait (READ , bio ))
13251315 sblock -> no_io_error_seen = 0 ;
1316+
13261317 bio_put (bio );
13271318 }
13281319
@@ -1391,11 +1382,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
13911382 sblock -> checksum_error = 1 ;
13921383}
13931384
1394- static void scrub_complete_bio_end_io (struct bio * bio , int err )
1395- {
1396- complete ((struct completion * )bio -> bi_private );
1397- }
1398-
13991385static int scrub_repair_block_from_good_copy (struct scrub_block * sblock_bad ,
14001386 struct scrub_block * sblock_good ,
14011387 int force_write )
@@ -1430,7 +1416,6 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
14301416 sblock_bad -> checksum_error || page_bad -> io_error ) {
14311417 struct bio * bio ;
14321418 int ret ;
1433- DECLARE_COMPLETION_ONSTACK (complete );
14341419
14351420 if (!page_bad -> dev -> bdev ) {
14361421 printk_ratelimited (KERN_WARNING
@@ -1443,19 +1428,14 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
14431428 return - EIO ;
14441429 bio -> bi_bdev = page_bad -> dev -> bdev ;
14451430 bio -> bi_sector = page_bad -> physical >> 9 ;
1446- bio -> bi_end_io = scrub_complete_bio_end_io ;
1447- bio -> bi_private = & complete ;
14481431
14491432 ret = bio_add_page (bio , page_good -> page , PAGE_SIZE , 0 );
14501433 if (PAGE_SIZE != ret ) {
14511434 bio_put (bio );
14521435 return - EIO ;
14531436 }
1454- btrfsic_submit_bio (WRITE , bio );
14551437
1456- /* this will also unplug the queue */
1457- wait_for_completion (& complete );
1458- if (!bio_flagged (bio , BIO_UPTODATE )) {
1438+ if (btrfsic_submit_bio_wait (WRITE , bio )) {
14591439 btrfs_dev_stat_inc_and_print (page_bad -> dev ,
14601440 BTRFS_DEV_STAT_WRITE_ERRS );
14611441 btrfs_dev_replace_stats_inc (
@@ -3375,7 +3355,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
33753355 struct bio * bio ;
33763356 struct btrfs_device * dev ;
33773357 int ret ;
3378- DECLARE_COMPLETION_ONSTACK (compl );
33793358
33803359 dev = sctx -> wr_ctx .tgtdev ;
33813360 if (!dev )
@@ -3392,8 +3371,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
33923371 spin_unlock (& sctx -> stat_lock );
33933372 return - ENOMEM ;
33943373 }
3395- bio -> bi_private = & compl ;
3396- bio -> bi_end_io = scrub_complete_bio_end_io ;
33973374 bio -> bi_size = 0 ;
33983375 bio -> bi_sector = physical_for_dev_replace >> 9 ;
33993376 bio -> bi_bdev = dev -> bdev ;
@@ -3404,10 +3381,8 @@ static int write_page_nocow(struct scrub_ctx *sctx,
34043381 btrfs_dev_stat_inc_and_print (dev , BTRFS_DEV_STAT_WRITE_ERRS );
34053382 return - EIO ;
34063383 }
3407- btrfsic_submit_bio (WRITE_SYNC , bio );
3408- wait_for_completion (& compl );
34093384
3410- if (! test_bit ( BIO_UPTODATE , & bio -> bi_flags ))
3385+ if (btrfsic_submit_bio_wait ( WRITE_SYNC , bio ))
34113386 goto leave_with_eio ;
34123387
34133388 bio_put (bio );
0 commit comments