Commit 69426613 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: improve move_gap()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 95ffc7fb
......@@ -218,8 +218,7 @@ int bch2_journal_key_insert_take(struct bch_fs *c, enum btree_id id,
journal_iters_move_gap(c, keys->gap, idx);
move_gap(keys->data, keys->nr, keys->size, keys->gap, idx);
keys->gap = idx;
move_gap(keys, idx);
keys->nr++;
keys->data[keys->gap++] = n;
......@@ -473,8 +472,7 @@ void bch2_journal_keys_put(struct bch_fs *c)
if (!atomic_dec_and_test(&keys->ref))
return;
move_gap(keys->data, keys->nr, keys->size, keys->gap, keys->nr);
keys->gap = keys->nr;
move_gap(keys, keys->nr);
darray_for_each(*keys, i)
if (i->allocated)
......
......@@ -531,8 +531,7 @@ static int bch2_set_may_go_rw(struct bch_fs *c)
* setting journal_key->overwritten: it will be accessed by multiple
* threads
*/
move_gap(keys->data, keys->nr, keys->size, keys->gap, keys->nr);
keys->gap = keys->nr;
move_gap(keys, keys->nr);
set_bit(BCH_FS_may_go_rw, &c->flags);
......
......@@ -756,8 +756,12 @@ static inline void __move_gap(void *array, size_t element_size,
}
/* Move the gap in a gap buffer: */
#define move_gap(_array, _nr, _size, _old_gap, _new_gap) \
__move_gap(_array, sizeof(_array[0]), _nr, _size, _old_gap, _new_gap)
#define move_gap(_d, _new_gap) \
do { \
__move_gap((_d)->data, sizeof((_d)->data[0]), \
(_d)->nr, (_d)->size, (_d)->gap, _new_gap); \
(_d)->gap = _new_gap; \
} while (0)
#define bubble_sort(_base, _nr, _cmp) \
do { \
......
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