summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-03-31 17:54:43 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-04-06 19:13:45 -0400
commitf1102be07677ba01c38ae107a7b6752d68e3ab24 (patch)
treed9bed92c89d0606c952e4e5f429fe498bd6577bc
parent067a3eeadc1a229e5fe409944a7500406dd562ea (diff)
bcachefs: alloc_request: deallocate_extra_replicas()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/alloc_foreground.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fs/bcachefs/alloc_foreground.c b/fs/bcachefs/alloc_foreground.c
index 6f3cee1083b0..6147cc1cf19a 100644
--- a/fs/bcachefs/alloc_foreground.c
+++ b/fs/bcachefs/alloc_foreground.c
@@ -1219,26 +1219,25 @@ out:
static noinline void
deallocate_extra_replicas(struct bch_fs *c,
- struct open_buckets *ptrs,
- struct open_buckets *ptrs_no_use,
- unsigned extra_replicas)
+ struct alloc_request *req)
{
struct open_buckets ptrs2 = { 0 };
struct open_bucket *ob;
+ unsigned extra_replicas = req->nr_effective - req->nr_replicas;
unsigned i;
- open_bucket_for_each(c, ptrs, ob, i) {
+ open_bucket_for_each(c, &req->ptrs, ob, i) {
unsigned d = ob_dev(c, ob)->mi.durability;
if (d && d <= extra_replicas) {
extra_replicas -= d;
- ob_push(c, ptrs_no_use, ob);
+ ob_push(c, &req->wp->ptrs, ob);
} else {
ob_push(c, &ptrs2, ob);
}
}
- *ptrs = ptrs2;
+ req->ptrs = ptrs2;
}
/*
@@ -1335,8 +1334,7 @@ alloc_done:
goto err;
if (req.nr_effective > req.nr_replicas)
- deallocate_extra_replicas(c, &req.ptrs, &req.wp->ptrs,
- req.nr_effective - req.nr_replicas);
+ deallocate_extra_replicas(c, &req);
/* Free buckets we didn't use: */
open_bucket_for_each(c, &req.wp->ptrs, ob, i)