From patchwork Fri Sep 3 20:59:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bmarzins@sourceware.org X-Patchwork-Id: 154931 Received: from mx01.colomx.prod.int.phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o83L1mep028720 for ; Fri, 3 Sep 2010 21:02:23 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx01.colomx.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o83KxWm5009693; Fri, 3 Sep 2010 16:59:33 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o83KxUSh027781 for ; Fri, 3 Sep 2010 16:59:30 -0400 Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.12]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o83KxPBr022666 for ; Fri, 3 Sep 2010 16:59:25 -0400 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by mx1.redhat.com (8.13.8/8.13.8) with SMTP id o83KxFoZ022247 for ; Fri, 3 Sep 2010 16:59:15 -0400 Received: (qmail 4041 invoked by uid 9475); 3 Sep 2010 20:59:15 -0000 Date: 3 Sep 2010 20:59:15 -0000 Message-ID: <20100903205915.4039.qmail@sourceware.org> From: bmarzins@sourceware.org To: dm-cvs@sourceware.org, dm-devel@redhat.com X-RedHat-Spam-Score: -2.31 (RCVD_IN_DNSWL_MED,T_RP_MATCHES_RCVD) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.12 X-loop: dm-devel@redhat.com Subject: [dm-devel] multipath-tools/libmultipath config.h dict.c s ... X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 03 Sep 2010 21:02:23 +0000 (UTC) --- multipath-tools/libmultipath/config.h 2010/04/24 05:28:06 1.18.2.11 +++ multipath-tools/libmultipath/config.h 2010/09/03 20:59:14 1.18.2.12 @@ -79,6 +79,7 @@ int queue_without_daemon; int checker_timeout; int allow_queueing; + int pg_prio_calc; uid_t uid; gid_t gid; mode_t mode; --- multipath-tools/libmultipath/dict.c 2010/08/27 21:02:07 1.17.2.13 +++ multipath-tools/libmultipath/dict.c 2010/09/03 20:59:14 1.17.2.14 @@ -416,6 +416,27 @@ } static int +def_pg_prio_calc_handler(vector strvec) +{ + char * buff; + + buff = set_value(strvec); + + if (!buff) + return 1; + + if (strlen(buff) == 3 && !strcmp(buff, "sum")) + conf->pg_prio_calc = PG_PRIO_CALC_SUM; + else if ((strlen(buff) == 3 && !strcmp(buff, "avg")) || + (strlen(buff) == 7 && !strcmp(buff, "average"))) + conf->pg_prio_calc = PG_PRIO_CALC_AVG; + + FREE(buff); + return 0; +} + + +static int bindings_file_handler(vector strvec) { conf->bindings_file = set_value(strvec); @@ -1975,6 +1996,14 @@ } static int +snprint_def_pg_prio_calc (char * buff, int len, void *data) +{ + if (conf->pg_prio_calc == PG_PRIO_CALC_AVG) + return snprintf(buff, len, "avg"); + return snprintf(buff, len, "sum"); +} + +static int snprint_def_bindings_file (char * buff, int len, void * data) { if (conf->bindings_file == NULL) @@ -2036,6 +2065,7 @@ install_keyword("checker_timeout", &def_checker_timeout_handler, &snprint_def_checker_timeout); install_keyword("pg_timeout", &def_pg_timeout_handler, &snprint_def_pg_timeout); install_keyword("user_friendly_names", &names_handler, &snprint_def_user_friendly_names); + install_keyword("pg_prio_calc", &def_pg_prio_calc_handler, &snprint_def_pg_prio_calc); install_keyword("bindings_file", &bindings_file_handler, &snprint_def_bindings_file); install_keyword("mode", &def_mode_handler, &snprint_def_mode); install_keyword("uid", &def_uid_handler, &snprint_def_uid); --- multipath-tools/libmultipath/structs.h 2008/09/08 22:01:20 1.18.2.6 +++ multipath-tools/libmultipath/structs.h 2010/09/03 20:59:14 1.18.2.7 @@ -84,6 +84,11 @@ QUE_NO_DAEMON_ON, }; +enum pg_prio_calc_states { + PG_PRIO_CALC_SUM, + PG_PRIO_CALC_AVG, +}; + struct scsi_idlun { int dev_id; int host_unique_id; --- multipath-tools/libmultipath/switchgroup.c 2007/06/01 00:26:41 1.5.2.2 +++ multipath-tools/libmultipath/switchgroup.c 2010/09/03 20:59:14 1.5.2.3 @@ -7,16 +7,18 @@ #include "vector.h" #include "structs.h" #include "switchgroup.h" +#include "config.h" extern int select_path_group (struct multipath * mpp) { int i, j; int highest = 0; + int most_paths = 0; int bestpg = 1; struct pathgroup * pgp; struct path * pp; - int priority; + int priority, enabled_paths; if (!mpp->pg) return 1; @@ -26,15 +28,28 @@ continue; priority = 0; + enabled_paths = 0; vector_foreach_slot (pgp->paths, pp, j) { - if (pp->state != PATH_DOWN) + if (pp->state != PATH_DOWN) { priority += pp->priority; + enabled_paths++; + } } - pgp->priority = priority; + if (conf->pg_prio_calc == PG_PRIO_CALC_AVG) + pgp->priority = priority / enabled_paths; + else + pgp->priority = priority; if (pgp->priority > highest) { highest = pgp->priority; + most_paths = enabled_paths; + bestpg = i + 1; + } + else if (pgp->priority == highest && + conf->pg_prio_calc == PG_PRIO_CALC_AVG && + enabled_paths > most_paths) { + most_paths = enabled_paths; bestpg = i + 1; } }