[rh7] ploop: Add sanity check on stop

Submitted by Kirill Tkhai on June 14, 2019, 10:40 a.m.

Details

Message ID 156050880209.2256.2847499862029227406.stgit@localhost.localdomain
State New
Series "ploop: Add sanity check on stop"
Headers show

Commit Message

Kirill Tkhai June 14, 2019, 10:40 a.m.
Check for (unbelievable) case, when we there are uncompleted
requests on stop.

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

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

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index 9bbb2ad02fa2..0c9534f588c5 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -4132,7 +4132,7 @@  static int ploop_start(struct ploop_device * plo, struct block_device *bdev)
 
 static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
 {
-	int p;
+	int p, active_reqs;
 	struct ploop_delta * delta;
 	int cnt;
 
@@ -4183,6 +4183,13 @@  static int ploop_stop(struct ploop_device * plo, struct block_device *bdev)
 		return -EBUSY;
 	}
 
+	active_reqs = plo->active_reqs;
+	if (active_reqs) {
+		WARN_ONCE(1, "stop ploop%d failed (active_reqs=%d)\n",
+			     plo->index, active_reqs);
+		return -EBUSY;
+	}
+
 	clear_bit(PLOOP_S_PUSH_BACKUP, &plo->state);
 	ploop_pb_stop(plo->pbd, true);