locking/rt-mutex: Flush block plug on __down_read()

__down_read() bypasses the rtmutex frontend to call
rt_mutex_slowlock_locked() directly, and thus it needs to call
blk_schedule_flush_flug() itself.

Cc: stable-rt@vger.kernel.org
Signed-off-by: Scott Wood <swood@redhat.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
This commit is contained in:
Scott Wood 2019-01-04 15:33:21 -05:00 committed by Alibek Omarov
parent 867ae8be55
commit 714e8359dd
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
/*
*/
#include <linux/blkdev.h>
#include <linux/rwsem.h>
#include <linux/sched/debug.h>
#include <linux/sched/signal.h>
@ -87,6 +88,14 @@ static int __sched __down_read_common(struct rw_semaphore *sem, int state)
if (__down_read_trylock(sem))
return 0;
/*
* If rt_mutex blocks, the function sched_submit_work will not call
* blk_schedule_flush_plug (because tsk_is_pi_blocked would be true).
* We must call blk_schedule_flush_plug here, if we don't call it,
* a deadlock in I/O may happen.
*/
if (unlikely(blk_needs_flush_plug(current)))
blk_schedule_flush_plug(current);
might_sleep();
raw_spin_lock_irq(&m->wait_lock);