Commit de611ab
Kent Overstreet
bcachefs: Fix race between trans_put() and btree_transactions_read()
debug.c was using closure_get() on a different thread's closure where
the we don't know if the object being refcounted is alive.
We keep btree_trans objects on a list so they can be printed by debug
code, and because it is cost prohibitive to touch the btree_trans list
every time we allocate and free btree_trans objects, cached objects are
also on this list.
However, we do not want the debug code to see cached but not in use
btree_trans objects - critically because the btree_paths array will have
been freed (if it was reallocated).
closure_get() is also incorrect to use when that get may race with it
hitting zero, i.e. we must already have a ref on the object or know the
ref can't currently hit 0 for other reasons (as used in the cycle
detector).
to fix this, use the previously introduced closure_get_not_zero(),
closure_return_sync(), and closure_init_stack_release(); the debug code
now can only take a ref on a trans object if it's alive and in use.
Signed-off-by: Kent Overstreet <[email protected]>1 parent 06efa5f commit de611ab
2 files changed
+13
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3130 | 3130 | | |
3131 | 3131 | | |
3132 | 3132 | | |
3133 | | - | |
3134 | 3133 | | |
3135 | 3134 | | |
3136 | 3135 | | |
| |||
3161 | 3160 | | |
3162 | 3161 | | |
3163 | 3162 | | |
3164 | | - | |
3165 | 3163 | | |
3166 | 3164 | | |
3167 | 3165 | | |
| |||
3200 | 3198 | | |
3201 | 3199 | | |
3202 | 3200 | | |
| 3201 | + | |
| 3202 | + | |
3203 | 3203 | | |
3204 | 3204 | | |
3205 | 3205 | | |
| |||
3257 | 3257 | | |
3258 | 3258 | | |
3259 | 3259 | | |
3260 | | - | |
| 3260 | + | |
3261 | 3261 | | |
3262 | 3262 | | |
3263 | | - | |
| 3263 | + | |
3264 | 3264 | | |
3265 | 3265 | | |
3266 | 3266 | | |
| |||
3385 | 3385 | | |
3386 | 3386 | | |
3387 | 3387 | | |
3388 | | - | |
3389 | | - | |
3390 | 3388 | | |
3391 | 3389 | | |
3392 | 3390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
587 | 587 | | |
588 | 588 | | |
589 | 589 | | |
590 | | - | |
591 | | - | |
| 590 | + | |
| 591 | + | |
592 | 592 | | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
597 | | - | |
| 593 | + | |
598 | 594 | | |
599 | 595 | | |
600 | 596 | | |
| |||
604 | 600 | | |
605 | 601 | | |
606 | 602 | | |
607 | | - | |
608 | | - | |
609 | 603 | | |
610 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
611 | 609 | | |
612 | 610 | | |
613 | 611 | | |
| |||
817 | 815 | | |
818 | 816 | | |
819 | 817 | | |
820 | | - | |
| 818 | + | |
| 819 | + | |
821 | 820 | | |
822 | 821 | | |
823 | 822 | | |
| |||
0 commit comments