bcachefs: Improve error handling for for_each_btree_key_continue()
Change it to match for_each_btree_key() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
b43a0f60a6
commit
ef9f95ba41
@ -246,6 +246,11 @@ static inline struct bkey_s_c __bch2_btree_iter_next(struct btree_iter *iter,
|
||||
: bch2_btree_iter_next(iter);
|
||||
}
|
||||
|
||||
static inline int bkey_err(struct bkey_s_c k)
|
||||
{
|
||||
return PTR_ERR_OR_ZERO(k.k);
|
||||
}
|
||||
|
||||
#define for_each_btree_key(_trans, _iter, _btree_id, \
|
||||
_start, _flags, _k, _ret) \
|
||||
for ((_ret) = PTR_ERR_OR_ZERO((_iter) = \
|
||||
@ -257,16 +262,11 @@ static inline struct bkey_s_c __bch2_btree_iter_next(struct btree_iter *iter,
|
||||
(_ret) = PTR_ERR_OR_ZERO(((_k) = \
|
||||
__bch2_btree_iter_next(_iter, _flags)).k))
|
||||
|
||||
#define for_each_btree_key_continue(_iter, _flags, _k) \
|
||||
#define for_each_btree_key_continue(_iter, _flags, _k, _ret) \
|
||||
for ((_k) = __bch2_btree_iter_peek(_iter, _flags); \
|
||||
!IS_ERR_OR_NULL((_k).k); \
|
||||
!((_ret) = bkey_err(_k)) && (_k).k; \
|
||||
(_k) = __bch2_btree_iter_next(_iter, _flags))
|
||||
|
||||
static inline int bkey_err(struct bkey_s_c k)
|
||||
{
|
||||
return PTR_ERR_OR_ZERO(k.k);
|
||||
}
|
||||
|
||||
/* new multiple iterator interface: */
|
||||
|
||||
int bch2_trans_iter_put(struct btree_trans *, struct btree_iter *);
|
||||
|
@ -248,7 +248,7 @@ static int hash_check_duplicates(struct btree_trans *trans,
|
||||
iter = bch2_trans_copy_iter(trans, h->chain);
|
||||
BUG_ON(IS_ERR(iter));
|
||||
|
||||
for_each_btree_key_continue(iter, 0, k2) {
|
||||
for_each_btree_key_continue(iter, 0, k2, ret) {
|
||||
if (bkey_cmp(k2.k->p, k.k->p) >= 0)
|
||||
break;
|
||||
|
||||
@ -458,7 +458,7 @@ static int check_extents(struct bch_fs *c)
|
||||
iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS,
|
||||
POS(BCACHEFS_ROOT_INO, 0), 0);
|
||||
retry:
|
||||
for_each_btree_key_continue(iter, 0, k) {
|
||||
for_each_btree_key_continue(iter, 0, k, ret) {
|
||||
ret = walk_inode(&trans, &w, k.k->p.inode);
|
||||
if (ret)
|
||||
break;
|
||||
@ -553,7 +553,7 @@ static int check_dirents(struct bch_fs *c)
|
||||
iter = bch2_trans_get_iter(&trans, BTREE_ID_DIRENTS,
|
||||
POS(BCACHEFS_ROOT_INO, 0), 0);
|
||||
retry:
|
||||
for_each_btree_key_continue(iter, 0, k) {
|
||||
for_each_btree_key_continue(iter, 0, k, ret) {
|
||||
struct bkey_s_c_dirent d;
|
||||
struct bch_inode_unpacked target;
|
||||
bool have_target;
|
||||
@ -707,7 +707,7 @@ static int check_xattrs(struct bch_fs *c)
|
||||
iter = bch2_trans_get_iter(&trans, BTREE_ID_XATTRS,
|
||||
POS(BCACHEFS_ROOT_INO, 0), 0);
|
||||
retry:
|
||||
for_each_btree_key_continue(iter, 0, k) {
|
||||
for_each_btree_key_continue(iter, 0, k, ret) {
|
||||
ret = walk_inode(&trans, &w, k.k->p.inode);
|
||||
if (ret)
|
||||
break;
|
||||
@ -995,7 +995,7 @@ up:
|
||||
|
||||
iter = bch2_trans_get_iter(&trans, BTREE_ID_INODES, POS_MIN, 0);
|
||||
retry:
|
||||
for_each_btree_key_continue(iter, 0, k) {
|
||||
for_each_btree_key_continue(iter, 0, k, ret) {
|
||||
if (k.k->type != KEY_TYPE_inode)
|
||||
continue;
|
||||
|
||||
@ -1021,7 +1021,7 @@ retry:
|
||||
had_unreachable = true;
|
||||
}
|
||||
}
|
||||
ret = bch2_trans_iter_free(&trans, iter);
|
||||
bch2_trans_iter_free(&trans, iter);
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
|
@ -187,6 +187,7 @@ int bch2_hash_needs_whiteout(struct btree_trans *trans,
|
||||
{
|
||||
struct btree_iter *iter;
|
||||
struct bkey_s_c k;
|
||||
int ret;
|
||||
|
||||
iter = bch2_trans_copy_iter(trans, start);
|
||||
if (IS_ERR(iter))
|
||||
@ -194,7 +195,7 @@ int bch2_hash_needs_whiteout(struct btree_trans *trans,
|
||||
|
||||
bch2_btree_iter_next_slot(iter);
|
||||
|
||||
for_each_btree_key_continue(iter, BTREE_ITER_SLOTS, k) {
|
||||
for_each_btree_key_continue(iter, BTREE_ITER_SLOTS, k, ret) {
|
||||
if (k.k->type != desc.key_type &&
|
||||
k.k->type != KEY_TYPE_whiteout)
|
||||
break;
|
||||
@ -206,7 +207,8 @@ int bch2_hash_needs_whiteout(struct btree_trans *trans,
|
||||
}
|
||||
}
|
||||
|
||||
return bch2_trans_iter_free(trans, iter);
|
||||
bch2_trans_iter_free(trans, iter);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static __always_inline
|
||||
|
Loading…
Reference in New Issue
Block a user