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

bcachefs: Must check for errors from bch2_trans_cond_resched()

But we don't need to call it from outside the btree iterator code
anymore, since it's called by bch2_trans_begin() and
bch2_btree_path_traverse().
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent 114eea75
...@@ -367,8 +367,6 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags) ...@@ -367,8 +367,6 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags)
POS(ca->dev_idx, ca->mi.first_bucket)); POS(ca->dev_idx, ca->mi.first_bucket));
while (iter.pos.offset < ca->mi.nbuckets) { while (iter.pos.offset < ca->mi.nbuckets) {
bch2_trans_cond_resched(&trans);
ret = bch2_alloc_write_key(&trans, &iter, flags); ret = bch2_alloc_write_key(&trans, &iter, flags);
if (ret) { if (ret) {
percpu_ref_put(&ca->ref); percpu_ref_put(&ca->ref);
......
...@@ -828,8 +828,6 @@ static int bch2_gc_btree(struct bch_fs *c, enum btree_id btree_id, ...@@ -828,8 +828,6 @@ static int bch2_gc_btree(struct bch_fs *c, enum btree_id btree_id,
BTREE_INSERT_NOWAIT| BTREE_INSERT_NOWAIT|
BTREE_INSERT_GC_LOCK_HELD); BTREE_INSERT_GC_LOCK_HELD);
} }
bch2_trans_cond_resched(&trans);
} }
bch2_trans_iter_exit(&trans, &iter); bch2_trans_iter_exit(&trans, &iter);
......
...@@ -24,6 +24,21 @@ static inline void btree_path_list_add(struct btree_trans *, struct btree_path * ...@@ -24,6 +24,21 @@ static inline void btree_path_list_add(struct btree_trans *, struct btree_path *
static struct btree_path *btree_path_alloc(struct btree_trans *, struct btree_path *); static struct btree_path *btree_path_alloc(struct btree_trans *, struct btree_path *);
/*
* Unlocks before scheduling
* Note: does not revalidate iterator
*/
static inline int bch2_trans_cond_resched(struct btree_trans *trans)
{
if (need_resched() || race_fault()) {
bch2_trans_unlock(trans);
schedule();
return bch2_trans_relock(trans) ? 0 : -EINTR;
} else {
return 0;
}
}
static inline int __btree_path_cmp(const struct btree_path *l, static inline int __btree_path_cmp(const struct btree_path *l,
enum btree_id r_btree_id, enum btree_id r_btree_id,
bool r_cached, bool r_cached,
......
...@@ -269,21 +269,6 @@ static inline void bch2_btree_iter_set_snapshot(struct btree_iter *iter, u32 sna ...@@ -269,21 +269,6 @@ static inline void bch2_btree_iter_set_snapshot(struct btree_iter *iter, u32 sna
bch2_btree_iter_set_pos(iter, pos); bch2_btree_iter_set_pos(iter, pos);
} }
/*
* Unlocks before scheduling
* Note: does not revalidate iterator
*/
static inline int bch2_trans_cond_resched(struct btree_trans *trans)
{
if (need_resched() || race_fault()) {
bch2_trans_unlock(trans);
schedule();
return bch2_trans_relock(trans) ? 0 : -EINTR;
} else {
return 0;
}
}
void bch2_trans_iter_exit(struct btree_trans *, struct btree_iter *); void bch2_trans_iter_exit(struct btree_trans *, struct btree_iter *);
void bch2_trans_iter_init(struct btree_trans *, struct btree_iter *, void bch2_trans_iter_init(struct btree_trans *, struct btree_iter *,
unsigned, struct bpos, unsigned); unsigned, struct bpos, unsigned);
......
...@@ -1414,8 +1414,6 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id, ...@@ -1414,8 +1414,6 @@ int bch2_btree_delete_range_trans(struct btree_trans *trans, enum btree_id id,
BTREE_INSERT_NOFAIL); BTREE_INSERT_NOFAIL);
if (ret) if (ret)
break; break;
bch2_trans_cond_resched(trans);
} }
if (ret == -EINTR) { if (ret == -EINTR) {
......
...@@ -2116,8 +2116,6 @@ static int check_nlinks_walk_dirents(struct bch_fs *c, struct nlink_table *links ...@@ -2116,8 +2116,6 @@ static int check_nlinks_walk_dirents(struct bch_fs *c, struct nlink_table *links
d.k->p.snapshot); d.k->p.snapshot);
break; break;
} }
bch2_trans_cond_resched(&trans);
} }
bch2_trans_iter_exit(&trans, &iter); bch2_trans_iter_exit(&trans, &iter);
......
...@@ -768,7 +768,6 @@ static int __bch2_move_data(struct bch_fs *c, ...@@ -768,7 +768,6 @@ static int __bch2_move_data(struct bch_fs *c,
&stats->sectors_seen); &stats->sectors_seen);
next_nondata: next_nondata:
bch2_btree_iter_advance(&iter); bch2_btree_iter_advance(&iter);
bch2_trans_cond_resched(&trans);
} }
out: out:
...@@ -914,7 +913,6 @@ static int bch2_move_btree(struct bch_fs *c, ...@@ -914,7 +913,6 @@ static int bch2_move_btree(struct bch_fs *c,
ret = bch2_btree_node_rewrite(&trans, &iter, ret = bch2_btree_node_rewrite(&trans, &iter,
b->data->keys.seq, 0) ?: ret; b->data->keys.seq, 0) ?: ret;
next: next:
bch2_trans_cond_resched(&trans);
bch2_btree_iter_next_node(&iter); bch2_btree_iter_next_node(&iter);
} }
if (ret == -EINTR) if (ret == -EINTR)
......
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