[rh7] ploop: Also decrement active_reqs before bio_endio() in ploop_complete_request()

Submitted by Kirill Tkhai on June 25, 2019, 9:15 a.m.

Details

Message ID 156145410835.5889.17370783303599815062.stgit@localhost.localdomain
State New
Series "ploop: Also decrement active_reqs before bio_endio() in ploop_complete_request()"
Headers show

Commit Message

Kirill Tkhai June 25, 2019, 9:15 a.m.
This is needed for ploop_ioctl() debug hook correct work.

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

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 10b4abc00592..64d205e691ba 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -1344,6 +1344,15 @@  static void ploop_complete_request(struct ploop_request * preq)
 
 	__TRACE("Z %p %u\n", preq, preq->req_cluster);
 
+	/*
+	 * Decrement active_reqs before BIO_IOEND() to make
+	 * a hook in ploop_stop() work properly. This is
+	 * mostly needed for debug purposes.
+	 */
+	spin_lock_irq(&plo->lock);
+	plo->active_reqs--;
+	spin_unlock_irq(&plo->lock);
+
 	while (preq->bl.head) {
 		struct bio * bio = preq->bl.head;
 		preq->bl.head = bio->bi_next;
@@ -1382,7 +1391,6 @@  static void ploop_complete_request(struct ploop_request * preq)
 
 				if (!list_empty(&preq->delay_list))
 					list_splice_init(&preq->delay_list, plo->ready_queue.prev);
-				plo->active_reqs--;
 
 				preq->eng_state = PLOOP_E_ENTRY;
 				ploop_entry_add(plo, preq);
@@ -1437,8 +1445,6 @@  static void ploop_complete_request(struct ploop_request * preq)
 	preq->preq_ub = NULL;
 #endif
 
-	plo->active_reqs--;
-
 	if (unlikely(test_bit(PLOOP_REQ_ZERO, &preq->state))) {
 		ploop_fb_put_zero_request(plo->fbd, preq);
 	} else {