All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandra Seetharaman <sekharan@us.ibm.com>
To: Christophe Varoqui <christophe.varoqui@free.fr>
Cc: dm-devel <dm-devel@redhat.com>
Subject: [PATCH] Use Average path priority value for path switching
Date: Thu, 02 Jul 2009 18:11:14 -0700	[thread overview]
Message-ID: <1246583474.30568.2.camel@chandra-ubuntu> (raw)

Hello,

Few weeks back I posted some issues w.r.t the way path priorities are
used during path switching.

Here is Hannes's latest response
(http://marc.info/?l=dm-devel&m=124573807907764&w=2) and this patch is
based on his suggestion.

regards,

chandra
----------------------------------------------------------------------- 
Failback happens only when the sum of priorities of all paths
(on the higher priority path group) is greater than the sum
of priorities of all paths on the lower priority path group.

This leads into problems when there are more than one paths
in each of the path groups, and the sum of all paths in the
lower priority path group is greater than that of path priority
of a single high priority path.

This patch fixes the problem by using average priority of a
path group in deciding path group switch over.

Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
---
 libmultipath/structs.h     |    1 +
 libmultipath/switchgroup.c |   23 ++++++++++++++++++-----
 2 files changed, 19 insertions(+), 5 deletions(-)

Index: multipath-tools-mainline/libmultipath/structs.h
===================================================================
--- multipath-tools-mainline.orig/libmultipath/structs.h
+++ multipath-tools-mainline/libmultipath/structs.h
@@ -202,6 +202,7 @@ struct pathgroup {
 	long id;
 	int status;
 	int priority;
+	int up_paths;
 	vector paths;
 	char * selector;
 };
Index: multipath-tools-mainline/libmultipath/switchgroup.c
===================================================================
--- multipath-tools-mainline.orig/libmultipath/switchgroup.c
+++ multipath-tools-mainline/libmultipath/switchgroup.c
@@ -14,13 +14,16 @@ path_group_prio_update (struct pathgroup
 	int priority = 0;
 	struct path * pp;
 
+	pgp->up_paths = 0;
 	if (!pgp->paths) {
 		pgp->priority = 0;
 		return;
 	}
 	vector_foreach_slot (pgp->paths, pp, i) {
-		if (pp->state != PATH_DOWN)
+		if (pp->state != PATH_DOWN) {
 			priority += pp->priority;
+			pgp->up_paths++;
+		}
 	}
 	pgp->priority = priority;
 }
@@ -29,8 +32,9 @@ extern int
 select_path_group (struct multipath * mpp)
 {
 	int i;
-	int highest = 0;
+	int highest_avg = 0;
 	int bestpg = 1;
+	int avg_priority, highest_up_paths = 1;
 	struct pathgroup * pgp;
 
 	if (!mpp->pg)
@@ -41,9 +45,18 @@ select_path_group (struct multipath * mp
 			continue;
 
 		path_group_prio_update(pgp);
-		if (pgp->priority > highest) {
-			highest = pgp->priority;
-			bestpg = i + 1;
+		if (pgp->up_paths) {
+			avg_priority = pgp->priority / pgp->up_paths;
+			if (avg_priority > highest_avg) {
+				highest_avg = avg_priority;
+				highest_up_paths = pgp->up_paths;
+				bestpg = i + 1;
+			} else if (avg_priority == highest_avg) {
+				if (pgp->up_paths > highest_up_paths) {
+					highest_up_paths = pgp->up_paths;
+					bestpg = i + 1;
+				}
+			}
 		}
 	}
 	return bestpg;

             reply	other threads:[~2009-07-03  1:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-03  1:11 Chandra Seetharaman [this message]
2009-07-03  6:40 ` [PATCH] Use Average path priority value for path switching Hannes Reinecke
2009-07-06 18:17   ` Chandra Seetharaman
2009-07-30 20:13 ` [RESEND] " Chandra Seetharaman
2009-07-31  6:06   ` Hannes Reinecke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1246583474.30568.2.camel@chandra-ubuntu \
    --to=sekharan@us.ibm.com \
    --cc=christophe.varoqui@free.fr \
    --cc=dm-devel@redhat.com \
    --cc=sekharan@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.