aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/extent_io.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 5d31f80c0562..0297f6f4d4c3 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -2502,7 +2502,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
2502 2502
2503 spin_lock(&tree->lock); 2503 spin_lock(&tree->lock);
2504 state = find_first_extent_bit_state(tree, start, EXTENT_LOCKED); 2504 state = find_first_extent_bit_state(tree, start, EXTENT_LOCKED);
2505 if (state && state->start == start) { 2505 if (likely(state && state->start == start)) {
2506 /* 2506 /*
2507 * take a reference on the state, unlock will drop 2507 * take a reference on the state, unlock will drop
2508 * the ref 2508 * the ref
@@ -2512,7 +2512,8 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
2512 spin_unlock(&tree->lock); 2512 spin_unlock(&tree->lock);
2513 2513
2514 mirror = io_bio->mirror_num; 2514 mirror = io_bio->mirror_num;
2515 if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) { 2515 if (likely(uptodate && tree->ops &&
2516 tree->ops->readpage_end_io_hook)) {
2516 ret = tree->ops->readpage_end_io_hook(page, start, end, 2517 ret = tree->ops->readpage_end_io_hook(page, start, end,
2517 state, mirror); 2518 state, mirror);
2518 if (ret) 2519 if (ret)
@@ -2521,12 +2522,15 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
2521 clean_io_failure(start, page); 2522 clean_io_failure(start, page);
2522 } 2523 }
2523 2524
2524 if (!uptodate && tree->ops && tree->ops->readpage_io_failed_hook) { 2525 if (likely(uptodate))
2526 goto readpage_ok;
2527
2528 if (tree->ops && tree->ops->readpage_io_failed_hook) {
2525 ret = tree->ops->readpage_io_failed_hook(page, mirror); 2529 ret = tree->ops->readpage_io_failed_hook(page, mirror);
2526 if (!ret && !err && 2530 if (!ret && !err &&
2527 test_bit(BIO_UPTODATE, &bio->bi_flags)) 2531 test_bit(BIO_UPTODATE, &bio->bi_flags))
2528 uptodate = 1; 2532 uptodate = 1;
2529 } else if (!uptodate) { 2533 } else {
2530 /* 2534 /*
2531 * The generic bio_readpage_error handles errors the 2535 * The generic bio_readpage_error handles errors the
2532 * following way: If possible, new read requests are 2536 * following way: If possible, new read requests are
@@ -2547,7 +2551,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
2547 continue; 2551 continue;
2548 } 2552 }
2549 } 2553 }
2550 2554readpage_ok:
2551 if (uptodate && tree->track_uptodate) { 2555 if (uptodate && tree->track_uptodate) {
2552 set_extent_uptodate(tree, start, end, &cached, 2556 set_extent_uptodate(tree, start, end, &cached,
2553 GFP_ATOMIC); 2557 GFP_ATOMIC);