Commit 44ddd8ad authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: kill for_each_btree_key_old_upto()

Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 3a860b5a
...@@ -784,15 +784,6 @@ transaction_restart: \ ...@@ -784,15 +784,6 @@ transaction_restart: \
!((_ret) = bkey_err(_k)) && (_k).k; \ !((_ret) = bkey_err(_k)) && (_k).k; \
bch2_btree_iter_advance(&(_iter))) 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, \ #define for_each_btree_key_norestart(_trans, _iter, _btree_id, \
_start, _flags, _k, _ret) \ _start, _flags, _k, _ret) \
for (bch2_trans_iter_init((_trans), &(_iter), (_btree_id), \ for (bch2_trans_iter_init((_trans), &(_iter), (_btree_id), \
......
...@@ -30,16 +30,15 @@ static s64 bch2_count_inode_sectors(struct btree_trans *trans, u64 inum, ...@@ -30,16 +30,15 @@ static s64 bch2_count_inode_sectors(struct btree_trans *trans, u64 inum,
struct btree_iter iter; struct btree_iter iter;
struct bkey_s_c k; struct bkey_s_c k;
u64 sectors = 0; u64 sectors = 0;
int ret;
for_each_btree_key_old_upto(trans, iter, BTREE_ID_extents, int ret = for_each_btree_key_upto(trans, iter, BTREE_ID_extents,
SPOS(inum, 0, snapshot), SPOS(inum, 0, snapshot),
POS(inum, U64_MAX), POS(inum, U64_MAX),
0, k, ret) 0, k, ({
if (bkey_extent_is_allocation(k.k)) if (bkey_extent_is_allocation(k.k))
sectors += k.k->size; sectors += k.k->size;
0;
bch2_trans_iter_exit(trans, &iter); }));
return ret ?: sectors; return ret ?: sectors;
} }
...@@ -49,22 +48,17 @@ static s64 bch2_count_subdirs(struct btree_trans *trans, u64 inum, ...@@ -49,22 +48,17 @@ static s64 bch2_count_subdirs(struct btree_trans *trans, u64 inum,
{ {
struct btree_iter iter; struct btree_iter iter;
struct bkey_s_c k; struct bkey_s_c k;
struct bkey_s_c_dirent d;
u64 subdirs = 0; 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), SPOS(inum, 0, snapshot),
POS(inum, U64_MAX), POS(inum, U64_MAX),
0, k, ret) { 0, k, ({
if (k.k->type != KEY_TYPE_dirent) if (k.k->type == KEY_TYPE_dirent &&
continue; bkey_s_c_to_dirent(k).v->d_type == DT_DIR)
d = bkey_s_c_to_dirent(k);
if (d.v->d_type == DT_DIR)
subdirs++; subdirs++;
} 0;
bch2_trans_iter_exit(trans, &iter); }));
return ret ?: subdirs; return ret ?: subdirs;
} }
......
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