4.14.109-rt58-rc1 stable review patch.
If anyone has any objections, please let me know.

------------------

From: Scott Wood <[email protected]>

[ Upstream commit 0d5d32425a0cab4a282dd79fc953d76a3ab17072 ]

__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: [email protected]
Signed-off-by: Scott Wood <[email protected]>
Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Signed-off-by: Tom Zanussi <[email protected]>

 Conflicts:
        kernel/locking/rwsem-rt.c
---
 kernel/locking/rtmutex.c  | 2 +-
 kernel/locking/rwsem-rt.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 2cf515877b8e..1177f2815040 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -1946,7 +1946,7 @@ rt_mutex_fastlock(struct rt_mutex *lock, int state,
         * 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 device mapper may happen.
+        * a deadlock in I/O may happen.
         */
        if (unlikely(blk_needs_flush_plug(current)))
                blk_schedule_flush_plug(current);
diff --git a/kernel/locking/rwsem-rt.c b/kernel/locking/rwsem-rt.c
index 26991ddb6c5a..dbdde2476b1c 100644
--- a/kernel/locking/rwsem-rt.c
+++ b/kernel/locking/rwsem-rt.c
@@ -1,5 +1,6 @@
 /*
  */
+#include <linux/blkdev.h>
 #include <linux/rwsem.h>
 #include <linux/sched/debug.h>
 #include <linux/sched/signal.h>
@@ -86,6 +87,14 @@ void __sched __down_read(struct rw_semaphore *sem)
 
        if (__down_read_trylock(sem))
                return;
+       /*
+        * 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);
-- 
2.14.1

Reply via email to