mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
bcachefs: Fix an rcu splat
bch2_bucket_alloc() requires rcu_read_lock() to be held. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
b7a9bbfc1b
commit
f302055077
@ -682,16 +682,19 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
|
|||||||
if (nr <= ja->nr)
|
if (nr <= ja->nr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = -ENOMEM;
|
|
||||||
new_buckets = kzalloc(nr * sizeof(u64), GFP_KERNEL);
|
new_buckets = kzalloc(nr * sizeof(u64), GFP_KERNEL);
|
||||||
new_bucket_seq = kzalloc(nr * sizeof(u64), GFP_KERNEL);
|
new_bucket_seq = kzalloc(nr * sizeof(u64), GFP_KERNEL);
|
||||||
if (!new_buckets || !new_bucket_seq)
|
if (!new_buckets || !new_bucket_seq) {
|
||||||
|
ret = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
journal_buckets = bch2_sb_resize_journal(&ca->disk_sb,
|
journal_buckets = bch2_sb_resize_journal(&ca->disk_sb,
|
||||||
nr + sizeof(*journal_buckets) / sizeof(u64));
|
nr + sizeof(*journal_buckets) / sizeof(u64));
|
||||||
if (!journal_buckets)
|
if (!journal_buckets) {
|
||||||
|
ret = -ENOSPC;
|
||||||
goto err;
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We may be called from the device add path, before the new device has
|
* We may be called from the device add path, before the new device has
|
||||||
@ -720,8 +723,10 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
rcu_read_lock();
|
||||||
ob = bch2_bucket_alloc(c, ca, RESERVE_ALLOC,
|
ob = bch2_bucket_alloc(c, ca, RESERVE_ALLOC,
|
||||||
false, cl);
|
false, cl);
|
||||||
|
rcu_read_unlock();
|
||||||
if (IS_ERR(ob)) {
|
if (IS_ERR(ob)) {
|
||||||
ret = cl ? -EAGAIN : -ENOSPC;
|
ret = cl ? -EAGAIN : -ENOSPC;
|
||||||
goto err;
|
goto err;
|
||||||
@ -773,8 +778,6 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
|
|||||||
if (!new_fs)
|
if (!new_fs)
|
||||||
bch2_open_bucket_put(c, ob);
|
bch2_open_bucket_put(c, ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
err:
|
err:
|
||||||
bch2_sb_resize_journal(&ca->disk_sb,
|
bch2_sb_resize_journal(&ca->disk_sb,
|
||||||
ja->nr + sizeof(*journal_buckets) / sizeof(u64));
|
ja->nr + sizeof(*journal_buckets) / sizeof(u64));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user