.. | .. |
---|
1 | | -/* |
---|
2 | | - */ |
---|
3 | | -#include <linux/blkdev.h> |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
4 | 2 | #include <linux/rwsem.h> |
---|
5 | 3 | #include <linux/sched/debug.h> |
---|
6 | 4 | #include <linux/sched/signal.h> |
---|
7 | 5 | #include <linux/export.h> |
---|
| 6 | +#include <linux/blkdev.h> |
---|
8 | 7 | |
---|
9 | 8 | #include "rtmutex_common.h" |
---|
10 | 9 | |
---|
.. | .. |
---|
88 | 87 | |
---|
89 | 88 | if (__down_read_trylock(sem)) |
---|
90 | 89 | return 0; |
---|
| 90 | + |
---|
91 | 91 | /* |
---|
92 | | - * If rt_mutex blocks, the function sched_submit_work will not call |
---|
93 | | - * blk_schedule_flush_plug (because tsk_is_pi_blocked would be true). |
---|
94 | | - * We must call blk_schedule_flush_plug here, if we don't call it, |
---|
95 | | - * a deadlock in I/O may happen. |
---|
| 92 | + * Flush blk before ->pi_blocked_on is set. At schedule() time it is too |
---|
| 93 | + * late if one of the callbacks needs to acquire a sleeping lock. |
---|
96 | 94 | */ |
---|
97 | | - if (unlikely(blk_needs_flush_plug(current))) |
---|
| 95 | + if (blk_needs_flush_plug(current)) |
---|
98 | 96 | blk_schedule_flush_plug(current); |
---|
99 | 97 | |
---|
100 | 98 | might_sleep(); |
---|
.. | .. |
---|
229 | 227 | struct rt_mutex *m = &sem->rtmutex; |
---|
230 | 228 | unsigned long flags; |
---|
231 | 229 | |
---|
| 230 | + /* |
---|
| 231 | + * Flush blk before ->pi_blocked_on is set. At schedule() time it is too |
---|
| 232 | + * late if one of the callbacks needs to acquire a sleeping lock. |
---|
| 233 | + */ |
---|
| 234 | + if (blk_needs_flush_plug(current)) |
---|
| 235 | + blk_schedule_flush_plug(current); |
---|
| 236 | + |
---|
232 | 237 | /* Take the rtmutex as a first step */ |
---|
233 | 238 | if (__rt_mutex_lock_state(m, state)) |
---|
234 | 239 | return -EINTR; |
---|