@@ -2381,13 +2381,6 @@ int clean_io_failure(struct btrfs_fs_info *fs_info,
2381
2381
2382
2382
BUG_ON (!failrec -> this_mirror );
2383
2383
2384
- if (failrec -> in_validation ) {
2385
- /* there was no real error, just free the record */
2386
- btrfs_debug (fs_info ,
2387
- "clean_io_failure: freeing dummy error at %llu" ,
2388
- failrec -> start );
2389
- goto out ;
2390
- }
2391
2384
if (sb_rdonly (fs_info -> sb ))
2392
2385
goto out ;
2393
2386
@@ -2464,9 +2457,8 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
2464
2457
failrec = get_state_failrec (failure_tree , start );
2465
2458
if (!IS_ERR (failrec )) {
2466
2459
btrfs_debug (fs_info ,
2467
- "Get IO Failure Record: (found) logical=%llu, start=%llu, len=%llu, validation=%d" ,
2468
- failrec -> logical , failrec -> start , failrec -> len ,
2469
- failrec -> in_validation );
2460
+ "Get IO Failure Record: (found) logical=%llu, start=%llu, len=%llu" ,
2461
+ failrec -> logical , failrec -> start , failrec -> len );
2470
2462
/*
2471
2463
* when data can be on disk more than twice, add to failrec here
2472
2464
* (e.g. with a list for failed_mirror) to make
@@ -2484,7 +2476,6 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
2484
2476
failrec -> len = sectorsize ;
2485
2477
failrec -> this_mirror = 0 ;
2486
2478
failrec -> bio_flags = 0 ;
2487
- failrec -> in_validation = 0 ;
2488
2479
2489
2480
read_lock (& em_tree -> lock );
2490
2481
em = lookup_extent_mapping (em_tree , start , failrec -> len );
@@ -2535,7 +2526,7 @@ static struct io_failure_record *btrfs_get_io_failure_record(struct inode *inode
2535
2526
return failrec ;
2536
2527
}
2537
2528
2538
- static bool btrfs_check_repairable (struct inode * inode , bool needs_validation ,
2529
+ static bool btrfs_check_repairable (struct inode * inode ,
2539
2530
struct io_failure_record * failrec ,
2540
2531
int failed_mirror )
2541
2532
{
@@ -2555,39 +2546,22 @@ static bool btrfs_check_repairable(struct inode *inode, bool needs_validation,
2555
2546
return false;
2556
2547
}
2557
2548
2549
+ /* The failure record should only contain one sector */
2550
+ ASSERT (failrec -> len == fs_info -> sectorsize );
2551
+
2558
2552
/*
2559
- * there are two premises:
2560
- * a) deliver good data to the caller
2561
- * b) correct the bad sectors on disk
2553
+ * There are two premises:
2554
+ * a) deliver good data to the caller
2555
+ * b) correct the bad sectors on disk
2556
+ *
2557
+ * Since we're only doing repair for one sector, we only need to get
2558
+ * a good copy of the failed sector and if we succeed, we have setup
2559
+ * everything for repair_io_failure to do the rest for us.
2562
2560
*/
2563
- if (needs_validation ) {
2564
- /*
2565
- * to fulfill b), we need to know the exact failing sectors, as
2566
- * we don't want to rewrite any more than the failed ones. thus,
2567
- * we need separate read requests for the failed bio
2568
- *
2569
- * if the following BUG_ON triggers, our validation request got
2570
- * merged. we need separate requests for our algorithm to work.
2571
- */
2572
- BUG_ON (failrec -> in_validation );
2573
- failrec -> in_validation = 1 ;
2574
- failrec -> this_mirror = failed_mirror ;
2575
- } else {
2576
- /*
2577
- * we're ready to fulfill a) and b) alongside. get a good copy
2578
- * of the failed sector and if we succeed, we have setup
2579
- * everything for repair_io_failure to do the rest for us.
2580
- */
2581
- if (failrec -> in_validation ) {
2582
- BUG_ON (failrec -> this_mirror != failed_mirror );
2583
- failrec -> in_validation = 0 ;
2584
- failrec -> this_mirror = 0 ;
2585
- }
2586
- failrec -> failed_mirror = failed_mirror ;
2561
+ failrec -> failed_mirror = failed_mirror ;
2562
+ failrec -> this_mirror ++ ;
2563
+ if (failrec -> this_mirror == failed_mirror )
2587
2564
failrec -> this_mirror ++ ;
2588
- if (failrec -> this_mirror == failed_mirror )
2589
- failrec -> this_mirror ++ ;
2590
- }
2591
2565
2592
2566
if (failrec -> this_mirror > num_copies ) {
2593
2567
btrfs_debug (fs_info ,
@@ -2599,48 +2573,6 @@ static bool btrfs_check_repairable(struct inode *inode, bool needs_validation,
2599
2573
return true;
2600
2574
}
2601
2575
2602
- static bool btrfs_io_needs_validation (struct inode * inode , struct bio * bio )
2603
- {
2604
- u64 len = 0 ;
2605
- const u32 blocksize = inode -> i_sb -> s_blocksize ;
2606
-
2607
- /*
2608
- * If bi_status is BLK_STS_OK, then this was a checksum error, not an
2609
- * I/O error. In this case, we already know exactly which sector was
2610
- * bad, so we don't need to validate.
2611
- */
2612
- if (bio -> bi_status == BLK_STS_OK )
2613
- return false;
2614
-
2615
- /*
2616
- * We need to validate each sector individually if the failed I/O was
2617
- * for multiple sectors.
2618
- *
2619
- * There are a few possible bios that can end up here:
2620
- * 1. A buffered read bio, which is not cloned.
2621
- * 2. A direct I/O read bio, which is cloned.
2622
- * 3. A (buffered or direct) repair bio, which is not cloned.
2623
- *
2624
- * For cloned bios (case 2), we can get the size from
2625
- * btrfs_io_bio->iter; for non-cloned bios (cases 1 and 3), we can get
2626
- * it from the bvecs.
2627
- */
2628
- if (bio_flagged (bio , BIO_CLONED )) {
2629
- if (btrfs_io_bio (bio )-> iter .bi_size > blocksize )
2630
- return true;
2631
- } else {
2632
- struct bio_vec * bvec ;
2633
- int i ;
2634
-
2635
- bio_for_each_bvec_all (bvec , bio , i ) {
2636
- len += bvec -> bv_len ;
2637
- if (len > blocksize )
2638
- return true;
2639
- }
2640
- }
2641
- return false;
2642
- }
2643
-
2644
2576
int btrfs_repair_one_sector (struct inode * inode ,
2645
2577
struct bio * failed_bio , u32 bio_offset ,
2646
2578
struct page * page , unsigned int pgoff ,
@@ -2653,7 +2585,6 @@ int btrfs_repair_one_sector(struct inode *inode,
2653
2585
struct extent_io_tree * failure_tree = & BTRFS_I (inode )-> io_failure_tree ;
2654
2586
struct btrfs_io_bio * failed_io_bio = btrfs_io_bio (failed_bio );
2655
2587
const int icsum = bio_offset >> fs_info -> sectorsize_bits ;
2656
- bool need_validation ;
2657
2588
struct bio * repair_bio ;
2658
2589
struct btrfs_io_bio * repair_io_bio ;
2659
2590
blk_status_t status ;
@@ -2667,25 +2598,15 @@ int btrfs_repair_one_sector(struct inode *inode,
2667
2598
if (IS_ERR (failrec ))
2668
2599
return PTR_ERR (failrec );
2669
2600
2670
- /*
2671
- * We will only submit repair for one sector, thus we don't need
2672
- * extra validation anymore.
2673
- *
2674
- * TODO: All those extra validation related code will be cleaned up
2675
- * later.
2676
- */
2677
- need_validation = false;
2678
- if (!btrfs_check_repairable (inode , need_validation , failrec ,
2679
- failed_mirror )) {
2601
+
2602
+ if (!btrfs_check_repairable (inode , failrec , failed_mirror )) {
2680
2603
free_io_failure (failure_tree , tree , failrec );
2681
2604
return - EIO ;
2682
2605
}
2683
2606
2684
2607
repair_bio = btrfs_io_bio_alloc (1 );
2685
2608
repair_io_bio = btrfs_io_bio (repair_bio );
2686
2609
repair_bio -> bi_opf = REQ_OP_READ ;
2687
- if (need_validation )
2688
- repair_bio -> bi_opf |= REQ_FAILFAST_DEV ;
2689
2610
repair_bio -> bi_end_io = failed_bio -> bi_end_io ;
2690
2611
repair_bio -> bi_iter .bi_sector = failrec -> logical >> 9 ;
2691
2612
repair_bio -> bi_private = failed_bio -> bi_private ;
@@ -2703,8 +2624,8 @@ int btrfs_repair_one_sector(struct inode *inode,
2703
2624
repair_io_bio -> iter = repair_bio -> bi_iter ;
2704
2625
2705
2626
btrfs_debug (btrfs_sb (inode -> i_sb ),
2706
- "repair read error: submitting new read to mirror %d, in_validation= %d" ,
2707
- failrec -> this_mirror , failrec -> in_validation );
2627
+ "repair read error: submitting new read to mirror %d" ,
2628
+ failrec -> this_mirror );
2708
2629
2709
2630
status = submit_bio_hook (inode , repair_bio , failrec -> this_mirror ,
2710
2631
failrec -> bio_flags );
0 commit comments