[Devel] [PATCH RHEL8 COMMIT] ploop: Check for all delayed bio lists on destroy

Konstantin Khorenko khorenko at virtuozzo.com
Thu Mar 12 13:16:45 MSK 2020


The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.3.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.3.3
------>
commit de4f03d2a998d0ff9c2f89891d60592c31ace733
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu Mar 12 13:16:45 2020 +0300

    ploop: Check for all delayed bio lists on destroy
    
    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 at virtuozzo.com>
---
 drivers/md/dm-ploop-target.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

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);
 }
 


More information about the Devel mailing list