bcachefs: kill for_each_btree_key_old_upto()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-12-16 21:51:34 -05:00
parent 3a860b5ad5
commit 44ddd8ad1e
2 changed files with 12 additions and 27 deletions

View File

@ -784,15 +784,6 @@ transaction_restart: \
!((_ret) = bkey_err(_k)) && (_k).k; \
bch2_btree_iter_advance(&(_iter)))
#define for_each_btree_key_old_upto(_trans, _iter, _btree_id, \
_start, _end, _flags, _k, _ret) \
for (bch2_trans_iter_init((_trans), &(_iter), (_btree_id), \
(_start), (_flags)); \
(_k) = __bch2_btree_iter_peek_upto_and_restart((_trans), \
&(_iter), _end, _flags),\
!((_ret) = bkey_err(_k)) && (_k).k; \
bch2_btree_iter_advance(&(_iter)))
#define for_each_btree_key_norestart(_trans, _iter, _btree_id, \
_start, _flags, _k, _ret) \
for (bch2_trans_iter_init((_trans), &(_iter), (_btree_id), \

View File

@ -30,16 +30,15 @@ static s64 bch2_count_inode_sectors(struct btree_trans *trans, u64 inum,
struct btree_iter iter;
struct bkey_s_c k;
u64 sectors = 0;
int ret;
for_each_btree_key_old_upto(trans, iter, BTREE_ID_extents,
SPOS(inum, 0, snapshot),
POS(inum, U64_MAX),
0, k, ret)
int ret = for_each_btree_key_upto(trans, iter, BTREE_ID_extents,
SPOS(inum, 0, snapshot),
POS(inum, U64_MAX),
0, k, ({
if (bkey_extent_is_allocation(k.k))
sectors += k.k->size;
bch2_trans_iter_exit(trans, &iter);
0;
}));
return ret ?: sectors;
}
@ -49,22 +48,17 @@ static s64 bch2_count_subdirs(struct btree_trans *trans, u64 inum,
{
struct btree_iter iter;
struct bkey_s_c k;
struct bkey_s_c_dirent d;
u64 subdirs = 0;
int ret;
for_each_btree_key_old_upto(trans, iter, BTREE_ID_dirents,
int ret = for_each_btree_key_upto(trans, iter, BTREE_ID_dirents,
SPOS(inum, 0, snapshot),
POS(inum, U64_MAX),
0, k, ret) {
if (k.k->type != KEY_TYPE_dirent)
continue;
d = bkey_s_c_to_dirent(k);
if (d.v->d_type == DT_DIR)
0, k, ({
if (k.k->type == KEY_TYPE_dirent &&
bkey_s_c_to_dirent(k).v->d_type == DT_DIR)
subdirs++;
}
bch2_trans_iter_exit(trans, &iter);
0;
}));
return ret ?: subdirs;
}