From owner-svn-src-stable@FreeBSD.ORG Fri Apr 23 16:26:11 2010 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 04258106568B; Fri, 23 Apr 2010 16:26:11 +0000 (UTC) (envelope-from mjacob@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E365E8FC13; Fri, 23 Apr 2010 16:26:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3NGQAZX051664; Fri, 23 Apr 2010 16:26:10 GMT (envelope-from mjacob@svn.freebsd.org) Received: (from mjacob@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3NGQAFo051662; Fri, 23 Apr 2010 16:26:10 GMT (envelope-from mjacob@svn.freebsd.org) Message-Id: <201004231626.o3NGQAFo051662@svn.freebsd.org> From: Matt Jacob Date: Fri, 23 Apr 2010 16:26:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r207124 - stable/8/sys/geom/multipath X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Apr 2010 16:26:11 -0000 Author: mjacob Date: Fri Apr 23 16:26:10 2010 New Revision: 207124 URL: http://svn.freebsd.org/changeset/base/207124 Log: This is an MFC of 205412. Add 'rotate' and 'getactive' verbs to provide some control and information about what the currently active path is. Modified: stable/8/sys/geom/multipath/g_multipath.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/geom/multipath/g_multipath.c ============================================================================== --- stable/8/sys/geom/multipath/g_multipath.c Fri Apr 23 16:21:40 2010 (r207123) +++ stable/8/sys/geom/multipath/g_multipath.c Fri Apr 23 16:26:10 2010 (r207124) @@ -70,6 +70,8 @@ static int g_multipath_destroy(struct g_ static int g_multipath_destroy_geom(struct gctl_req *, struct g_class *, struct g_geom *); +static int g_multipath_rotate(struct g_geom *); + static g_taste_t g_multipath_taste; static g_ctl_req_t g_multipath_config; static g_init_t g_multipath_init; @@ -417,6 +419,30 @@ g_multipath_destroy_geom(struct gctl_req return (g_multipath_destroy(gp)); } +static int +g_multipath_rotate(struct g_geom *gp) +{ + struct g_consumer *lcp; + struct g_multipath_softc *sc = gp->softc; + + g_topology_assert(); + if (sc == NULL) + return (ENXIO); + LIST_FOREACH(lcp, &gp->consumer, consumer) { + if ((lcp->index & MP_BAD) == 0) { + if (sc->cp_active != lcp) { + break; + } + } + } + if (lcp) { + sc->cp_active = lcp; + printf("GEOM_MULTIPATH: %s now active path in %s\n", + lcp->provider->name, sc->sc_name); + } + return (0); +} + static void g_multipath_init(struct g_class *mp) { @@ -749,6 +775,63 @@ g_multipath_ctl_destroy(struct gctl_req } static void +g_multipath_ctl_rotate(struct gctl_req *req, struct g_class *mp) +{ + struct g_geom *gp; + const char *name; + int error; + + g_topology_assert(); + + name = gctl_get_asciiparam(req, "arg0"); + if (name == NULL) { + gctl_error(req, "No 'arg0' argument"); + return; + } + gp = g_multipath_find_geom(mp, name); + if (gp == NULL) { + gctl_error(req, "Device %s is invalid", name); + return; + } + error = g_multipath_rotate(gp); + if (error != 0) { + gctl_error(req, "failed to rotate %s (err=%d)", name, error); + } +} + +static void +g_multipath_ctl_getactive(struct gctl_req *req, struct g_class *mp) +{ + struct sbuf *sb; + struct g_geom *gp; + struct g_multipath_softc *sc; + const char *name; + + sb = sbuf_new_auto(); + + g_topology_assert(); + name = gctl_get_asciiparam(req, "arg0"); + if (name == NULL) { + gctl_error(req, "No 'arg0' argument"); + return; + } + gp = g_multipath_find_geom(mp, name); + if (gp == NULL) { + gctl_error(req, "Device %s is invalid", name); + return; + } + sc = gp->softc; + if (sc->cp_active) { + sbuf_printf(sb, "%s\n", sc->cp_active->provider->name); + } else { + sbuf_printf(sb, "none\n"); + } + sbuf_finish(sb); + gctl_set_param_err(req, "output", sbuf_data(sb), sbuf_len(sb) + 1); + sbuf_delete(sb); +} + +static void g_multipath_config(struct gctl_req *req, struct g_class *mp, const char *verb) { uint32_t *version; @@ -762,6 +845,10 @@ g_multipath_config(struct gctl_req *req, g_multipath_ctl_create(req, mp); } else if (strcmp(verb, "destroy") == 0) { g_multipath_ctl_destroy(req, mp); + } else if (strcmp(verb, "rotate") == 0) { + g_multipath_ctl_rotate(req, mp); + } else if (strcmp(verb, "getactive") == 0) { + g_multipath_ctl_getactive(req, mp); } else { gctl_error(req, "Unknown verb %s", verb); }