[rh8,1/2] ploop: Check for all delayed bio lists on destroy

Submitted by Kirill Tkhai on March 11, 2020, 2:26 p.m.

Details

Message ID 158393676166.376475.348585123589158276.stgit@localhost.localdomain
State New
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai March 11, 2020, 2:26 p.m.
dev_remove() (unlike suspend) calls .dtr only, so it must care
about all inflight activity.
Add the rest of delayed bio lists to the check.

Also, since dm_suspend() waits for all inflight bios,
we remove ploop_flush_workqueue() from postsuspend.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-target.c |   21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 546056e7e6d6..318048227f53 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -29,16 +29,27 @@  static void inflight_bios_ref_exit1(struct percpu_ref *ref)
 	complete(&ploop->inflight_bios_ref_comp);
 }
 
+static bool ploop_has_pending_activity(struct ploop *ploop)
+{
+	bool has;
+
+	spin_lock_irq(&ploop->deferred_lock);
+	has = ploop->deferred_cmd;
+	has |= !bio_list_empty(&ploop->deferred_bios);
+	has |= !bio_list_empty(&ploop->discard_bios);
+	has |= !bio_list_empty(&ploop->delta_cow_action_list);
+	spin_unlock_irq(&ploop->deferred_lock);
+
+	return has;
+}
+
 static void ploop_flush_workqueue(struct ploop *ploop)
 {
 	bool again = true;
 
 	while (again) {
 		flush_workqueue(ploop->wq);
-
-		spin_lock_irq(&ploop->deferred_lock);
-		again = ploop->deferred_cmd || !bio_list_empty(&ploop->deferred_bios);
-		spin_unlock_irq(&ploop->deferred_lock);
+		again = ploop_has_pending_activity(ploop);
 		if (again)
 			schedule_timeout(HZ);
 	}
@@ -237,8 +248,6 @@  static void ploop_postsuspend(struct dm_target *ti)
 {
 	struct ploop *ploop = ti->private;
 
-	ploop_flush_workqueue(ploop);
-
 	blkdev_issue_flush(ploop->origin_dev->bdev, GFP_NOIO, NULL);
 }