From patchwork Thu Jul 30 20:13:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandra Seetharaman X-Patchwork-Id: 38381 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 n6UKAuQS019006 for ; Thu, 30 Jul 2009 20:10:56 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 62413618DB6; Thu, 30 Jul 2009 16:10:55 -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 n6UKAqi3018334 for ; Thu, 30 Jul 2009 16:10:53 -0400 Received: from mx3.redhat.com (mx3.redhat.com [172.16.48.32]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6UKAqld013959 for ; Thu, 30 Jul 2009 16:10:52 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx3.redhat.com (8.13.8/8.13.8) with ESMTP id n6UKAWsv002286 for ; Thu, 30 Jul 2009 16:10:32 -0400 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by e35.co.us.ibm.com (8.14.3/8.13.1) with ESMTP id n6UK22CY030394 for ; Thu, 30 Jul 2009 14:02:02 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n6UKAK5f212984 for ; Thu, 30 Jul 2009 14:10:28 -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 n6UKAI1l024287 for ; Thu, 30 Jul 2009 14:10:18 -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 n6UKAHxv024121; Thu, 30 Jul 2009 14:10:18 -0600 From: Chandra Seetharaman To: Christophe Varoqui , Hannes Reinecke In-Reply-To: <1246583474.30568.2.camel@chandra-ubuntu> References: <1246583474.30568.2.camel@chandra-ubuntu> Organization: IBM Date: Thu, 30 Jul 2009 13:13:55 -0700 Message-Id: <1248984835.18243.5.camel@chandra-ubuntu> Mime-Version: 1.0 X-RedHat-Spam-Score: -3.772 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 X-Scanned-By: MIMEDefang 2.63 on 172.16.48.32 X-loop: dm-devel@redhat.com Cc: device-mapper development Subject: [dm-devel] [RESEND] [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 Hi Christophe, I submitted this patch on Jul 2 (http://marc.info/?l=dm-devel&m=124658334721911&w=2). Resending it. Only change is a field name from up_paths to enabled_paths. Hi Hannes, Need an ACK from you :-). 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 the path group to decide on which path group to switch over. Signed-off-by: Chandra Seetharaman Acked-by: Hannes Reinecke --- 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 enabled_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->enabled_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->enabled_paths++; + } } pgp->priority = priority; } @@ -29,8 +32,9 @@ extern int select_path_group (struct multipath * mpp) { int i; - int highest = 0; + int max_priority = 0, avg_priority; int bestpg = 1; + int max_enabled_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->enabled_paths) { + avg_priority = pgp->priority / pgp->enabled_paths; + if (avg_priority > max_priority) { + max_priority = avg_priority; + max_enabled_paths = pgp->enabled_paths; + bestpg = i + 1; + } else if (avg_priority == max_priority) { + if (pgp->enabled_paths > max_enabled_paths) { + max_enabled_paths = pgp->enabled_paths; + bestpg = i + 1; + } + } } } return bestpg;