Commit f793fd85 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix for bch2_trans_commit() unlocking when it's not supposed to

When we pass BTREE_INSERT_NOUNLOCK bch2_trans_commit isn't supposed to
unlock after a successful commit, but it was calling
bch2_trans_cond_resched() - oops.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 3bf57160
...@@ -2155,6 +2155,7 @@ void bch2_trans_reset(struct btree_trans *trans, unsigned flags) ...@@ -2155,6 +2155,7 @@ 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 (!(flags & TRANS_RESET_NOTRAVERSE))
......
...@@ -303,6 +303,7 @@ static inline void set_btree_iter_dontneed(struct btree_trans *trans, struct btr ...@@ -303,6 +303,7 @@ static inline void set_btree_iter_dontneed(struct btree_trans *trans, struct btr
} }
#define TRANS_RESET_NOTRAVERSE (1 << 0) #define TRANS_RESET_NOTRAVERSE (1 << 0)
#define TRANS_RESET_NOUNLOCK (1 << 1)
void bch2_trans_reset(struct btree_trans *, unsigned); void bch2_trans_reset(struct btree_trans *, unsigned);
......
...@@ -826,7 +826,7 @@ int __bch2_trans_commit(struct btree_trans *trans) ...@@ -826,7 +826,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; unsigned u64s, reset_flags = 0;
int ret = 0; int ret = 0;
if (!trans->nr_updates) if (!trans->nr_updates)
...@@ -940,7 +940,11 @@ int __bch2_trans_commit(struct btree_trans *trans) ...@@ -940,7 +940,11 @@ 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:
bch2_trans_reset(trans, !ret ? TRANS_RESET_NOTRAVERSE : 0); if (!ret)
reset_flags |= TRANS_RESET_NOTRAVERSE;
if (!ret && (trans->flags & BTREE_INSERT_NOUNLOCK))
reset_flags |= TRANS_RESET_NOUNLOCK;
bch2_trans_reset(trans, reset_flags);
return ret; return ret;
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment