From patchwork Tue Dec 7 06:02:24 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: 381732 X-Patchwork-Delegate: christophe.varoqui@free.fr Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB764ts2004018 for ; Tue, 7 Dec 2010 06:05:17 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB762f8a020961; Tue, 7 Dec 2010 01:02:42 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB762efx025893 for ; Tue, 7 Dec 2010 01:02:40 -0500 Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB762YxA017448 for ; Tue, 7 Dec 2010 01:02:35 -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 oB762Pf9009479 for ; Tue, 7 Dec 2010 01:02:25 -0500 Received: (qmail 20391 invoked by uid 9475); 7 Dec 2010 06:02:24 -0000 Date: 7 Dec 2010 06:02:24 -0000 Message-ID: <20101207060224.20389.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.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.11 X-loop: dm-devel@redhat.com Subject: [dm-devel] multipath-tools/multipathd main.c 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]); Tue, 07 Dec 2010 06:05:17 +0000 (UTC) --- multipath-tools/multipathd/main.c 2010/09/08 21:40:30 1.69.2.30 +++ multipath-tools/multipathd/main.c 2010/12/07 06:02:23 1.69.2.31 @@ -937,14 +937,41 @@ return 0; } -int update_path_groups(struct multipath *mpp, struct vectors *vecs) +int update_prio(struct path *pp, int refresh_all) +{ + int oldpriority; + struct pathgroup * pgp; + int i, j, changed = 0; + + if (refresh_all) { + vector_foreach_slot (pp->mpp->pg, pgp, i) { + vector_foreach_slot (pgp->paths, pp, j) { + oldpriority = pp->priority; + pathinfo(pp, conf->hwtable, DI_PRIO); + if (pp->priority != oldpriority) + changed = 1; + } + } + return changed; + } + oldpriority = pp->priority; + pathinfo(pp, conf->hwtable, DI_PRIO); + + if (pp->priority == oldpriority) + return 0; + return 1; +} + +int update_path_groups(struct multipath *mpp, struct vectors *vecs, int refresh) { int i; struct path * pp; update_mpp_paths(mpp, vecs->pathvec); - vector_foreach_slot (mpp->paths, pp, i) - pathinfo(pp, conf->hwtable, DI_PRIO); + if (refresh) { + vector_foreach_slot (mpp->paths, pp, i) + pathinfo(pp, conf->hwtable, DI_PRIO); + } setup_map(mpp); mpp->action = ACT_RELOAD; if (domap(mpp) <= 0) { @@ -969,7 +996,6 @@ int newstate; unsigned int i; sigset_t old; - int oldpriority; mlockall(MCL_CURRENT | MCL_FUTURE); vecs = (struct vectors *)ap; @@ -989,6 +1015,7 @@ condlog(4, "tick"); vector_foreach_slot (vecs->pathvec, pp, i) { + int new_path_up = 0; if (!pp->mpp) continue; @@ -1081,16 +1108,7 @@ reinstate_path(pp, 1); else reinstate_path(pp, 0); - - /* - * schedule [defered] failback - */ - if (pp->mpp->pgfailback > 0) - pp->mpp->failback_tick = - pp->mpp->pgfailback + 1; - else if (pp->mpp->pgfailback == -FAILBACK_IMMEDIATE && - need_switch_pathgroup(pp->mpp, 1)) - switch_pathgroup(pp->mpp); + new_path_up = 1; /* * if at least one path is up in a group, and @@ -1127,15 +1145,13 @@ * path prio refreshing */ condlog(4, "path prio refresh"); - oldpriority = pp->priority; - pathinfo(pp, conf->hwtable, DI_PRIO); - - if (pp->priority != oldpriority && + if (update_prio(pp, new_path_up) && pp->mpp->pgpolicyfn == (pgpolicyfn *)group_by_prio) - update_path_groups(pp->mpp, vecs); + update_path_groups(pp->mpp, vecs, !new_path_up); else if (need_switch_pathgroup(pp->mpp, 0)) { if (pp->mpp->pgfailback > 0 && - pp->mpp->failback_tick <= 0) + (new_path_up || + pp->mpp->failback_tick <= 0)) pp->mpp->failback_tick = pp->mpp->pgfailback + 1; else if (pp->mpp->pgfailback ==