summaryrefslogtreecommitdiff
path: root/fs/bcachefs/journal.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-07-20 22:08:17 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:07 -0400
commit97446a242a56f9350be7b8985ed933fe9118f41e (patch)
tree5b5b619d94cdc107540800a1ee8ca2454e1ffc85 /fs/bcachefs/journal.c
parent1c7a0adf3112090c42ef93ac84aad97bf4d414d3 (diff)
downloadlwn-97446a242a56f9350be7b8985ed933fe9118f41e.tar.gz
lwn-97446a242a56f9350be7b8985ed933fe9118f41e.zip
bcachefs: Fix device add
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal.c')
-rw-r--r--fs/bcachefs/journal.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/bcachefs/journal.c b/fs/bcachefs/journal.c
index 697f601c2cdf..fe2926095770 100644
--- a/fs/bcachefs/journal.c
+++ b/fs/bcachefs/journal.c
@@ -727,6 +727,10 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
if (!journal_buckets)
goto err;
+ /*
+ * We may be called from the device add path, before the new device has
+ * actually been added to the running filesystem:
+ */
if (c)
spin_lock(&c->journal.lock);
@@ -743,10 +747,7 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
long bucket;
if (new_fs) {
- percpu_down_read(&c->usage_lock);
bucket = bch2_bucket_alloc_new_fs(ca);
- percpu_up_read(&c->usage_lock);
-
if (bucket < 0) {
ret = -ENOSPC;
goto err;
@@ -765,6 +766,8 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
if (c) {
percpu_down_read(&c->usage_lock);
spin_lock(&c->journal.lock);
+ } else {
+ preempt_disable();
}
__array_insert_item(ja->buckets, ja->nr, ja->last_idx);
@@ -792,6 +795,8 @@ static int __bch2_set_nr_journal_buckets(struct bch_dev *ca, unsigned nr,
if (c) {
spin_unlock(&c->journal.lock);
percpu_up_read(&c->usage_lock);
+ } else {
+ preempt_enable();
}
if (!new_fs)