aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8c4a0a09c221..0d1876c76732 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2120,8 +2120,9 @@ int clean_io_failure(struct inode *inode, u64 start, struct page *page,
2120 2120
2121 if (failrec->in_validation) { 2121 if (failrec->in_validation) {
2122 /* there was no real error, just free the record */ 2122 /* there was no real error, just free the record */
2123 pr_debug("clean_io_failure: freeing dummy error at %llu\n", 2123 btrfs_debug(fs_info,
2124 failrec->start); 2124 "clean_io_failure: freeing dummy error at %llu",
2125 failrec->start);
2125 goto out; 2126 goto out;
2126 } 2127 }
2127 if (fs_info->sb->s_flags & MS_RDONLY) 2128 if (fs_info->sb->s_flags & MS_RDONLY)
@@ -2187,6 +2188,7 @@ void btrfs_free_io_failure_record(struct inode *inode, u64 start, u64 end)
2187int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, 2188int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
2188 struct io_failure_record **failrec_ret) 2189 struct io_failure_record **failrec_ret)
2189{ 2190{
2191 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2190 struct io_failure_record *failrec; 2192 struct io_failure_record *failrec;
2191 struct extent_map *em; 2193 struct extent_map *em;
2192 struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree; 2194 struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree;
@@ -2234,8 +2236,9 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
2234 em->compress_type); 2236 em->compress_type);
2235 } 2237 }
2236 2238
2237 pr_debug("Get IO Failure Record: (new) logical=%llu, start=%llu, len=%llu\n", 2239 btrfs_debug(fs_info,
2238 logical, start, failrec->len); 2240 "Get IO Failure Record: (new) logical=%llu, start=%llu, len=%llu",
2241 logical, start, failrec->len);
2239 2242
2240 failrec->logical = logical; 2243 failrec->logical = logical;
2241 free_extent_map(em); 2244 free_extent_map(em);
@@ -2253,9 +2256,10 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
2253 return ret; 2256 return ret;
2254 } 2257 }
2255 } else { 2258 } else {
2256 pr_debug("Get IO Failure Record: (found) logical=%llu, start=%llu, len=%llu, validation=%d\n", 2259 btrfs_debug(fs_info,
2257 failrec->logical, failrec->start, failrec->len, 2260 "Get IO Failure Record: (found) logical=%llu, start=%llu, len=%llu, validation=%d",
2258 failrec->in_validation); 2261 failrec->logical, failrec->start, failrec->len,
2262 failrec->in_validation);
2259 /* 2263 /*
2260 * when data can be on disk more than twice, add to failrec here 2264 * when data can be on disk more than twice, add to failrec here
2261 * (e.g. with a list for failed_mirror) to make 2265 * (e.g. with a list for failed_mirror) to make
@@ -2271,18 +2275,19 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end,
2271int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, 2275int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
2272 struct io_failure_record *failrec, int failed_mirror) 2276 struct io_failure_record *failrec, int failed_mirror)
2273{ 2277{
2278 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2274 int num_copies; 2279 int num_copies;
2275 2280
2276 num_copies = btrfs_num_copies(BTRFS_I(inode)->root->fs_info, 2281 num_copies = btrfs_num_copies(fs_info, failrec->logical, failrec->len);
2277 failrec->logical, failrec->len);
2278 if (num_copies == 1) { 2282 if (num_copies == 1) {
2279 /* 2283 /*
2280 * we only have a single copy of the data, so don't bother with 2284 * we only have a single copy of the data, so don't bother with
2281 * all the retry and error correction code that follows. no 2285 * all the retry and error correction code that follows. no
2282 * matter what the error is, it is very likely to persist. 2286 * matter what the error is, it is very likely to persist.
2283 */ 2287 */
2284 pr_debug("Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d\n", 2288 btrfs_debug(fs_info,
2285 num_copies, failrec->this_mirror, failed_mirror); 2289 "Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d",
2290 num_copies, failrec->this_mirror, failed_mirror);
2286 return 0; 2291 return 0;
2287 } 2292 }
2288 2293
@@ -2321,8 +2326,9 @@ int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio,
2321 } 2326 }
2322 2327
2323 if (failrec->this_mirror > num_copies) { 2328 if (failrec->this_mirror > num_copies) {
2324 pr_debug("Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d\n", 2329 btrfs_debug(fs_info,
2325 num_copies, failrec->this_mirror, failed_mirror); 2330 "Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d",
2331 num_copies, failrec->this_mirror, failed_mirror);
2326 return 0; 2332 return 0;
2327 } 2333 }
2328 2334
@@ -2413,8 +2419,9 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset,
2413 } 2419 }
2414 bio_set_op_attrs(bio, REQ_OP_READ, read_mode); 2420 bio_set_op_attrs(bio, REQ_OP_READ, read_mode);
2415 2421
2416 pr_debug("Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d\n", 2422 btrfs_debug(btrfs_sb(inode->i_sb),
2417 read_mode, failrec->this_mirror, failrec->in_validation); 2423 "Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d",
2424 read_mode, failrec->this_mirror, failrec->in_validation);
2418 2425
2419 ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror, 2426 ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror,
2420 failrec->bio_flags, 0); 2427 failrec->bio_flags, 0);
@@ -2538,10 +2545,12 @@ static void end_bio_extent_readpage(struct bio *bio)
2538 bio_for_each_segment_all(bvec, bio, i) { 2545 bio_for_each_segment_all(bvec, bio, i) {
2539 struct page *page = bvec->bv_page; 2546 struct page *page = bvec->bv_page;
2540 struct inode *inode = page->mapping->host; 2547 struct inode *inode = page->mapping->host;
2548 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2541 2549
2542 pr_debug("end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u\n", 2550 btrfs_debug(fs_info,
2543 (u64)bio->bi_iter.bi_sector, 2551 "end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u",
2544 bio->bi_error, io_bio->mirror_num); 2552 (u64)bio->bi_iter.bi_sector, bio->bi_error,
2553 io_bio->mirror_num);
2545 tree = &BTRFS_I(inode)->io_tree; 2554 tree = &BTRFS_I(inode)->io_tree;
2546 2555
2547 /* We always issue full-page reads, but if some block 2556 /* We always issue full-page reads, but if some block
@@ -2551,12 +2560,12 @@ static void end_bio_extent_readpage(struct bio *bio)
2551 * if they don't add up to a full page. */ 2560 * if they don't add up to a full page. */
2552 if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) { 2561 if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) {
2553 if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE) 2562 if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE)
2554 btrfs_err(BTRFS_I(page->mapping->host)->root->fs_info, 2563 btrfs_err(fs_info,
2555 "partial page read in btrfs with offset %u and length %u", 2564 "partial page read in btrfs with offset %u and length %u",
2556 bvec->bv_offset, bvec->bv_len); 2565 bvec->bv_offset, bvec->bv_len);
2557 else 2566 else
2558 btrfs_info(BTRFS_I(page->mapping->host)->root->fs_info, 2567 btrfs_info(fs_info,
2559 "incomplete page read in btrfs with offset %u and length %u", 2568 "incomplete page read in btrfs with offset %u and length %u",
2560 bvec->bv_offset, bvec->bv_len); 2569 bvec->bv_offset, bvec->bv_len);
2561 } 2570 }
2562 2571