From patchwork Wed Dec 16 05:31:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: bmarzins@sourceware.org X-Patchwork-Id: 67875 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id nBI4ghFJ001982 for ; Fri, 18 Dec 2009 04:42:43 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 9B22861A8B4; Wed, 16 Dec 2009 00:32:28 -0500 (EST) Received: from int-mx01.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id nBG5W3ax009394 for ; Wed, 16 Dec 2009 00:32:03 -0500 Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.8]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBG5W3fr002207 for ; Wed, 16 Dec 2009 00:32:03 -0500 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by mx1.redhat.com (8.13.8/8.13.8) with SMTP id nBG5VpY8026866 for ; Wed, 16 Dec 2009 00:31:51 -0500 Received: (qmail 31528 invoked by uid 9475); 16 Dec 2009 05:31:51 -0000 Date: 16 Dec 2009 05:31:51 -0000 Message-ID: <20091216053151.31526.qmail@sourceware.org> From: bmarzins@sourceware.org To: dm-cvs@sourceware.org, dm-devel@redhat.com X-RedHat-Spam-Score: -2 (AWL) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.8 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] multipath-tools/libmultipath pgpolicies.c X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: 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 --- multipath-tools/libmultipath/pgpolicies.c 2009/04/03 15:09:02 1.7.2.1 +++ multipath-tools/libmultipath/pgpolicies.c 2009/12/16 05:31:50 1.7.2.2 @@ -206,7 +206,8 @@ extern int one_path_per_group (struct multipath * mp) { - int i; + int i, j; + unsigned int prio; struct path * pp; struct pathgroup * pgp; @@ -218,16 +219,30 @@ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) { pp = VECTOR_SLOT(mp->paths, i); + prio = pp->priority; + + vector_foreach_slot(mp->pg, pgp, j) { + pp = VECTOR_SLOT(pgp->paths, 0); + + if (prio > pp->priority) + break; + } + pgp = alloc_pathgroup(); if (!pgp) goto out; - if (store_pathgroup(mp->pg, pgp)) - goto out; - - if (store_path(pgp->paths, pp)) + if (store_path(pgp->paths, VECTOR_SLOT(mp->paths, i))) goto out; + + if (j < VECTOR_SIZE(mp->pg)) { + if (!vector_insert_slot(mp->pg, j, pgp)) + goto out; + } else { + if (store_pathgroup(mp->pg, pgp)) + goto out; + } } free_pathvec(mp->paths, KEEP_PATHS); mp->paths = NULL;