Commit 70438dc3 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: bch2_read_extent() microoptimizations

Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent c4537686
...@@ -1272,7 +1272,6 @@ static void promote_start(struct promote_op *op, struct bch_read_bio *rbio) ...@@ -1272,7 +1272,6 @@ static void promote_start(struct promote_op *op, struct bch_read_bio *rbio)
closure_return_with_destructor(cl, promote_done); closure_return_with_destructor(cl, promote_done);
} }
noinline
static struct promote_op *__promote_alloc(struct bch_fs *c, static struct promote_op *__promote_alloc(struct bch_fs *c,
enum btree_id btree_id, enum btree_id btree_id,
struct bpos pos, struct bpos pos,
...@@ -1346,7 +1345,8 @@ static struct promote_op *__promote_alloc(struct bch_fs *c, ...@@ -1346,7 +1345,8 @@ static struct promote_op *__promote_alloc(struct bch_fs *c,
return NULL; return NULL;
} }
static inline struct promote_op *promote_alloc(struct bch_fs *c, noinline
static struct promote_op *promote_alloc(struct bch_fs *c,
struct bvec_iter iter, struct bvec_iter iter,
struct bkey_s_c k, struct bkey_s_c k,
struct extent_ptr_decoded *pick, struct extent_ptr_decoded *pick,
...@@ -1910,7 +1910,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -1910,7 +1910,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
if (narrow_crcs && (flags & BCH_READ_USER_MAPPED)) if (narrow_crcs && (flags & BCH_READ_USER_MAPPED))
flags |= BCH_READ_MUST_BOUNCE; flags |= BCH_READ_MUST_BOUNCE;
BUG_ON(offset_into_extent + bvec_iter_sectors(iter) > k.k->size); EBUG_ON(offset_into_extent + bvec_iter_sectors(iter) > k.k->size);
if (pick.crc.compression_type != BCH_COMPRESSION_NONE || if (pick.crc.compression_type != BCH_COMPRESSION_NONE ||
(pick.crc.csum_type != BCH_CSUM_NONE && (pick.crc.csum_type != BCH_CSUM_NONE &&
...@@ -1922,6 +1922,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -1922,6 +1922,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
bounce = true; bounce = true;
} }
if (orig->opts.promote_target)
promote = promote_alloc(c, iter, k, &pick, orig->opts, flags, promote = promote_alloc(c, iter, k, &pick, orig->opts, flags,
&rbio, &bounce, &read_full); &rbio, &bounce, &read_full);
...@@ -1951,7 +1952,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -1951,7 +1952,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
* data in the write path, but we're not going to use it all * data in the write path, but we're not going to use it all
* here: * here:
*/ */
BUG_ON(rbio->bio.bi_iter.bi_size < EBUG_ON(rbio->bio.bi_iter.bi_size <
pick.crc.compressed_size << 9); pick.crc.compressed_size << 9);
rbio->bio.bi_iter.bi_size = rbio->bio.bi_iter.bi_size =
pick.crc.compressed_size << 9; pick.crc.compressed_size << 9;
...@@ -1986,10 +1987,10 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -1986,10 +1987,10 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
noclone: noclone:
rbio = orig; rbio = orig;
rbio->bio.bi_iter = iter; rbio->bio.bi_iter = iter;
BUG_ON(bio_flagged(&rbio->bio, BIO_CHAIN)); EBUG_ON(bio_flagged(&rbio->bio, BIO_CHAIN));
} }
BUG_ON(bio_sectors(&rbio->bio) != pick.crc.compressed_size); EBUG_ON(bio_sectors(&rbio->bio) != pick.crc.compressed_size);
rbio->c = c; rbio->c = c;
rbio->submit_time = local_clock(); rbio->submit_time = local_clock();
...@@ -2005,6 +2006,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -2005,6 +2006,7 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
rbio->hole = 0; rbio->hole = 0;
rbio->retry = 0; rbio->retry = 0;
rbio->context = 0; rbio->context = 0;
/* XXX: only initialize this if needed */
rbio->devs_have = bch2_bkey_devs(k); rbio->devs_have = bch2_bkey_devs(k);
rbio->pick = pick; rbio->pick = pick;
rbio->pos = pos; rbio->pos = pos;
...@@ -2021,11 +2023,11 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig, ...@@ -2021,11 +2023,11 @@ int __bch2_read_extent(struct bch_fs *c, struct bch_read_bio *orig,
bch2_increment_clock(c, bio_sectors(&rbio->bio), READ); bch2_increment_clock(c, bio_sectors(&rbio->bio), READ);
percpu_down_read(&c->mark_lock); rcu_read_lock();
bucket_io_clock_reset(c, ca, PTR_BUCKET_NR(ca, &pick.ptr), READ); bucket_io_clock_reset(c, ca, PTR_BUCKET_NR(ca, &pick.ptr), READ);
percpu_up_read(&c->mark_lock); rcu_read_unlock();
if (likely(!(flags & (BCH_READ_IN_RETRY|BCH_READ_LAST_FRAGMENT)))) { if (!(flags & (BCH_READ_IN_RETRY|BCH_READ_LAST_FRAGMENT))) {
bio_inc_remaining(&orig->bio); bio_inc_remaining(&orig->bio);
trace_read_split(&orig->bio); trace_read_split(&orig->bio);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment