diff mbox

dm/mpath: flush workqueue only in necessary

Message ID 1521728558-10695-1-git-send-email-wuzhouhui14@mails.ucas.ac.cn (mailing list archive)
State Accepted, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

wuzhouhui March 22, 2018, 2:22 p.m. UTC
The workqueue are shared by many multipath devices, we just need to flush
whole workqueue when it is necessary. Otherwise, we just flush works.

Signed-off-by: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>
---
 drivers/md/dm-mpath.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index f7810cc..0f14732 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1154,9 +1154,10 @@  static void flush_multipath_work(struct multipath *m)
 	set_bit(MPATHF_PG_INIT_DISABLED, &m->flags);
 	smp_mb__after_atomic();
 
-	flush_workqueue(kmpath_handlerd);
+	if (atomic_read(&m->pg_init_in_progress))
+		flush_workqueue(kmpath_handlerd);
 	multipath_wait_for_pg_init_completion(m);
-	flush_workqueue(kmultipathd);
+	flush_work(&m->process_queued_bios);
 	flush_work(&m->trigger_event);
 
 	clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags);