bcachefs: Add assertions for unexpected transaction restarts
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
223b560e02
commit
f0d2e9f2e5
@ -427,13 +427,17 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
|
|||||||
|
|
||||||
#define lockrestart_do(_trans, _do) \
|
#define lockrestart_do(_trans, _do) \
|
||||||
({ \
|
({ \
|
||||||
|
u32 _restart_count; \
|
||||||
int _ret; \
|
int _ret; \
|
||||||
\
|
\
|
||||||
do { \
|
do { \
|
||||||
bch2_trans_begin(_trans); \
|
_restart_count = bch2_trans_begin(_trans); \
|
||||||
_ret = (_do); \
|
_ret = (_do); \
|
||||||
} while (bch2_err_matches(_ret, BCH_ERR_transaction_restart)); \
|
} while (bch2_err_matches(_ret, BCH_ERR_transaction_restart)); \
|
||||||
\
|
\
|
||||||
|
if (!_ret) \
|
||||||
|
bch2_trans_verify_not_restarted(_trans, _restart_count);\
|
||||||
|
\
|
||||||
_ret; \
|
_ret; \
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -474,7 +478,7 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
|
|||||||
(_start), (_flags)); \
|
(_start), (_flags)); \
|
||||||
\
|
\
|
||||||
while (1) { \
|
while (1) { \
|
||||||
bch2_trans_begin(_trans); \
|
u32 _restart_count = bch2_trans_begin(_trans); \
|
||||||
(_k) = bch2_btree_iter_peek_type(&(_iter), (_flags)); \
|
(_k) = bch2_btree_iter_peek_type(&(_iter), (_flags)); \
|
||||||
if (!(_k).k) { \
|
if (!(_k).k) { \
|
||||||
_ret = 0; \
|
_ret = 0; \
|
||||||
@ -486,6 +490,7 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
|
|||||||
continue; \
|
continue; \
|
||||||
if (_ret) \
|
if (_ret) \
|
||||||
break; \
|
break; \
|
||||||
|
bch2_trans_verify_not_restarted(_trans, _restart_count);\
|
||||||
if (!bch2_btree_iter_advance(&(_iter))) \
|
if (!bch2_btree_iter_advance(&(_iter))) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
@ -503,7 +508,7 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
|
|||||||
(_start), (_flags)); \
|
(_start), (_flags)); \
|
||||||
\
|
\
|
||||||
while (1) { \
|
while (1) { \
|
||||||
bch2_trans_begin(_trans); \
|
u32 _restart_count = bch2_trans_begin(_trans); \
|
||||||
(_k) = bch2_btree_iter_peek_prev_type(&(_iter), (_flags));\
|
(_k) = bch2_btree_iter_peek_prev_type(&(_iter), (_flags));\
|
||||||
if (!(_k).k) { \
|
if (!(_k).k) { \
|
||||||
_ret = 0; \
|
_ret = 0; \
|
||||||
@ -515,6 +520,7 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
|
|||||||
continue; \
|
continue; \
|
||||||
if (_ret) \
|
if (_ret) \
|
||||||
break; \
|
break; \
|
||||||
|
bch2_trans_verify_not_restarted(_trans, _restart_count);\
|
||||||
if (!bch2_btree_iter_rewind(&(_iter))) \
|
if (!bch2_btree_iter_rewind(&(_iter))) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
|
@ -969,6 +969,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
|
|||||||
unsigned update_level = level;
|
unsigned update_level = level;
|
||||||
int journal_flags = flags & JOURNAL_WATERMARK_MASK;
|
int journal_flags = flags & JOURNAL_WATERMARK_MASK;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
u32 restart_count = trans->restart_count;
|
||||||
|
|
||||||
BUG_ON(!path->should_be_locked);
|
BUG_ON(!path->should_be_locked);
|
||||||
|
|
||||||
@ -1094,6 +1095,7 @@ bch2_btree_update_start(struct btree_trans *trans, struct btree_path *path,
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
bch2_trans_verify_not_restarted(trans, restart_count);
|
||||||
return as;
|
return as;
|
||||||
err:
|
err:
|
||||||
bch2_btree_update_free(as);
|
bch2_btree_update_free(as);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user