From: Kent Overstreet Date: Sun, 17 Jul 2022 06:46:46 +0000 (-0400) Subject: bcachefs: bch2_bucket_alloc_trans_early -> for_each_btree_key_norestart X-Git-Tag: v6.7-rc1~201^2~859 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=db346e7120a6dec1534184ea2abf9d22edbb9b8a;p=thirdparty%2Fkernel%2Flinux.git bcachefs: bch2_bucket_alloc_trans_early -> for_each_btree_key_norestart Nested btree transactions require special care, and an upcoming patch is going to add assertions to that effect. We don't want to be using them unnecessarily, so this patch switches bch2_bucket_trans_early() to not handle transaction restarts. This patch also adds a cursor so that on transaction restart we can continue scanning from where the previous search for an empty bucket left off. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c index 99fbf1d2dee5d..bbe74a05a7a27 100644 --- a/fs/bcachefs/alloc_foreground.c +++ b/fs/bcachefs/alloc_foreground.c @@ -406,7 +406,7 @@ bch2_bucket_alloc_early(struct btree_trans *trans, u64 alloc_cursor = max(alloc_start, READ_ONCE(ca->alloc_cursor)); int ret; again: - for_each_btree_key(trans, iter, BTREE_ID_alloc, POS(ca->dev_idx, alloc_cursor), + for_each_btree_key_norestart(trans, iter, BTREE_ID_alloc, POS(ca->dev_idx, alloc_cursor), BTREE_ITER_SLOTS, k, ret) { struct bch_alloc_v4 a;