mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 07:23:14 +00:00
bcachefs: __bch2_trans_commit() no longer calls bch2_trans_reset()
It's now the caller's responsibility to call bch2_trans_begin. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
e829b7175b
commit
955af63441
@ -2382,22 +2382,14 @@ inline void bch2_trans_unlink_iters(struct btree_trans *trans)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bch2_trans_reset() - reset a transaction after a interrupted attempt
|
* bch2_trans_begin() - reset a transaction after a interrupted attempt
|
||||||
* @trans: transaction to reset
|
* @trans: transaction to reset
|
||||||
* @flags: transaction reset flags.
|
|
||||||
*
|
*
|
||||||
* While iterating over nodes or updating nodes a attempt to lock a btree
|
* While iterating over nodes or updating nodes a attempt to lock a btree
|
||||||
* node may return EINTR when the trylock fails. When this occurs
|
* node may return EINTR when the trylock fails. When this occurs
|
||||||
* bch2_trans_reset() or bch2_trans_begin() should be called and the
|
* bch2_trans_begin() should be called and the transaction retried.
|
||||||
* transaction retried.
|
|
||||||
*
|
|
||||||
* Transaction reset flags include:
|
|
||||||
*
|
|
||||||
* - TRANS_RESET_NOUNLOCK - Do not attempt to unlock and reschedule the
|
|
||||||
* transaction.
|
|
||||||
* - TRANS_RESET_NOTRAVERSE - Do not traverse all linked iters.
|
|
||||||
*/
|
*/
|
||||||
void bch2_trans_reset(struct btree_trans *trans, unsigned flags)
|
void bch2_trans_begin(struct btree_trans *trans)
|
||||||
{
|
{
|
||||||
struct btree_iter *iter;
|
struct btree_iter *iter;
|
||||||
|
|
||||||
@ -2405,8 +2397,11 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags)
|
|||||||
iter->flags &= ~(BTREE_ITER_KEEP_UNTIL_COMMIT|
|
iter->flags &= ~(BTREE_ITER_KEEP_UNTIL_COMMIT|
|
||||||
BTREE_ITER_SET_POS_AFTER_COMMIT);
|
BTREE_ITER_SET_POS_AFTER_COMMIT);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: we shouldn't be doing this if the transaction was restarted, but
|
||||||
|
* currently we still overflow transaction iterators if we do that
|
||||||
|
* */
|
||||||
bch2_trans_unlink_iters(trans);
|
bch2_trans_unlink_iters(trans);
|
||||||
|
|
||||||
trans->iters_touched &= trans->iters_live;
|
trans->iters_touched &= trans->iters_live;
|
||||||
|
|
||||||
trans->extra_journal_res = 0;
|
trans->extra_journal_res = 0;
|
||||||
@ -2425,11 +2420,9 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags)
|
|||||||
(void *) &trans->fs_usage_deltas->memset_start);
|
(void *) &trans->fs_usage_deltas->memset_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & TRANS_RESET_NOUNLOCK))
|
bch2_trans_cond_resched(trans);
|
||||||
bch2_trans_cond_resched(trans);
|
|
||||||
|
|
||||||
if (!(flags & TRANS_RESET_NOTRAVERSE) &&
|
if (trans->restarted)
|
||||||
trans->iters_linked)
|
|
||||||
bch2_btree_iter_traverse_all(trans);
|
bch2_btree_iter_traverse_all(trans);
|
||||||
|
|
||||||
trans->restarted = false;
|
trans->restarted = false;
|
||||||
|
@ -323,22 +323,7 @@ static inline void set_btree_iter_dontneed(struct btree_trans *trans, struct btr
|
|||||||
trans->iters_touched &= ~(1ULL << iter->idx);
|
trans->iters_touched &= ~(1ULL << iter->idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TRANS_RESET_NOTRAVERSE (1 << 0)
|
void bch2_trans_begin(struct btree_trans *);
|
||||||
#define TRANS_RESET_NOUNLOCK (1 << 1)
|
|
||||||
|
|
||||||
void bch2_trans_reset(struct btree_trans *, unsigned);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* bch2_trans_begin() - ensure lock consistency of transaction on retry
|
|
||||||
* @trans: transaction to prepare
|
|
||||||
*
|
|
||||||
* Ensure lock ordering is correct before potentially retrying a transaction
|
|
||||||
* after a failed trylock.
|
|
||||||
*/
|
|
||||||
static inline void bch2_trans_begin(struct btree_trans *trans)
|
|
||||||
{
|
|
||||||
return bch2_trans_reset(trans, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void *bch2_trans_kmalloc(struct btree_trans *, size_t);
|
void *bch2_trans_kmalloc(struct btree_trans *, size_t);
|
||||||
void bch2_trans_init(struct btree_trans *, struct bch_fs *, unsigned, size_t);
|
void bch2_trans_init(struct btree_trans *, struct bch_fs *, unsigned, size_t);
|
||||||
|
@ -923,7 +923,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
|||||||
struct btree_insert_entry *i = NULL;
|
struct btree_insert_entry *i = NULL;
|
||||||
struct btree_iter *iter;
|
struct btree_iter *iter;
|
||||||
bool trans_trigger_run;
|
bool trans_trigger_run;
|
||||||
unsigned u64s, reset_flags = 0;
|
unsigned u64s;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (!trans->nr_updates &&
|
if (!trans->nr_updates &&
|
||||||
@ -1030,11 +1030,19 @@ int __bch2_trans_commit(struct btree_trans *trans)
|
|||||||
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
|
if (likely(!(trans->flags & BTREE_INSERT_NOCHECK_RW)))
|
||||||
percpu_ref_put(&trans->c->writes);
|
percpu_ref_put(&trans->c->writes);
|
||||||
out_reset:
|
out_reset:
|
||||||
if (!ret)
|
trans->extra_journal_res = 0;
|
||||||
reset_flags |= TRANS_RESET_NOTRAVERSE;
|
trans->nr_updates = 0;
|
||||||
if (!ret && (trans->flags & BTREE_INSERT_NOUNLOCK))
|
trans->hooks = NULL;
|
||||||
reset_flags |= TRANS_RESET_NOUNLOCK;
|
trans->extra_journal_entries = NULL;
|
||||||
bch2_trans_reset(trans, reset_flags);
|
trans->extra_journal_entry_u64s = 0;
|
||||||
|
|
||||||
|
if (trans->fs_usage_deltas) {
|
||||||
|
trans->fs_usage_deltas->used = 0;
|
||||||
|
memset((void *) trans->fs_usage_deltas +
|
||||||
|
offsetof(struct replicas_delta_list, memset_start), 0,
|
||||||
|
(void *) &trans->fs_usage_deltas->memset_end -
|
||||||
|
(void *) &trans->fs_usage_deltas->memset_start);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
err:
|
err:
|
||||||
|
Loading…
Reference in New Issue
Block a user