From patchwork Fri Jul 3 01:11:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandra Seetharaman X-Patchwork-Id: 33842 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n63194HY011018 for ; Fri, 3 Jul 2009 01:09:05 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id DBEC2619E58; Thu, 2 Jul 2009 21:09:03 -0400 (EDT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n63191eO003414 for ; Thu, 2 Jul 2009 21:09:01 -0400 Received: from mx1.redhat.com (mx1.redhat.com [172.16.48.31]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n63190H5022784 for ; Thu, 2 Jul 2009 21:09:00 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n6318gxT014874 for ; Thu, 2 Jul 2009 21:08:42 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e38.co.us.ibm.com (8.13.1/8.13.1) with ESMTP id n6315VOF031470 for ; Thu, 2 Jul 2009 19:05:31 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n6318fQ1226404 for ; Thu, 2 Jul 2009 19:08:41 -0600 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n6318fgB009538 for ; Thu, 2 Jul 2009 19:08:41 -0600 Received: from [9.47.17.98] (chandra-ubuntu.beaverton.ibm.com [9.47.17.98]) by d03av02.boulder.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n6318ehh009507; Thu, 2 Jul 2009 19:08:41 -0600 From: Chandra Seetharaman To: Christophe Varoqui Organization: IBM Date: Thu, 02 Jul 2009 18:11:14 -0700 Message-Id: <1246583474.30568.2.camel@chandra-ubuntu> Mime-Version: 1.0 X-RedHat-Spam-Score: -3.541 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.31 X-loop: dm-devel@redhat.com Cc: dm-devel Subject: [dm-devel] [PATCH] Use Average path priority value for path switching X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: sekharan@linux.vnet.ibm.com, device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com 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 --- libmultipath/structs.h | 1 + libmultipath/switchgroup.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel 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;