Commit 3fb5ebcd authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Inline some fast paths

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 416f6852
......@@ -806,19 +806,6 @@ bool bch2_cut_back(struct bpos where, struct bkey *k)
return true;
}
/**
* bch_key_resize - adjust size of @k
*
* bkey_start_offset(k) will be preserved, modifies where the extent ends
*/
void bch2_key_resize(struct bkey *k,
unsigned new_size)
{
k->p.offset -= k->size;
k->p.offset += new_size;
k->size = new_size;
}
static bool extent_i_save(struct btree *b, struct bkey_packed *dst,
struct bkey_i *src)
{
......
......@@ -540,7 +540,18 @@ static inline void bch2_cut_front(struct bpos where, struct bkey_i *k)
}
bool bch2_cut_back(struct bpos, struct bkey *);
void bch2_key_resize(struct bkey *, unsigned);
/**
* bch_key_resize - adjust size of @k
*
* bkey_start_offset(k) will be preserved, modifies where the extent ends
*/
static inline void bch2_key_resize(struct bkey *k, unsigned new_size)
{
k->p.offset -= k->size;
k->p.offset += new_size;
k->size = new_size;
}
/*
* In extent_sort_fix_overlapping(), insert_fixup_extent(),
......
......@@ -1036,7 +1036,7 @@ static void bchfs_read(struct btree_trans *trans, struct btree_iter *iter,
bkey_start_offset(k.k);
sectors = k.k->size - offset_into_extent;
ret = bch2_read_indirect_extent(trans, iter,
ret = bch2_read_indirect_extent(trans,
&offset_into_extent, &tmp.k);
if (ret)
break;
......
......@@ -1233,7 +1233,7 @@ static int bch2_fiemap(struct inode *vinode, struct fiemap_extent_info *info,
bkey_start_offset(k.k);
sectors = k.k->size - offset_into_extent;
ret = bch2_read_indirect_extent(&trans, iter,
ret = bch2_read_indirect_extent(&trans,
&offset_into_extent, &cur.k);
if (ret)
break;
......
......@@ -1305,7 +1305,7 @@ static void bch2_read_retry(struct bch_fs *c, struct bch_read_bio *rbio,
bkey_start_offset(k.k);
sectors = k.k->size - offset_into_extent;
ret = bch2_read_indirect_extent(&trans, iter,
ret = bch2_read_indirect_extent(&trans,
&offset_into_extent, &tmp.k);
if (ret)
break;
......@@ -1594,19 +1594,15 @@ static void bch2_read_endio(struct bio *bio)
bch2_rbio_punt(rbio, __bch2_read_endio, context, wq);
}
int bch2_read_indirect_extent(struct btree_trans *trans,
struct btree_iter *extent_iter,
unsigned *offset_into_extent,
struct bkey_i *orig_k)
int __bch2_read_indirect_extent(struct btree_trans *trans,
unsigned *offset_into_extent,
struct bkey_i *orig_k)
{
struct btree_iter *iter;
struct bkey_s_c k;
u64 reflink_offset;
int ret;
if (orig_k->k.type != KEY_TYPE_reflink_p)
return 0;
reflink_offset = le64_to_cpu(bkey_i_to_reflink_p(orig_k)->v.idx) +
*offset_into_extent;
......@@ -1920,7 +1916,7 @@ void bch2_read(struct bch_fs *c, struct bch_read_bio *rbio, u64 inode)
bkey_start_offset(k.k);
sectors = k.k->size - offset_into_extent;
ret = bch2_read_indirect_extent(&trans, iter,
ret = bch2_read_indirect_extent(&trans,
&offset_into_extent, &tmp.k);
if (ret)
goto err;
......
......@@ -99,8 +99,17 @@ struct bch_devs_mask;
struct cache_promote_op;
struct extent_ptr_decoded;
int bch2_read_indirect_extent(struct btree_trans *, struct btree_iter *,
unsigned *, struct bkey_i *);
int __bch2_read_indirect_extent(struct btree_trans *, unsigned *,
struct bkey_i *);
static inline int bch2_read_indirect_extent(struct btree_trans *trans,
unsigned *offset_into_extent,
struct bkey_i *k)
{
return k->k.type == KEY_TYPE_reflink_p
? __bch2_read_indirect_extent(trans, offset_into_extent, k)
: 0;
}
enum bch_read_flags {
BCH_READ_RETRY_IF_STALE = 1 << 0,
......
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