bcachefs: for_each_keylist_key() declares loop iter

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-12-21 22:24:46 -05:00
parent 0beebd9245
commit 1a2a9f9f53
4 changed files with 4 additions and 13 deletions

View File

@ -556,8 +556,6 @@ static void btree_update_add_key(struct btree_update *as,
static int btree_update_nodes_written_trans(struct btree_trans *trans, static int btree_update_nodes_written_trans(struct btree_trans *trans,
struct btree_update *as) struct btree_update *as)
{ {
struct bkey_i *k;
struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, as->journal_u64s); struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, as->journal_u64s);
int ret = PTR_ERR_OR_ZERO(e); int ret = PTR_ERR_OR_ZERO(e);
if (ret) if (ret)

View File

@ -1106,15 +1106,14 @@ static bool bch2_extent_is_writeable(struct bch_write_op *op,
static inline void bch2_nocow_write_unlock(struct bch_write_op *op) static inline void bch2_nocow_write_unlock(struct bch_write_op *op)
{ {
struct bch_fs *c = op->c; struct bch_fs *c = op->c;
struct bkey_i *k;
for_each_keylist_key(&op->insert_keys, k) { for_each_keylist_key(&op->insert_keys, k) {
struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(k)); struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(k));
bkey_for_each_ptr(ptrs, ptr) bkey_for_each_ptr(ptrs, ptr)
bch2_bucket_nocow_unlock(&c->nocow_locks, bch2_bucket_nocow_unlock(&c->nocow_locks,
PTR_BUCKET_POS(c, ptr), PTR_BUCKET_POS(c, ptr),
BUCKET_NOCOW_LOCK_UPDATE); BUCKET_NOCOW_LOCK_UPDATE);
} }
} }
@ -1158,11 +1157,9 @@ static void bch2_nocow_write_convert_unwritten(struct bch_write_op *op)
{ {
struct bch_fs *c = op->c; struct bch_fs *c = op->c;
struct btree_trans *trans = bch2_trans_get(c); struct btree_trans *trans = bch2_trans_get(c);
struct bkey_i *orig;
int ret;
for_each_keylist_key(&op->insert_keys, orig) { for_each_keylist_key(&op->insert_keys, orig) {
ret = for_each_btree_key_upto_commit(trans, iter, BTREE_ID_extents, int ret = for_each_btree_key_upto_commit(trans, iter, BTREE_ID_extents,
bkey_start_pos(&orig->k), orig->k.p, bkey_start_pos(&orig->k), orig->k.p,
BTREE_ITER_INTENT, k, BTREE_ITER_INTENT, k,
NULL, NULL, BCH_TRANS_COMMIT_no_enospc, ({ NULL, NULL, BCH_TRANS_COMMIT_no_enospc, ({

View File

@ -43,8 +43,6 @@ void bch2_keylist_pop_front(struct keylist *l)
#ifdef CONFIG_BCACHEFS_DEBUG #ifdef CONFIG_BCACHEFS_DEBUG
void bch2_verify_keylist_sorted(struct keylist *l) void bch2_verify_keylist_sorted(struct keylist *l)
{ {
struct bkey_i *k;
for_each_keylist_key(l, k) for_each_keylist_key(l, k)
BUG_ON(bkey_next(k) != l->top && BUG_ON(bkey_next(k) != l->top &&
bpos_ge(k->k.p, bkey_next(k)->k.p)); bpos_ge(k->k.p, bkey_next(k)->k.p));

View File

@ -50,18 +50,16 @@ static inline struct bkey_i *bch2_keylist_front(struct keylist *l)
} }
#define for_each_keylist_key(_keylist, _k) \ #define for_each_keylist_key(_keylist, _k) \
for (_k = (_keylist)->keys; \ for (struct bkey_i *_k = (_keylist)->keys; \
_k != (_keylist)->top; \ _k != (_keylist)->top; \
_k = bkey_next(_k)) _k = bkey_next(_k))
static inline u64 keylist_sectors(struct keylist *keys) static inline u64 keylist_sectors(struct keylist *keys)
{ {
struct bkey_i *k;
u64 ret = 0; u64 ret = 0;
for_each_keylist_key(keys, k) for_each_keylist_key(keys, k)
ret += k->k.size; ret += k->k.size;
return ret; return ret;
} }