bcachefs: Fix bch2_propagate_key_to_snapshot_leaves()
When we handle a transaction restart in a nested context, we need to return -BCH_ERR_transaction_restart_nested because we invalidated the outer context's iterators and locks. bch2_propagate_key_to_snapshot_leaves() wasn't doing this, this patch fixes it to use trans_was_restarted(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
5b7fbdcd5b
commit
c872afa224
@ -276,9 +276,11 @@ int bch2_trans_relock_notrace(struct btree_trans *);
|
||||
void bch2_trans_unlock(struct btree_trans *);
|
||||
bool bch2_trans_locked(struct btree_trans *);
|
||||
|
||||
static inline bool trans_was_restarted(struct btree_trans *trans, u32 restart_count)
|
||||
static inline int trans_was_restarted(struct btree_trans *trans, u32 restart_count)
|
||||
{
|
||||
return restart_count != trans->restart_count;
|
||||
return restart_count != trans->restart_count
|
||||
? -BCH_ERR_transaction_restart_nested
|
||||
: 0;
|
||||
}
|
||||
|
||||
void __noreturn bch2_trans_restart_error(struct btree_trans *, u32);
|
||||
@ -707,10 +709,7 @@ __bch2_btree_iter_peek_upto_and_restart(struct btree_trans *trans,
|
||||
if (!_ret) \
|
||||
bch2_trans_verify_not_restarted(_trans, _restart_count);\
|
||||
\
|
||||
if (!_ret && trans_was_restarted(_trans, _orig_restart_count)) \
|
||||
_ret = -BCH_ERR_transaction_restart_nested; \
|
||||
\
|
||||
_ret; \
|
||||
_ret ?: trans_was_restarted(_trans, _restart_count); \
|
||||
})
|
||||
|
||||
#define for_each_btree_key2(_trans, _iter, _btree_id, \
|
||||
|
@ -777,9 +777,7 @@ err:
|
||||
}
|
||||
bch2_trans_iter_exit(trans, &iter);
|
||||
|
||||
if (!ret && trans_was_restarted(trans, restart_count))
|
||||
ret = -BCH_ERR_transaction_restart_nested;
|
||||
return ret;
|
||||
return ret ?: trans_was_restarted(trans, restart_count);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -618,10 +618,7 @@ static int get_inodes_all_snapshots(struct btree_trans *trans,
|
||||
|
||||
w->first_this_inode = true;
|
||||
|
||||
if (trans_was_restarted(trans, restart_count))
|
||||
return -BCH_ERR_transaction_restart_nested;
|
||||
|
||||
return 0;
|
||||
return trans_was_restarted(trans, restart_count);
|
||||
}
|
||||
|
||||
static struct inode_walker_entry *
|
||||
@ -1089,9 +1086,7 @@ static int check_i_sectors(struct btree_trans *trans, struct inode_walker *w)
|
||||
fsck_err:
|
||||
if (ret)
|
||||
bch_err_fn(c, ret);
|
||||
if (!ret && trans_was_restarted(trans, restart_count))
|
||||
ret = -BCH_ERR_transaction_restart_nested;
|
||||
return ret;
|
||||
return ret ?: trans_was_restarted(trans, restart_count);
|
||||
}
|
||||
|
||||
struct extent_end {
|
||||
@ -1509,9 +1504,7 @@ static int check_subdir_count(struct btree_trans *trans, struct inode_walker *w)
|
||||
fsck_err:
|
||||
if (ret)
|
||||
bch_err_fn(c, ret);
|
||||
if (!ret && trans_was_restarted(trans, restart_count))
|
||||
ret = -BCH_ERR_transaction_restart_nested;
|
||||
return ret;
|
||||
return ret ?: trans_was_restarted(trans, restart_count);
|
||||
}
|
||||
|
||||
static int check_dirent_target(struct btree_trans *trans,
|
||||
|
@ -1637,6 +1637,7 @@ int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *trans,
|
||||
{
|
||||
struct bch_fs *c = trans->c;
|
||||
struct bkey_buf sk;
|
||||
u32 restart_count = trans->restart_count;
|
||||
int ret;
|
||||
|
||||
bch2_bkey_buf_init(&sk);
|
||||
@ -1659,7 +1660,8 @@ int bch2_propagate_key_to_snapshot_leaves(struct btree_trans *trans,
|
||||
}
|
||||
|
||||
bch2_bkey_buf_exit(&sk, c);
|
||||
return ret;
|
||||
|
||||
return ret ?: trans_was_restarted(trans, restart_count);
|
||||
}
|
||||
|
||||
int bch2_snapshots_read(struct bch_fs *c)
|
||||
|
Loading…
Reference in New Issue
Block a user