mirror of
https://github.com/torvalds/linux.git
synced 2026-05-30 10:04:04 +02:00
bcachefs: reduce new_stripe_alloc_buckets() stack usage
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
a0b0b9bb9e
commit
2a81bd454c
|
|
@ -829,15 +829,15 @@ static int bucket_alloc_set_writepoint(struct bch_fs *c,
|
|||
unsigned i;
|
||||
int ret = 0;
|
||||
|
||||
req->ptrs2.nr = 0;
|
||||
req->scratch_ptrs.nr = 0;
|
||||
|
||||
open_bucket_for_each(c, &req->wp->ptrs, ob, i) {
|
||||
if (!ret && want_bucket(c, req, ob))
|
||||
ret = add_new_bucket(c, req, ob);
|
||||
else
|
||||
ob_push(c, &req->ptrs2, ob);
|
||||
ob_push(c, &req->scratch_ptrs, ob);
|
||||
}
|
||||
req->wp->ptrs = req->ptrs2;
|
||||
req->wp->ptrs = req->scratch_ptrs;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1214,7 +1214,7 @@ deallocate_extra_replicas(struct bch_fs *c,
|
|||
unsigned extra_replicas = req->nr_effective - req->nr_replicas;
|
||||
unsigned i;
|
||||
|
||||
req->ptrs2.nr = 0;
|
||||
req->scratch_ptrs.nr = 0;
|
||||
|
||||
open_bucket_for_each(c, &req->ptrs, ob, i) {
|
||||
unsigned d = ob_dev(c, ob)->mi.durability;
|
||||
|
|
@ -1223,11 +1223,11 @@ deallocate_extra_replicas(struct bch_fs *c,
|
|||
extra_replicas -= d;
|
||||
ob_push(c, &req->wp->ptrs, ob);
|
||||
} else {
|
||||
ob_push(c, &req->ptrs2, ob);
|
||||
ob_push(c, &req->scratch_ptrs, ob);
|
||||
}
|
||||
}
|
||||
|
||||
req->ptrs = req->ptrs2;
|
||||
req->ptrs = req->scratch_ptrs;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ struct alloc_request {
|
|||
|
||||
/* These fields are used primarily by open_bucket_add_buckets */
|
||||
struct open_buckets ptrs;
|
||||
struct open_buckets ptrs2;
|
||||
unsigned nr_effective; /* sum of @ptrs durability */
|
||||
bool have_cache; /* have we allocated from a 0 durability dev */
|
||||
struct bch_devs_mask devs_may_alloc;
|
||||
|
|
@ -62,6 +61,13 @@ struct alloc_request {
|
|||
u64 skipped_nouse;
|
||||
u64 skipped_mi_btree_bitmap;
|
||||
} counters;
|
||||
|
||||
unsigned scratch_nr_replicas;
|
||||
unsigned scratch_nr_effective;
|
||||
bool scratch_have_cache;
|
||||
enum bch_data_type scratch_data_type;
|
||||
struct open_buckets scratch_ptrs;
|
||||
struct bch_devs_mask scratch_devs_may_alloc;
|
||||
};
|
||||
|
||||
struct dev_alloc_list bch2_dev_alloc_list(struct bch_fs *,
|
||||
|
|
|
|||
|
|
@ -1720,12 +1720,12 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans,
|
|||
unsigned i, j, nr_have_parity = 0, nr_have_data = 0;
|
||||
int ret = 0;
|
||||
|
||||
enum bch_data_type saved_data_type = req->data_type;
|
||||
struct open_buckets saved_ptrs = req->ptrs;
|
||||
unsigned saved_nr_replicas = req->nr_replicas;
|
||||
unsigned saved_nr_effective = req->nr_effective;
|
||||
bool saved_have_cache = req->have_cache;
|
||||
struct bch_devs_mask saved_devs_may_alloc = req->devs_may_alloc;
|
||||
req->scratch_data_type = req->data_type;
|
||||
req->scratch_ptrs = req->ptrs;
|
||||
req->scratch_nr_replicas = req->nr_replicas;
|
||||
req->scratch_nr_effective = req->nr_effective;
|
||||
req->scratch_have_cache = req->have_cache;
|
||||
req->scratch_devs_may_alloc = req->devs_may_alloc;
|
||||
|
||||
req->devs_may_alloc = h->devs;
|
||||
req->have_cache = true;
|
||||
|
|
@ -1801,12 +1801,12 @@ static int new_stripe_alloc_buckets(struct btree_trans *trans,
|
|||
goto err;
|
||||
}
|
||||
err:
|
||||
req->data_type = saved_data_type;
|
||||
req->ptrs = saved_ptrs;
|
||||
req->nr_replicas = saved_nr_replicas;
|
||||
req->nr_effective = saved_nr_effective;
|
||||
req->have_cache = saved_have_cache;
|
||||
req->devs_may_alloc = saved_devs_may_alloc;
|
||||
req->data_type = req->scratch_data_type;
|
||||
req->ptrs = req->scratch_ptrs;
|
||||
req->nr_replicas = req->scratch_nr_replicas;
|
||||
req->nr_effective = req->scratch_nr_effective;
|
||||
req->have_cache = req->scratch_have_cache;
|
||||
req->devs_may_alloc = req->scratch_devs_may_alloc;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user