diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-16 21:51:34 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 11:47:42 -0500 |
commit | 44ddd8ad1e0be697cf090af669765b3a8b8965dc (patch) | |
tree | 858bdb69ca9fda16c63dd03d7e9e2be19c9bf07b | |
parent | 3a860b5ad5f7fb851d1a9de5cd09b3e6e95362b2 (diff) | |
download | lwn-44ddd8ad1e0be697cf090af669765b3a8b8965dc.tar.gz lwn-44ddd8ad1e0be697cf090af669765b3a8b8965dc.zip |
bcachefs: kill for_each_btree_key_old_upto()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/btree_iter.h | 9 | ||||
-rw-r--r-- | fs/bcachefs/fsck.c | 30 |
2 files changed, 12 insertions, 27 deletions
diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index 8e0e579400b5..f9f6ef9e178f 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -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), \ diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index c3c0b9c1dba2..3e66f244a67e 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -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; } |