Skip to content

Commit 427ba55

Browse files
author
Kent Overstreet
committed
bcachefs: Fix rcu splat in check_fix_ptrs()
Signed-off-by: Kent Overstreet <[email protected]>
1 parent eb6a933 commit 427ba55

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/bcachefs/buckets.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,8 @@ int bch2_check_fix_ptrs(struct btree_trans *trans,
479479

480480
percpu_down_read(&c->mark_lock);
481481

482-
rcu_read_lock();
483482
bkey_for_each_ptr_decode(k.k, ptrs_c, p, entry_c) {
484-
struct bch_dev *ca = bch2_dev_rcu(c, p.ptr.dev);
483+
struct bch_dev *ca = bch2_dev_tryget(c, p.ptr.dev);
485484
if (!ca) {
486485
if (fsck_err(c, ptr_to_invalid_device,
487486
"pointer to missing device %u\n"
@@ -558,7 +557,7 @@ int bch2_check_fix_ptrs(struct btree_trans *trans,
558557
do_update = true;
559558

560559
if (data_type != BCH_DATA_btree && p.ptr.gen != g->gen)
561-
continue;
560+
goto next;
562561

563562
if (fsck_err_on(bucket_data_type_mismatch(g->data_type, data_type),
564563
c, ptr_bucket_data_type_mismatch,
@@ -601,8 +600,9 @@ int bch2_check_fix_ptrs(struct btree_trans *trans,
601600
bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
602601
do_update = true;
603602
}
603+
next:
604+
bch2_dev_put(ca);
604605
}
605-
rcu_read_unlock();
606606

607607
if (do_update) {
608608
if (flags & BTREE_TRIGGER_is_root) {
@@ -638,9 +638,10 @@ int bch2_check_fix_ptrs(struct btree_trans *trans,
638638
} else {
639639
struct bkey_ptrs ptrs;
640640
union bch_extent_entry *entry;
641+
642+
rcu_read_lock();
641643
restart_drop_ptrs:
642644
ptrs = bch2_bkey_ptrs(bkey_i_to_s(new));
643-
rcu_read_lock();
644645
bkey_for_each_ptr_decode(bkey_i_to_s(new).k, ptrs, p, entry) {
645646
struct bch_dev *ca = bch2_dev_rcu(c, p.ptr.dev);
646647
struct bucket *g = PTR_GC_BUCKET(ca, &p.ptr);

0 commit comments

Comments
 (0)