mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
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: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
parent
114eea75c7
commit
b0d1b70af8
@ -367,8 +367,6 @@ int bch2_alloc_write(struct bch_fs *c, unsigned flags)
|
||||
POS(ca->dev_idx, ca->mi.first_bucket));
|
||||
|
||||
while (iter.pos.offset < ca->mi.nbuckets) {
|
||||
bch2_trans_cond_resched(&trans);
|
||||
|
||||
ret = bch2_alloc_write_key(&trans, &iter, flags);
|
||||
if (ret) {
|
||||
percpu_ref_put(&ca->ref);
|
||||
|
@ -828,8 +828,6 @@ static int bch2_gc_btree(struct bch_fs *c, enum btree_id btree_id,
|
||||
BTREE_INSERT_NOWAIT|
|
||||
BTREE_INSERT_GC_LOCK_HELD);
|
||||
}
|
||||
|
||||
bch2_trans_cond_resched(&trans);
|
||||
}
|
||||
bch2_trans_iter_exit(&trans, &iter);
|
||||
|
||||
|
@ -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 *);
|
||||
|
||||
/*
|
||||
* 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,
|
||||
enum btree_id r_btree_id,
|
||||
bool r_cached,
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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_init(struct btree_trans *, struct btree_iter *,
|
||||
unsigned, struct bpos, unsigned);
|
||||
|
@ -1414,8 +1414,6 @@ retry:
|
||||
BTREE_INSERT_NOFAIL);
|
||||
if (ret)
|
||||
break;
|
||||
|
||||
bch2_trans_cond_resched(trans);
|
||||
}
|
||||
|
||||
if (ret == -EINTR) {
|
||||
|
@ -2116,8 +2116,6 @@ static int check_nlinks_walk_dirents(struct bch_fs *c, struct nlink_table *links
|
||||
d.k->p.snapshot);
|
||||
break;
|
||||
}
|
||||
|
||||
bch2_trans_cond_resched(&trans);
|
||||
}
|
||||
bch2_trans_iter_exit(&trans, &iter);
|
||||
|
||||
|
@ -768,7 +768,6 @@ next:
|
||||
&stats->sectors_seen);
|
||||
next_nondata:
|
||||
bch2_btree_iter_advance(&iter);
|
||||
bch2_trans_cond_resched(&trans);
|
||||
}
|
||||
out:
|
||||
|
||||
@ -914,7 +913,6 @@ retry:
|
||||
ret = bch2_btree_node_rewrite(&trans, &iter,
|
||||
b->data->keys.seq, 0) ?: ret;
|
||||
next:
|
||||
bch2_trans_cond_resched(&trans);
|
||||
bch2_btree_iter_next_node(&iter);
|
||||
}
|
||||
if (ret == -EINTR)
|
||||
|
Loading…
Reference in New Issue
Block a user