@@ -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 );
@@ -1292,7 +1291,6 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
12921291 for (page_num = 0 ; page_num < sblock -> page_count ; page_num ++ ) {
12931292 struct bio * bio ;
12941293 struct scrub_page * page = sblock -> pagev [page_num ];
1295- DECLARE_COMPLETION_ONSTACK (complete );
12961294
12971295 if (page -> dev -> bdev == NULL ) {
12981296 page -> io_error = 1 ;
@@ -1309,18 +1307,11 @@ static void scrub_recheck_block(struct btrfs_fs_info *fs_info,
13091307 }
13101308 bio -> bi_bdev = page -> dev -> bdev ;
13111309 bio -> bi_sector = page -> physical >> 9 ;
1312- bio -> bi_end_io = scrub_complete_bio_end_io ;
1313- bio -> bi_private = & complete ;
13141310
13151311 bio_add_page (bio , page -> page , PAGE_SIZE , 0 );
1316- btrfsic_submit_bio (READ , bio );
1317-
1318- /* this will also unplug the queue */
1319- wait_for_completion (& complete );
1320-
1321- page -> io_error = !test_bit (BIO_UPTODATE , & bio -> bi_flags );
1322- if (!test_bit (BIO_UPTODATE , & bio -> bi_flags ))
1312+ if (btrfsic_submit_bio_wait (READ , bio ))
13231313 sblock -> no_io_error_seen = 0 ;
1314+
13241315 bio_put (bio );
13251316 }
13261317
@@ -1389,11 +1380,6 @@ static void scrub_recheck_block_checksum(struct btrfs_fs_info *fs_info,
13891380 sblock -> checksum_error = 1 ;
13901381}
13911382
1392- static void scrub_complete_bio_end_io (struct bio * bio , int err )
1393- {
1394- complete ((struct completion * )bio -> bi_private );
1395- }
1396-
13971383static int scrub_repair_block_from_good_copy (struct scrub_block * sblock_bad ,
13981384 struct scrub_block * sblock_good ,
13991385 int force_write )
@@ -1428,7 +1414,6 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
14281414 sblock_bad -> checksum_error || page_bad -> io_error ) {
14291415 struct bio * bio ;
14301416 int ret ;
1431- DECLARE_COMPLETION_ONSTACK (complete );
14321417
14331418 if (!page_bad -> dev -> bdev ) {
14341419 printk_ratelimited (KERN_WARNING
@@ -1441,19 +1426,14 @@ static int scrub_repair_page_from_good_copy(struct scrub_block *sblock_bad,
14411426 return - EIO ;
14421427 bio -> bi_bdev = page_bad -> dev -> bdev ;
14431428 bio -> bi_sector = page_bad -> physical >> 9 ;
1444- bio -> bi_end_io = scrub_complete_bio_end_io ;
1445- bio -> bi_private = & complete ;
14461429
14471430 ret = bio_add_page (bio , page_good -> page , PAGE_SIZE , 0 );
14481431 if (PAGE_SIZE != ret ) {
14491432 bio_put (bio );
14501433 return - EIO ;
14511434 }
1452- btrfsic_submit_bio (WRITE , bio );
14531435
1454- /* this will also unplug the queue */
1455- wait_for_completion (& complete );
1456- if (!bio_flagged (bio , BIO_UPTODATE )) {
1436+ if (btrfsic_submit_bio_wait (WRITE , bio )) {
14571437 btrfs_dev_stat_inc_and_print (page_bad -> dev ,
14581438 BTRFS_DEV_STAT_WRITE_ERRS );
14591439 btrfs_dev_replace_stats_inc (
@@ -3373,7 +3353,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
33733353 struct bio * bio ;
33743354 struct btrfs_device * dev ;
33753355 int ret ;
3376- DECLARE_COMPLETION_ONSTACK (compl );
33773356
33783357 dev = sctx -> wr_ctx .tgtdev ;
33793358 if (!dev )
@@ -3390,8 +3369,6 @@ static int write_page_nocow(struct scrub_ctx *sctx,
33903369 spin_unlock (& sctx -> stat_lock );
33913370 return - ENOMEM ;
33923371 }
3393- bio -> bi_private = & compl ;
3394- bio -> bi_end_io = scrub_complete_bio_end_io ;
33953372 bio -> bi_size = 0 ;
33963373 bio -> bi_sector = physical_for_dev_replace >> 9 ;
33973374 bio -> bi_bdev = dev -> bdev ;
@@ -3402,10 +3379,8 @@ static int write_page_nocow(struct scrub_ctx *sctx,
34023379 btrfs_dev_stat_inc_and_print (dev , BTRFS_DEV_STAT_WRITE_ERRS );
34033380 return - EIO ;
34043381 }
3405- btrfsic_submit_bio (WRITE_SYNC , bio );
3406- wait_for_completion (& compl );
34073382
3408- if (! test_bit ( BIO_UPTODATE , & bio -> bi_flags ))
3383+ if (btrfsic_submit_bio_wait ( WRITE_SYNC , bio ))
34093384 goto leave_with_eio ;
34103385
34113386 bio_put (bio );
0 commit comments