[RH7] ploop: Wake up on last discard bio from ploop_complete_request()

Submitted by Kirill Tkhai on Oct. 12, 2020, 10:08 a.m.

Details

Message ID 160249732217.18060.10192756417115969233.stgit@localhost.localdomain
State New
Series "ploop: Wake up on last discard bio from ploop_complete_request()"
Headers show

Commit Message

Kirill Tkhai Oct. 12, 2020, 10:08 a.m.
Concurrent thread waits that on pending_waitq.

https://jira.sw.ru/browse/PSBM-121135

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/dev.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index d6edbfbe4422..320a5d55d65b 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -1461,8 +1461,11 @@  static void ploop_complete_request(struct ploop_request * preq)
 	 */
 	spin_lock_irq(&plo->lock);
 	plo->active_reqs--;
-	if (preq->req_rw & REQ_DISCARD)
-		plo->discard_inflight_reqs--;
+	if (preq->req_rw & REQ_DISCARD) {
+		if (!--plo->discard_inflight_reqs &&
+		    waitqueue_active(&plo->pending_waitq))
+			wake_up(&plo->pending_waitq);
+	}
 	spin_unlock_irq(&plo->lock);
 
 	while (preq->bl.head) {