Commit eb2de94
committed
io-wq: fix race around io_worker grabbing
There's a small window between lookup dropping the reference to the
worker and calling wake_up_process() on the worker task, where the worker
itself could have exited. We ensure that the worker struct itself is
valid, but worker->task may very well be gone by the time we issue the
wakeup.
Fix the race by using a completion triggered by the reference going to
zero, and having exit wait for that completion before proceeding.
Signed-off-by: Jens Axboe <axboe@kernel.dk>1 parent 8b3e78b commit eb2de94
1 file changed
+9
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
129 | 131 | | |
130 | 132 | | |
131 | 133 | | |
132 | | - | |
| 134 | + | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
| |||
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
168 | 165 | | |
169 | 166 | | |
170 | 167 | | |
| |||
615 | 612 | | |
616 | 613 | | |
617 | 614 | | |
| 615 | + | |
618 | 616 | | |
619 | 617 | | |
620 | 618 | | |
| |||
724 | 722 | | |
725 | 723 | | |
726 | 724 | | |
| 725 | + | |
727 | 726 | | |
728 | 727 | | |
729 | 728 | | |
| |||
734 | 733 | | |
735 | 734 | | |
736 | 735 | | |
| 736 | + | |
737 | 737 | | |
738 | 738 | | |
739 | 739 | | |
| |||
0 commit comments