mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-19 00:54:41 +08:00
bcachefs: Fix ca->oldest_gen allocation
The ca->oldest_gen array needs to be the same size as the bucket_gens array; ca->mi.nbuckets is updated with only state_lock held, not gc_lock, so bch2_gc_gens() could race with device resize and allocate too small of an oldest_gens array. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
a1d97d8417
commit
253ba178c8
@ -1954,19 +1954,17 @@ int bch2_gc_gens(struct bch_fs *c)
|
||||
trans = bch2_trans_get(c);
|
||||
|
||||
for_each_member_device(ca, c, i) {
|
||||
struct bucket_gens *gens;
|
||||
struct bucket_gens *gens = bucket_gens(ca);
|
||||
|
||||
BUG_ON(ca->oldest_gen);
|
||||
|
||||
ca->oldest_gen = kvmalloc(ca->mi.nbuckets, GFP_KERNEL);
|
||||
ca->oldest_gen = kvmalloc(gens->nbuckets, GFP_KERNEL);
|
||||
if (!ca->oldest_gen) {
|
||||
percpu_ref_put(&ca->ref);
|
||||
ret = -BCH_ERR_ENOMEM_gc_gens;
|
||||
goto err;
|
||||
}
|
||||
|
||||
gens = bucket_gens(ca);
|
||||
|
||||
for (b = gens->first_bucket;
|
||||
b < gens->nbuckets; b++)
|
||||
ca->oldest_gen[b] = gens->b[b];
|
||||
|
Loading…
Reference in New Issue
Block a user