Skip to content

Commit 4125bf7

Browse files
committed
Btrfs: finish read pages in the order they are submitted
The endio is done at reverse order of bio vectors. That means for a sequential read, the page first submitted will finish last in a bio. Considering we will do checksum (making cache hot) for every page, this does introduce delay (and chance to squeeze cache used soon) for pages submitted at the begining. I don't observe obvious performance difference with below patch at my simple test, but seems more natural to finish read in the order they are submitted. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent 0be2e98 commit 4125bf7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎fs/btrfs/extent_io.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,7 +1750,8 @@ static void end_bio_extent_writepage(struct bio *bio, int err)
17501750
static void end_bio_extent_readpage(struct bio *bio, int err)
17511751
{
17521752
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
1753-
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
1753+
struct bio_vec *bvec_end = bio->bi_io_vec + bio->bi_vcnt - 1;
1754+
struct bio_vec *bvec = bio->bi_io_vec;
17541755
struct extent_io_tree *tree;
17551756
u64 start;
17561757
u64 end;
@@ -1773,7 +1774,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
17731774
else
17741775
whole_page = 0;
17751776

1776-
if (--bvec >= bio->bi_io_vec)
1777+
if (++bvec <= bvec_end)
17771778
prefetchw(&bvec->bv_page->flags);
17781779

17791780
if (uptodate && tree->ops && tree->ops->readpage_end_io_hook) {
@@ -1818,7 +1819,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)
18181819
}
18191820
check_page_locked(tree, page);
18201821
}
1821-
} while (bvec >= bio->bi_io_vec);
1822+
} while (bvec <= bvec_end);
18221823

18231824
bio_put(bio);
18241825
}

0 commit comments

Comments
 (0)