diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-10-24 16:40:05 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:14 -0400 |
commit | b0d1b70af85718a58e4edd796251a3600a20b6d5 (patch) | |
tree | 2e5d13ecd4a048106b2ac309dd9b00af6f27f8de /fs | |
parent | 114eea75c73dfd95ae529eb841aad0330793f446 (diff) | |
download | linux-stable-b0d1b70af85718a58e4edd796251a3600a20b6d5.tar.gz linux-stable-b0d1b70af85718a58e4edd796251a3600a20b6d5.tar.bz2 linux-stable-b0d1b70af85718a58e4edd796251a3600a20b6d5.zip |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/bcachefs/alloc_background.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_gc.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.c | 15 | ||||
-rw-r--r-- | fs/bcachefs/btree_iter.h | 15 | ||||
-rw-r--r-- | fs/bcachefs/btree_update_leaf.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/fsck.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/move.c | 2 |
7 files changed, 15 insertions, 25 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index fc1b4b354b05..2551ccc99d38 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -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); diff --git a/fs/bcachefs/btree_gc.c b/fs/bcachefs/btree_gc.c index 315a78b5ba8b..75d881b7a6c9 100644 --- a/fs/bcachefs/btree_gc.c +++ b/fs/bcachefs/btree_gc.c @@ -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); diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 2b51245dd5fe..189c020d289a 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -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, diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index fea1101155be..e58cad4b8fc6 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -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); diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 22fce150781e..8b4933add017 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1414,8 +1414,6 @@ retry: BTREE_INSERT_NOFAIL); if (ret) break; - - bch2_trans_cond_resched(trans); } if (ret == -EINTR) { diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c index 58d42734c252..197b9079e2b8 100644 --- a/fs/bcachefs/fsck.c +++ b/fs/bcachefs/fsck.c @@ -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); diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c index 4e2bd1474a0a..db9800141728 100644 --- a/fs/bcachefs/move.c +++ b/fs/bcachefs/move.c @@ -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) |