summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-02-23 22:43:24 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2024-03-13 21:22:25 -0400
commit69426613cdf0784e29e1a429c1a2f372a6267c43 (patch)
tree08d9402cd8f82ccb17731096d4bcd5640bd6fe0b
parent95ffc7fb8c7831ee79ed8d2c0e53c7b4869c6338 (diff)
downloadlinux-stable-69426613cdf0784e29e1a429c1a2f372a6267c43.tar.gz
linux-stable-69426613cdf0784e29e1a429c1a2f372a6267c43.tar.bz2
linux-stable-69426613cdf0784e29e1a429c1a2f372a6267c43.zip
bcachefs: improve move_gap()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/btree_journal_iter.c6
-rw-r--r--fs/bcachefs/recovery.c3
-rw-r--r--fs/bcachefs/util.h8
3 files changed, 9 insertions, 8 deletions
diff --git a/fs/bcachefs/btree_journal_iter.c b/fs/bcachefs/btree_journal_iter.c
index 9291a897abab..207dd32e2ecc 100644
--- a/fs/bcachefs/btree_journal_iter.c
+++ b/fs/bcachefs/btree_journal_iter.c
@@ -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)
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c
index d773af23a189..f11e882de02b 100644
--- a/fs/bcachefs/recovery.c
+++ b/fs/bcachefs/recovery.c
@@ -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);
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 7fed75c44cd5..b3d3a7349814 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -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 { \