diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-03-27 23:14:38 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:19 -0400 |
commit | e1120a4c8dd4c8839265a052d03d5604c30166b5 (patch) | |
tree | 9577dd55a05c99d6576f90104fb7bdd2994ede66 /fs/bcachefs/btree_iter.c | |
parent | ecc892e40b52213ceb9eee8dfb972d32911e7509 (diff) | |
download | lwn-e1120a4c8dd4c8839265a052d03d5604c30166b5.tar.gz lwn-e1120a4c8dd4c8839265a052d03d5604c30166b5.zip |
bcachefs: Add iter->idx
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_iter.c')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 34d4ce32c2a2..fef5b04440b3 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -1606,24 +1606,12 @@ static inline void bch2_btree_iter_init(struct btree_trans *trans, /* new transactional stuff: */ -static inline unsigned btree_trans_iter_idx(struct btree_trans *trans, - struct btree_iter *iter) -{ - ssize_t idx = iter - trans->iters; - - EBUG_ON(idx < 0 || idx >= trans->nr_iters); - EBUG_ON(!(trans->iters_linked & (1ULL << idx))); - - return idx; -} - int bch2_trans_iter_put(struct btree_trans *trans, struct btree_iter *iter) { - ssize_t idx = btree_trans_iter_idx(trans, iter); int ret = btree_iter_err(iter); - trans->iters_live &= ~(1ULL << idx); + trans->iters_live &= ~(1ULL << iter->idx); return ret; } @@ -1643,7 +1631,7 @@ int bch2_trans_iter_free(struct btree_trans *trans, { int ret = btree_iter_err(iter); - __bch2_trans_iter_free(trans, btree_trans_iter_idx(trans, iter)); + __bch2_trans_iter_free(trans, iter->idx); return ret; } @@ -1652,8 +1640,7 @@ int bch2_trans_iter_free_on_commit(struct btree_trans *trans, { int ret = btree_iter_err(iter); - trans->iters_unlink_on_commit |= - 1ULL << btree_trans_iter_idx(trans, iter); + trans->iters_unlink_on_commit |= 1ULL << iter->idx; return ret; } @@ -1729,6 +1716,8 @@ static int btree_trans_iter_alloc(struct btree_trans *trans) idx = trans->nr_iters++; BUG_ON(trans->nr_iters > trans->size); + + trans->iters[idx].idx = idx; got_slot: BUG_ON(trans->iters_linked & (1ULL << idx)); trans->iters_linked |= 1ULL << idx; @@ -1826,6 +1815,7 @@ struct btree_iter *bch2_trans_copy_iter(struct btree_trans *trans, struct btree_iter *src) { struct btree_iter *iter; + unsigned offset = offsetof(struct btree_iter, trans); int i, idx; idx = btree_trans_iter_alloc(trans); @@ -1837,7 +1827,10 @@ struct btree_iter *bch2_trans_copy_iter(struct btree_trans *trans, trans->iters_unlink_on_restart |= 1ULL << idx; iter = &trans->iters[idx]; - *iter = *src; + + memcpy((void *) iter + offset, + (void *) src + offset, + sizeof(*iter) - offset); for (i = 0; i < BTREE_MAX_DEPTH; i++) if (btree_node_locked(iter, i)) |