[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH] libmultipath: multipath active paths count optimization



Hi Martin, Ben and other viewers

Cloud you help to view below patch which try to deal with a multipath active paths
count not right issue, thanks a lot.

>From deee7196ece43b01b8ee635e60ce465080905b5e Mon Sep 17 00:00:00 2001
From: Chongyun Wu <wu chongyun h3c com>
Date: Tue, 27 Aug 2019 13:58:33 +0800
Subject: [PATCH] libmultipath:  multipath active paths count optimization

Really count multipath active paths not use mpp->nr_active++
or mpp->nr_active--, because there are other places might call
pathinfo to change path state not only in check_path, if other
places detect and changed path state but not do mpp->nr_active++
or mpp->nr_active--, the active paths might not right any more.

We meet an issue which actually have three paths but after all
paths down syslog report have three paths remaining so multipathd
not send disable queueing to dm and this dm device been blocked.
This patch might fix this issue.

Signed-off-by: Chongyun Wu <wu chongyun h3c com>
---
 libmultipath/structs_vec.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c
index c43b58f..7e2441b 100644
--- a/libmultipath/structs_vec.c
+++ b/libmultipath/structs_vec.c
@@ -450,7 +450,8 @@ int verify_paths(struct multipath *mpp, struct vectors *vecs)
  */
 void update_queue_mode_del_path(struct multipath *mpp)
 {
-	if (--mpp->nr_active == 0) {
+	mpp->nr_active = pathcount(mpp, PATH_UP) + pathcount(mpp, PATH_GHOST);
+	if (mpp->nr_active == 0) {
 		if (mpp->no_path_retry > 0)
 			enter_recovery_mode(mpp);
 		else if (mpp->no_path_retry != NO_PATH_RETRY_QUEUE)
@@ -461,7 +462,10 @@ void update_queue_mode_del_path(struct multipath *mpp)
 
 void update_queue_mode_add_path(struct multipath *mpp)
 {
-	if (mpp->nr_active++ == 0 && mpp->no_path_retry > 0) {
+	int old_active_paths = mpp->nr_active;
+	mpp->nr_active = pathcount(mpp, PATH_UP) + pathcount(mpp, PATH_GHOST);
+	if ((old_active_paths == 0 && mpp->nr_active == 1)
+		&& mpp->no_path_retry > 0) {
 		/* come back to normal mode from retry mode */
 		mpp->retry_tick = 0;
 		dm_queue_if_no_path(mpp->alias, 1);
-- 

Best Regards´╝î
Chongyun Wu



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]