diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-19 14:51:52 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-03 22:52:26 -0400 |
commit | 030ac4b51ea2b412ef9c1a1bae1d68a581b70413 (patch) | |
tree | 26c845d0e3ddcdeb1b397d8d3bbf0387c5c57e06 | |
parent | 6c5e4105512abe76e293029a59795bbcf8ff8218 (diff) |
bcachefs: Prevent a btree iter overflow in alloc path
In bch2_bucket_alloc_trans(), we're iterating over buckets - but not
directly with an iterator, since we're iterating over the freespace
btree.
This means that we need to clear iter->path->preserve, otherwise we'll
end up retaining a btree_path for every alloc key we touched - which is
not what we want here.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r-- | fs/bcachefs/alloc_foreground.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 8899d15651d3..9ba46714b627 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -340,6 +340,7 @@ static struct open_bucket *try_alloc_bucket(struct btree_trans *trans, struct bc skipped_nouse, cl); err: + set_btree_iter_dontneed(&iter); bch2_trans_iter_exit(trans, &iter); printbuf_exit(&buf); return ob; @@ -455,6 +456,11 @@ static struct open_bucket *bch2_bucket_alloc_trans(struct btree_trans *trans, BUG_ON(ca->new_fs_bucket_idx); + /* + * XXX: + * On transaction restart, we'd like to restart from the bucket we were + * at previously + */ for_each_btree_key_norestart(trans, iter, BTREE_ID_freespace, POS(ca->dev_idx, *cur_bucket), 0, k, ret) { if (k.k->p.inode != ca->dev_idx) |