mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 02:36:02 +00:00
bcachefs: bkey_on_stack_reassemble()
Small helper function. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
bd7e82ee2a
commit
5934a0caf2
@ -19,6 +19,14 @@ static inline void bkey_on_stack_realloc(struct bkey_on_stack *s,
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bkey_on_stack_reassemble(struct bkey_on_stack *s,
|
||||
struct bch_fs *c,
|
||||
struct bkey_s_c k)
|
||||
{
|
||||
bkey_on_stack_realloc(s, c, k.k->u64s);
|
||||
bkey_reassemble(s->k, k);
|
||||
}
|
||||
|
||||
static inline void bkey_on_stack_init(struct bkey_on_stack *s)
|
||||
{
|
||||
s->k = (void *) s->onstack;
|
||||
|
@ -356,12 +356,11 @@ struct btree_nr_keys bch2_extent_sort_fix_overlapping(struct bch_fs *c,
|
||||
|
||||
extent_sort_sift(iter, b, _r - iter->data);
|
||||
} else if (bkey_cmp(l.k->p, r.k->p) > 0) {
|
||||
bkey_on_stack_realloc(&split, c, l.k->u64s);
|
||||
|
||||
/*
|
||||
* r wins, but it overlaps in the middle of l - split l:
|
||||
*/
|
||||
bkey_reassemble(split.k, l.s_c);
|
||||
bkey_on_stack_reassemble(&split, c, l.s_c);
|
||||
bch2_cut_back(bkey_start_pos(r.k), split.k);
|
||||
|
||||
bch2_cut_front_s(r.k->p, l);
|
||||
|
@ -807,8 +807,7 @@ static int ec_stripe_update_ptrs(struct bch_fs *c,
|
||||
|
||||
dev = s->key.v.ptrs[idx].dev;
|
||||
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
e = bkey_i_to_s_extent(sk.k);
|
||||
|
||||
extent_for_each_ptr(e, ptr) {
|
||||
|
@ -347,7 +347,7 @@ extent_squash(struct bch_fs *c, struct btree_iter *iter,
|
||||
struct bkey_on_stack split;
|
||||
|
||||
bkey_on_stack_init(&split);
|
||||
bkey_on_stack_realloc(&split, c, k.k->u64s);
|
||||
bkey_on_stack_reassemble(&split, c, k.s_c);
|
||||
|
||||
/*
|
||||
* The insert key falls 'in the middle' of k
|
||||
@ -363,7 +363,6 @@ extent_squash(struct bch_fs *c, struct btree_iter *iter,
|
||||
* modify k _before_ doing the insert (which will move
|
||||
* what k points to)
|
||||
*/
|
||||
bkey_reassemble(split.k, k.s_c);
|
||||
split.k->k.needs_whiteout |= bkey_written(l->b, _k);
|
||||
|
||||
bch2_cut_back(bkey_start_pos(&insert->k), split.k);
|
||||
|
@ -780,8 +780,7 @@ static void bchfs_read(struct btree_trans *trans, struct btree_iter *iter,
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
k = bkey_i_to_s_c(sk.k);
|
||||
|
||||
offset_into_extent = iter->pos.offset -
|
||||
@ -2476,8 +2475,7 @@ static long bchfs_fcollapse_finsert(struct bch_inode_info *inode,
|
||||
bkey_cmp(k.k->p, POS(inode->v.i_ino, offset >> 9)) <= 0)
|
||||
break;
|
||||
reassemble:
|
||||
bkey_on_stack_realloc(©, c, k.k->u64s);
|
||||
bkey_reassemble(copy.k, k);
|
||||
bkey_on_stack_reassemble(©, c, k);
|
||||
|
||||
if (insert &&
|
||||
bkey_cmp(bkey_start_pos(k.k), move_pos) < 0) {
|
||||
|
@ -1538,8 +1538,7 @@ static void bch2_read_retry_nodecode(struct bch_fs *c, struct bch_read_bio *rbio
|
||||
if (bkey_err(k))
|
||||
goto err;
|
||||
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
k = bkey_i_to_s_c(sk.k);
|
||||
bch2_trans_unlock(&trans);
|
||||
|
||||
@ -1590,8 +1589,7 @@ static void bch2_read_retry(struct bch_fs *c, struct bch_read_bio *rbio,
|
||||
BTREE_ITER_SLOTS, k, ret) {
|
||||
unsigned bytes, sectors, offset_into_extent;
|
||||
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
k = bkey_i_to_s_c(sk.k);
|
||||
|
||||
offset_into_extent = iter->pos.offset -
|
||||
@ -1714,8 +1712,7 @@ static void bch2_rbio_narrow_crcs(struct bch_read_bio *rbio)
|
||||
if (IS_ERR_OR_NULL(k.k))
|
||||
goto out;
|
||||
|
||||
bkey_on_stack_realloc(&new, c, k.k->u64s);
|
||||
bkey_reassemble(new.k, k);
|
||||
bkey_on_stack_reassemble(&new, c, k);
|
||||
k = bkey_i_to_s_c(new.k);
|
||||
|
||||
if (bversion_cmp(k.k->version, rbio->version) ||
|
||||
@ -2229,8 +2226,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;
|
||||
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
k = bkey_i_to_s_c(sk.k);
|
||||
|
||||
ret = bch2_read_indirect_extent(&trans,
|
||||
|
@ -60,8 +60,7 @@ static int __bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags
|
||||
continue;
|
||||
}
|
||||
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
|
||||
ret = drop_dev_ptrs(c, bkey_i_to_s(sk.k),
|
||||
dev_idx, flags, false);
|
||||
|
@ -578,8 +578,7 @@ static int __bch2_move_data(struct bch_fs *c,
|
||||
}
|
||||
|
||||
/* unlock before doing IO: */
|
||||
bkey_on_stack_realloc(&sk, c, k.k->u64s);
|
||||
bkey_reassemble(sk.k, k);
|
||||
bkey_on_stack_reassemble(&sk, c, k);
|
||||
k = bkey_i_to_s_c(sk.k);
|
||||
bch2_trans_unlock(&trans);
|
||||
|
||||
|
@ -225,8 +225,7 @@ s64 bch2_remap_range(struct bch_fs *c,
|
||||
break;
|
||||
|
||||
if (src_k.k->type == KEY_TYPE_extent) {
|
||||
bkey_on_stack_realloc(&new_src, c, src_k.k->u64s);
|
||||
bkey_reassemble(new_src.k, src_k);
|
||||
bkey_on_stack_reassemble(&new_src, c, src_k);
|
||||
src_k = bkey_i_to_s_c(new_src.k);
|
||||
|
||||
bch2_cut_front(src_iter->pos, new_src.k);
|
||||
|
Loading…
Reference in New Issue
Block a user