[Devel] [PATCH RHEL8 COMMIT] ploop: Kill try_preflush

Konstantin Khorenko khorenko at virtuozzo.com
Wed Jun 9 20:46:50 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.38
------>
commit 2822b0b9c7f41c65deff2a89f4cd20cae9253a8a
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Wed Jun 9 20:46:50 2021 +0300

    ploop: Kill try_preflush
    
    This is used from .dtr only, where normal IO is stopped
    and messages are not possible.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c    | 41 -----------------------------------------
 drivers/md/dm-ploop-target.c | 26 ++++++++++++--------------
 drivers/md/dm-ploop.h        |  1 -
 3 files changed, 12 insertions(+), 56 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index f6fc549d34da..e38d38a2351f 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -1485,43 +1485,6 @@ static int ploop_push_backup_write(struct ploop *ploop, char *uuid,
 	return 0;
 }
 
-static bool ploop_has_pending_activity(struct ploop *ploop)
-{
-	bool has;
-
-	spin_lock_irq(&ploop->deferred_lock);
-	has = ploop->deferred_cmd;
-	has |= !list_empty(&ploop->deferred_pios);
-	has |= !list_empty(&ploop->discard_pios);
-	has |= !list_empty(&ploop->delta_cow_action_list);
-	spin_unlock_irq(&ploop->deferred_lock);
-
-	return has;
-}
-
-static void process_try_preflush(struct ploop *ploop, struct ploop_cmd *cmd)
-{
-	/* Make all inflight bios appear in pending activities */
-	cmd->retval = ploop_inflight_bios_ref_switch(ploop, true);
-	if (!cmd->retval)
-		cmd->retval = ploop_has_pending_activity(ploop);
-	complete(&cmd->comp); /* Last touch of cmd memory */
-}
-
-static int ploop_try_preflush(struct ploop *ploop)
-{
-	struct ploop_cmd cmd = { {0} };
-
-	cmd.type = PLOOP_CMD_TRY_PREFLUSH;
-	cmd.ploop = ploop;
-
-	init_completion(&cmd.comp);
-	ploop_queue_deferred_cmd(ploop, &cmd);
-	wait_for_completion(&cmd.comp);
-	return cmd.retval;
-
-}
-
 /* Handle user commands requested via "message" interface */
 void process_deferred_cmd(struct ploop *ploop, struct ploop_index_wb *piwb)
 	__releases(&ploop->deferred_lock)
@@ -1552,8 +1515,6 @@ void process_deferred_cmd(struct ploop *ploop, struct ploop_index_wb *piwb)
 		process_flip_upper_deltas(ploop, cmd);
 	} else if (cmd->type == PLOOP_CMD_SET_PUSH_BACKUP) {
 		process_set_push_backup(ploop, cmd);
-	} else if (cmd->type == PLOOP_CMD_TRY_PREFLUSH) {
-		process_try_preflush(ploop, cmd);
 	} else {
 		cmd->retval = -EINVAL;
 		complete(&cmd->comp);
@@ -1653,8 +1614,6 @@ int ploop_message(struct dm_target *ti, unsigned int argc, char **argv,
 		if (argc != 3 || sscanf(argv[2], "%llu:%llu", &val, &val2) != 2)
 			goto unlock;
 		ret = ploop_push_backup_write(ploop, argv[1], val, val2);
-	} else if (!strcmp(argv[0], "try_preflush")) {
-		ret = ploop_try_preflush(ploop);
 	} else {
 		ret = -ENOTSUPP;
 	}
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index 2cfcdda34160..d18ff1fa5050 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -122,21 +122,18 @@ void free_md_pages_tree(struct rb_root *root)
 	}
 }
 
-/* This is called on final device destroy */
-static void ploop_flush_workqueue(struct ploop *ploop)
+static bool ploop_has_pending_activity(struct ploop *ploop)
 {
-	char *argv[1] = {"try_preflush"};
-	bool again = true;
+	bool has;
 
-	while (again) {
-		flush_workqueue(ploop->wq);
-		/*
-		 * Normally, ploop_message("try_preflush") returns 0 or 1.
-		 * In case of underlining bdev is hung, this finishes with
-		 * error by timeout, and our caller (.dtr) never completes.
-		 */
-		again = ploop_message(ploop->ti, 1, argv, NULL, 0);
-	}
+	spin_lock_irq(&ploop->deferred_lock);
+	has = ploop->deferred_cmd;
+	has |= !list_empty(&ploop->deferred_pios);
+	has |= !list_empty(&ploop->discard_pios);
+	has |= !list_empty(&ploop->delta_cow_action_list);
+	spin_unlock_irq(&ploop->deferred_lock);
+
+	return has;
 }
 
 static void ploop_destroy(struct ploop *ploop)
@@ -148,8 +145,9 @@ static void ploop_destroy(struct ploop *ploop)
 		ploop_free_pb(ploop->pb);
 	}
 	if (ploop->wq) {
-		ploop_flush_workqueue(ploop);
+		flush_workqueue(ploop->wq);
 		destroy_workqueue(ploop->wq);
+		WARN_ON_ONCE(ploop_has_pending_activity(ploop));
 	}
 	for (i = 0; i < 2; i++)
 		percpu_ref_exit(&ploop->inflight_bios_ref[i]);
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index c9d6d04684fe..a9ef7d71f446 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -48,7 +48,6 @@ struct ploop_cmd {
 #define PLOOP_CMD_TRACKING_START	7
 #define PLOOP_CMD_FLIP_UPPER_DELTAS	8
 #define PLOOP_CMD_SET_PUSH_BACKUP	9
-#define PLOOP_CMD_TRY_PREFLUSH		10
 	struct completion comp;
 	struct ploop *ploop;
 	unsigned int type;


More information about the Devel mailing list