From owner-freebsd-geom@FreeBSD.ORG Sun Sep 6 00:36:16 2009 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0DEDD1065696; Sun, 6 Sep 2009 00:36:16 +0000 (UTC) (envelope-from mel.flynn+fbsd.fs@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id A8A5C8FC1B; Sun, 6 Sep 2009 00:36:15 +0000 (UTC) Received: from smoochies.rachie.is-a-geek.net (mailhub.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id 677297E853; Sat, 5 Sep 2009 16:36:25 -0800 (AKDT) From: Mel Flynn To: freebsd-fs@freebsd.org Date: Sun, 6 Sep 2009 02:36:10 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-BETA3; KDE/4.2.4; i386; ; ) References: <200909030000.11961.mel.flynn+fbsd.fs@mailing.thruhere.net> <200909052111.27667.mel.flynn+fbsd.fs@mailing.thruhere.net> <20090905192251.GJ1665@garage.freebsd.pl> In-Reply-To: <20090905192251.GJ1665@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_7PwoKCEku+NtiA2" Message-Id: <200909060236.11224.mel.flynn+fbsd.fs@mailing.thruhere.net> Cc: Pawel Jakub Dawidek , freebsd-geom@freebsd.org Subject: Re: Patch to allow gmirror to set priority of a disk X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2009 00:36:16 -0000 --Boundary-00=_7PwoKCEku+NtiA2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, new patch containing everything and points for elegance. Double checked for style, so I'm sure there's one or two left ;). Since it's applies nearly clean (1 hunk -6 lines offset) on 7-STABLE, I can runtime test it tomorrow (tonight is lvl 0 backup). -- Mel --Boundary-00=_7PwoKCEku+NtiA2 Content-Type: text/plain; charset="UTF-8"; name="gmirror-priority.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="gmirror-priority.txt" Index: sys/geom/mirror/g_mirror_ctl.c =================================================================== --- sys/geom/mirror/g_mirror_ctl.c (revision 196868) +++ sys/geom/mirror/g_mirror_ctl.c (working copy) @@ -93,12 +93,12 @@ { struct g_mirror_softc *sc; struct g_mirror_disk *disk; - const char *name, *balancep; + const char *name, *balancep, *prov; intmax_t *slicep; uint32_t slice; uint8_t balance; int *autosync, *noautosync, *failsync, *nofailsync, *hardcode, *dynamic; - int *nargs, do_sync = 0, dirty = 1; + int *nargs, *priority, do_sync = 0, dirty = 1, do_priority = 0; nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); if (nargs == NULL) { @@ -149,6 +149,29 @@ gctl_error(req, "No '%s' argument.", "dynamic"); return; } + priority = gctl_get_paraml(req, "priority", sizeof(*priority)); + if (priority == NULL) { + gctl_error(req, "No '%s' argument.", "priority"); + return; + } + if (*priority < -1 || *priority > 255) { + gctl_error(req, "Priority range is 0 to 255, %i given", + *priority); + return; + } + /* + * Since we have a priority, we also need a provider now. + * Note: be WARNS safe, by always assigning prov and only throw an + * error if *priority != -1. + */ + prov = gctl_get_asciiparam(req, "arg1"); + if (*priority > -1) { + if (prov == NULL) { + gctl_error(req, "Priority needs a disk name"); + return; + } + do_priority = 1; + } if (*autosync && *noautosync) { gctl_error(req, "'%s' and '%s' specified.", "autosync", "noautosync"); @@ -189,6 +212,14 @@ slice = sc->sc_slice; else slice = *slicep; + /* Enforce usage() of -p not allowing any other options */ + if (do_priority && (*autosync || *noautosync || *failsync || + *nofailsync || *hardcode || *dynamic || *slicep != -1 || + (strcmp(balancep, "none")))) { + gctl_error(req, "only -p accepted when setting priority"); + sx_xunlock(&sc->sc_lock); + return; + } if (g_mirror_ndisks(sc, -1) < sc->sc_ndisks) { sx_xunlock(&sc->sc_lock); gctl_error(req, "Not all disks connected. Try 'forget' command " @@ -197,7 +228,7 @@ } if (sc->sc_balance == balance && sc->sc_slice == slice && !*autosync && !*noautosync && !*failsync && !*nofailsync && !*hardcode && - !*dynamic) { + !*dynamic && !do_priority) { sx_xunlock(&sc->sc_lock); gctl_error(req, "Nothing has changed."); return; @@ -223,6 +254,19 @@ } } LIST_FOREACH(disk, &sc->sc_disks, d_next) { + /* + * Handle priority first, since we only need one disk, do one + * operation on it and then we're done. No need to check other + * flags, as usage doesn't allow it. + */ + if (do_priority) { + if (strcmp(disk->d_name, prov) == 0) { + disk->d_priority = *priority; + g_mirror_update_metadata(disk); + break; + } + continue; + } if (do_sync) { if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) disk->d_flags &= ~G_MIRROR_DISK_FLAG_FORCE_SYNC; Index: sbin/geom/core/geom.c =================================================================== --- sbin/geom/core/geom.c (revision 196868) +++ sbin/geom/core/geom.c (working copy) @@ -98,11 +98,25 @@ struct g_option *opt; unsigned i; - fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); if (cmd->gc_usage != NULL) { - fprintf(stderr, " %s\n", cmd->gc_usage); + char *pos, *ptr, *sptr; + + ptr = strdup(cmd->gc_usage); + sptr = ptr; + while ((pos = strchr(ptr, '\n')) != NULL) { + *pos = '\0'; + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); + fprintf(stderr, "%s\n", ptr); + ptr = pos + 1; + } + /* Tail or no \n at all */ + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); + fprintf(stderr, " %s\n", ptr); + free(sptr); return; } + + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); if ((cmd->gc_flags & G_FLAG_VERBOSE) != 0) fprintf(stderr, " [-v]"); for (i = 0; ; i++) { Index: sbin/geom/class/mirror/geom_mirror.c =================================================================== --- sbin/geom/class/mirror/geom_mirror.c (revision 196868) +++ sbin/geom/class/mirror/geom_mirror.c (working copy) @@ -47,7 +47,7 @@ static char label_balance[] = "split", configure_balance[] = "none"; static intmax_t label_slice = 4096, configure_slice = -1; -static intmax_t insert_priority = 0; +static intmax_t insert_priority = 0, configure_priority = -1; static void mirror_main(struct gctl_req *req, unsigned flags); static void mirror_activate(struct gctl_req *req); @@ -71,10 +71,12 @@ { 'F', "nofailsync", NULL, G_TYPE_BOOL }, { 'h', "hardcode", NULL, G_TYPE_BOOL }, { 'n', "noautosync", NULL, G_TYPE_BOOL }, + { 'p', "priority", &configure_priority, G_TYPE_NUMBER }, { 's', "slice", &configure_slice, G_TYPE_NUMBER }, G_OPT_SENTINEL }, - NULL, "[-adfFhnv] [-b balance] [-s slice] name" + NULL, "[-adfFhnv] [-b balance] [-s slice] name\n" + "-p priority name prov" }, { "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL, "[-v] name prov ..." Index: sbin/geom/class/mirror/gmirror.8 =================================================================== --- sbin/geom/class/mirror/gmirror.8 (revision 196868) +++ sbin/geom/class/mirror/gmirror.8 (working copy) @@ -49,6 +49,12 @@ .Op Fl s Ar slice .Ar name .Nm +.Cm configure +.Op Fl v +.Fl p Ar priority +.Ar name +.Ar prov +.Nm .Cm rebuild .Op Fl v .Ar name @@ -115,8 +121,8 @@ .It Cm label Create a mirror. The order of components is important, because a component's priority is based on its position -(starting from 0). -The component with the biggest priority is used by the +(starting from 0 to 255). +The component with the biggest priority (the lowest number) is used by the .Cm prefer balance algorithm and is also used as a master component when resynchronization is needed, @@ -175,6 +181,9 @@ Hardcode providers' names in metadata. .It Fl n Turn off autosynchronization of stale components. +.It Fl p Ar priority +Specifies priority for the given component +.Ar prov . .It Fl s Ar slice Specifies slice size for .Cm split --Boundary-00=_7PwoKCEku+NtiA2-- From owner-freebsd-geom@FreeBSD.ORG Sun Sep 6 00:56:07 2009 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 52AAF106566B; Sun, 6 Sep 2009 00:56:07 +0000 (UTC) (envelope-from mel.flynn+fbsd.fs@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 2131D8FC13; Sun, 6 Sep 2009 00:56:06 +0000 (UTC) Received: from smoochies.rachie.is-a-geek.net (mailhub.lan.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id 101D37E853; Sat, 5 Sep 2009 16:56:18 -0800 (AKDT) From: Mel Flynn To: freebsd-fs@freebsd.org Date: Sun, 6 Sep 2009 02:56:03 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-BETA3; KDE/4.2.4; i386; ; ) References: <200909030000.11961.mel.flynn+fbsd.fs@mailing.thruhere.net> <20090905192251.GJ1665@garage.freebsd.pl> <200909060236.11224.mel.flynn+fbsd.fs@mailing.thruhere.net> In-Reply-To: <200909060236.11224.mel.flynn+fbsd.fs@mailing.thruhere.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200909060256.04013.mel.flynn+fbsd.fs@mailing.thruhere.net> Cc: Pawel Jakub Dawidek , freebsd-geom@freebsd.org Subject: Re: Patch to allow gmirror to set priority of a disk X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2009 00:56:07 -0000 On Sunday 06 September 2009 02:36:10 Mel Flynn wrote: > Hi, > > new patch containing everything and points for elegance. Double checked for > style, so I'm sure there's one or two left ;). > > Since it's applies nearly clean (1 hunk -6 lines offset) on 7-STABLE, I can > runtime test it tomorrow (tonight is lvl 0 backup). Ack, totally missed your strsep comments, strike this one and yes I should've used that. Will redo when it's not 3am in the morning anymore. ;) -- Mel From owner-freebsd-geom@FreeBSD.ORG Sun Sep 6 06:52:24 2009 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EEE031065700; Sun, 6 Sep 2009 06:52:24 +0000 (UTC) (envelope-from pjd@garage.freebsd.pl) Received: from mail.garage.freebsd.pl (chello087206049004.chello.pl [87.206.49.4]) by mx1.freebsd.org (Postfix) with ESMTP id 178718FC08; Sun, 6 Sep 2009 06:52:23 +0000 (UTC) Received: by mail.garage.freebsd.pl (Postfix, from userid 65534) id 5BA3E45CD9; Sun, 6 Sep 2009 08:52:18 +0200 (CEST) Received: from localhost (chello087206049004.chello.pl [87.206.49.4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.garage.freebsd.pl (Postfix) with ESMTP id 4267E45C9B; Sun, 6 Sep 2009 08:52:12 +0200 (CEST) Date: Sun, 6 Sep 2009 08:52:17 +0200 From: Pawel Jakub Dawidek To: Mel Flynn Message-ID: <20090906065217.GL1665@garage.freebsd.pl> References: <200909030000.11961.mel.flynn+fbsd.fs@mailing.thruhere.net> <200909052111.27667.mel.flynn+fbsd.fs@mailing.thruhere.net> <20090905192251.GJ1665@garage.freebsd.pl> <200909060236.11224.mel.flynn+fbsd.fs@mailing.thruhere.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="9ToWwKEyhugL+MAz" Content-Disposition: inline In-Reply-To: <200909060236.11224.mel.flynn+fbsd.fs@mailing.thruhere.net> User-Agent: Mutt/1.4.2.3i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 8.0-CURRENT i386 X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on mail.garage.freebsd.pl X-Spam-Level: X-Spam-Status: No, score=-0.6 required=4.5 tests=BAYES_00,RCVD_IN_SORBS_DUL autolearn=no version=3.0.4 Cc: freebsd-fs@freebsd.org, freebsd-geom@freebsd.org Subject: Re: Patch to allow gmirror to set priority of a disk X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2009 06:52:25 -0000 --9ToWwKEyhugL+MAz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Sep 06, 2009 at 02:36:10AM +0200, Mel Flynn wrote: > Hi, >=20 > new patch containing everything and points for elegance. Double checked f= or=20 > style, so I'm sure there's one or two left ;). Yeah:) I'll fixed what's left by myself and tested it. With few little changes it works fine, good job. Below, for the record, you can find what I changed. Patch committed. > Since it's applies nearly clean (1 hunk -6 lines offset) on 7-STABLE, I c= an=20 > runtime test it tomorrow (tonight is lvl 0 backup). > Index: sys/geom/mirror/g_mirror_ctl.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sys/geom/mirror/g_mirror_ctl.c (revision 196868) > +++ sys/geom/mirror/g_mirror_ctl.c (working copy) > @@ -93,12 +93,12 @@ > { > struct g_mirror_softc *sc; > struct g_mirror_disk *disk; > - const char *name, *balancep; > + const char *name, *balancep, *prov; > intmax_t *slicep; > uint32_t slice; > uint8_t balance; > int *autosync, *noautosync, *failsync, *nofailsync, *hardcode, *dynamic; > - int *nargs, do_sync =3D 0, dirty =3D 1; > + int *nargs, *priority, do_sync =3D 0, dirty =3D 1, do_priority =3D 0; priority should be 'intmax_t *' here. > nargs =3D gctl_get_paraml(req, "nargs", sizeof(*nargs)); > if (nargs =3D=3D NULL) { We need to accept 1 or 2 arguments few lines below. > @@ -149,6 +149,29 @@ > gctl_error(req, "No '%s' argument.", "dynamic"); > return; > } > + priority =3D gctl_get_paraml(req, "priority", sizeof(*priority)); > + if (priority =3D=3D NULL) { > + gctl_error(req, "No '%s' argument.", "priority"); > + return; > + } > + if (*priority < -1 || *priority > 255) { > + gctl_error(req, "Priority range is 0 to 255, %i given", %d instead of %i for consistency. > + *priority); > + return; > + } > + /*=20 > + * Since we have a priority, we also need a provider now. > + * Note: be WARNS safe, by always assigning prov and only throw an > + * error if *priority !=3D -1. > + */ > + prov =3D gctl_get_asciiparam(req, "arg1"); > + if (*priority > -1) { > + if (prov =3D=3D NULL) { > + gctl_error(req, "Priority needs a disk name"); > + return; > + } > + do_priority =3D 1; > + } > if (*autosync && *noautosync) { > gctl_error(req, "'%s' and '%s' specified.", "autosync", > "noautosync"); > @@ -189,6 +212,14 @@ > slice =3D sc->sc_slice; > else > slice =3D *slicep; > + /* Enforce usage() of -p not allowing any other options */ Missing '.' at the end of the sentence. > + if (do_priority && (*autosync || *noautosync || *failsync || > + *nofailsync || *hardcode || *dynamic || *slicep !=3D -1 || > + (strcmp(balancep, "none")))) { One tab too much. strcmp() returns int, not bool, so we have to check it against 0. Extra () around strcmp(). > + gctl_error(req, "only -p accepted when setting priority"); > + sx_xunlock(&sc->sc_lock); There's no need to hold the lock during gctl_error(). > + return; > + } > if (g_mirror_ndisks(sc, -1) < sc->sc_ndisks) { > sx_xunlock(&sc->sc_lock); > gctl_error(req, "Not all disks connected. Try 'forget' command " > @@ -197,7 +228,7 @@ > } > if (sc->sc_balance =3D=3D balance && sc->sc_slice =3D=3D slice && !*aut= osync && > !*noautosync && !*failsync && !*nofailsync && !*hardcode && > - !*dynamic) { > + !*dynamic && !do_priority) { > sx_xunlock(&sc->sc_lock); > gctl_error(req, "Nothing has changed."); > return; I also added the following check: if ((!do_priority && *nargs !=3D 1) || (do_priority && *nargs !=3D 2)) { sx_xunlock(&sc->sc_lock); gctl_error(req, "Invalid number of arguments."); return; } > @@ -223,6 +254,19 @@ > } > } > LIST_FOREACH(disk, &sc->sc_disks, d_next) { > + /* > + * Handle priority first, since we only need one disk, do one > + * operation on it and then we're done. No need to check other > + * flags, as usage doesn't allow it. > + */ > + if (do_priority) { > + if (strcmp(disk->d_name, prov) =3D=3D 0) { > + disk->d_priority =3D *priority; > + g_mirror_update_metadata(disk); > + break; > + } To be consistent with other option I changed it to: if (strcmp(disk->d_name, prov) =3D=3D 0) { if (disk->d_priority =3D=3D *priority) gctl_error(req, "Nothing has changed."); else { disk->d_priority =3D *priority; g_mirror_update_metadata(disk); } break; } > + continue; > + } > if (do_sync) { > if (disk->d_state =3D=3D G_MIRROR_DISK_STATE_SYNCHRONIZING) > disk->d_flags &=3D ~G_MIRROR_DISK_FLAG_FORCE_SYNC; > Index: sbin/geom/core/geom.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sbin/geom/core/geom.c (revision 196868) > +++ sbin/geom/core/geom.c (working copy) > @@ -98,11 +98,25 @@ > struct g_option *opt; > unsigned i; > =20 > - fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); > if (cmd->gc_usage !=3D NULL) { > - fprintf(stderr, " %s\n", cmd->gc_usage); > + char *pos, *ptr, *sptr; > + > + ptr =3D strdup(cmd->gc_usage); > + sptr =3D ptr; > + while ((pos =3D strchr(ptr, '\n')) !=3D NULL) { > + *pos =3D '\0'; > + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); > + fprintf(stderr, "%s\n", ptr); We need a space between cmd->gc_name and ptr here. > + ptr =3D pos + 1; > + } > + /* Tail or no \n at all */ > + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); > + fprintf(stderr, " %s\n", ptr); > + free(sptr); I went with strsep(3) version I proposed, I think you missed it. > return; > } > + > + fprintf(stderr, "%s %s %s", prefix, comm, cmd->gc_name); > if ((cmd->gc_flags & G_FLAG_VERBOSE) !=3D 0) > fprintf(stderr, " [-v]"); > for (i =3D 0; ; i++) { > Index: sbin/geom/class/mirror/geom_mirror.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sbin/geom/class/mirror/geom_mirror.c (revision 196868) > +++ sbin/geom/class/mirror/geom_mirror.c (working copy) > @@ -47,7 +47,7 @@ > =20 > static char label_balance[] =3D "split", configure_balance[] =3D "none"; > static intmax_t label_slice =3D 4096, configure_slice =3D -1; > -static intmax_t insert_priority =3D 0; > +static intmax_t insert_priority =3D 0, configure_priority =3D -1; > =20 > static void mirror_main(struct gctl_req *req, unsigned flags); > static void mirror_activate(struct gctl_req *req); > @@ -71,10 +71,12 @@ > { 'F', "nofailsync", NULL, G_TYPE_BOOL }, > { 'h', "hardcode", NULL, G_TYPE_BOOL }, > { 'n', "noautosync", NULL, G_TYPE_BOOL }, > + { 'p', "priority", &configure_priority, G_TYPE_NUMBER }, > { 's', "slice", &configure_slice, G_TYPE_NUMBER }, > G_OPT_SENTINEL > }, > - NULL, "[-adfFhnv] [-b balance] [-s slice] name" > + NULL, "[-adfFhnv] [-b balance] [-s slice] name\n" > + "-p priority name prov" I added '[-v]' here as it i a valid option. > }, > { "deactivate", G_FLAG_VERBOSE, NULL, G_NULL_OPTS, NULL, > "[-v] name prov ..." > Index: sbin/geom/class/mirror/gmirror.8 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sbin/geom/class/mirror/gmirror.8 (revision 196868) > +++ sbin/geom/class/mirror/gmirror.8 (working copy) > @@ -49,6 +49,12 @@ > .Op Fl s Ar slice > .Ar name > .Nm > +.Cm configure > +.Op Fl v > +.Fl p Ar priority > +.Ar name > +.Ar prov > +.Nm > .Cm rebuild > .Op Fl v > .Ar name > @@ -115,8 +121,8 @@ > .It Cm label > Create a mirror. > The order of components is important, because a component's priority is = based on its position > -(starting from 0). > -The component with the biggest priority is used by the > +(starting from 0 to 255). > +The component with the biggest priority (the lowest number) is used by t= he > .Cm prefer > balance algorithm > and is also used as a master component when resynchronization is needed, > @@ -175,6 +181,9 @@ We also need: -.Bl -tag -width ".Fl b Ar balance" +.Bl -tag -width ".Fl p Ar priority" > Hardcode providers' names in metadata. > .It Fl n > Turn off autosynchronization of stale components. > +.It Fl p Ar priority > +Specifies priority for the given component > +.Ar prov . > .It Fl s Ar slice > Specifies slice size for > .Cm split --=20 Pawel Jakub Dawidek http://www.wheel.pl pjd@FreeBSD.org http://www.FreeBSD.org FreeBSD committer Am I Evil? Yes, I Am! --9ToWwKEyhugL+MAz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQFKo1whForvXbEpPzQRAtt7AJ0RB3pQw7DilUiqBOqgM3LQuEgdNgCgxueH 1QW+WmTfmOoc44Fmz7DiHUo= =/9zD -----END PGP SIGNATURE----- --9ToWwKEyhugL+MAz-- From owner-freebsd-geom@FreeBSD.ORG Sun Sep 6 08:17:10 2009 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3C091065676; Sun, 6 Sep 2009 08:17:10 +0000 (UTC) (envelope-from mel.flynn+fbsd.fs@mailing.thruhere.net) Received: from mailhub.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 7D6868FC14; Sun, 6 Sep 2009 08:17:10 +0000 (UTC) Received: from smoochies.rachie.is-a-geek.net (mailhub.lan.rachie.is-a-geek.net [192.168.2.11]) by mailhub.rachie.is-a-geek.net (Postfix) with ESMTP id A36907E818; Sun, 6 Sep 2009 00:17:20 -0800 (AKDT) From: Mel Flynn To: Pawel Jakub Dawidek Date: Sun, 6 Sep 2009 10:17:05 +0200 User-Agent: KMail/1.11.4 (FreeBSD/8.0-BETA3; KDE/4.2.4; i386; ; ) References: <200909030000.11961.mel.flynn+fbsd.fs@mailing.thruhere.net> <200909060236.11224.mel.flynn+fbsd.fs@mailing.thruhere.net> <20090906065217.GL1665@garage.freebsd.pl> In-Reply-To: <20090906065217.GL1665@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200909061017.05990.mel.flynn+fbsd.fs@mailing.thruhere.net> Cc: freebsd-fs@freebsd.org, freebsd-geom@freebsd.org Subject: Re: Patch to allow gmirror to set priority of a disk X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Sep 2009 08:17:10 -0000 On Sunday 06 September 2009 08:52:17 you wrote: > On Sun, Sep 06, 2009 at 02:36:10AM +0200, Mel Flynn wrote: > > Hi, > > > > new patch containing everything and points for elegance. Double checked > > for style, so I'm sure there's one or two left ;). > > Yeah:) I'll fixed what's left by myself and tested it. With few little > changes it works fine, good job. Below, for the record, you can find > what I changed. Patch committed. Thank you very much! And now you got me thinking about allowing and enforcing two usage patterns of the same command in the core geom, so that the enforcement can be stripped out of command implementations. But I'll leave that for a time when this is not the only consumer of that logic. This has nonetheless been a welcome learning experience. -- Mel From owner-freebsd-geom@FreeBSD.ORG Mon Sep 7 11:07:00 2009 Return-Path: Delivered-To: freebsd-geom@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 056E0106568B for ; Mon, 7 Sep 2009 11:07:00 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E790D8FC14 for ; Mon, 7 Sep 2009 11:06:59 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n87B6xMA010233 for ; Mon, 7 Sep 2009 11:06:59 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n87B6x9o010229 for freebsd-geom@FreeBSD.org; Mon, 7 Sep 2009 11:06:59 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 7 Sep 2009 11:06:59 GMT Message-Id: <200909071106.n87B6x9o010229@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-geom@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-geom@FreeBSD.org X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2009 11:07:00 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/135898 geom [geom] Severe filesystem corruption - large files or l o kern/134922 geom [gmirror] [panic] kernel panic when use fdisk on disk o kern/134113 geom [geli] Problem setting secondary GELI key o kern/134044 geom [geom] gmirror(8) overwrites fs with stale data from r o kern/133931 geom [geli] [request] intentionally wrong password to destr o bin/132845 geom [geom] [patch] ggated(8) does not close files opened a o kern/132273 geom glabel(8): [patch] failing on journaled partition f kern/132242 geom [gmirror] gmirror.ko fails to fully initialize o kern/131353 geom [geom] gjournal(8) kernel lock p docs/130548 geom [patch] gjournal(8) man page is missing sysctls o kern/129674 geom [geom] gjournal root did not mount on boot o kern/129645 geom gjournal(8): GEOM_JOURNAL causes system to fail to boo o kern/129245 geom [geom] gcache is more suitable for suffix based provid f kern/128276 geom [gmirror] machine lock up when gmirror module is used f kern/126902 geom [geom] geom_label: kernel panic during install boot o kern/124973 geom [gjournal] [patch] boot order affects geom_journal con o kern/124969 geom gvinum(8): gvinum raid5 plex does not detect missing s f kern/124294 geom [geom] gmirror(8) have inappropriate logic when workin o kern/123962 geom [panic] [gjournal] gjournal (455Gb data, 8Gb journal), o kern/123630 geom [patch] [gmirror] gmirror doesnt allow the original dr o kern/123122 geom [geom] GEOM / gjournal kernel lock o kern/122738 geom [geom] gmirror list "losts consumers" after gmirror de f kern/122415 geom [geom] UFS labels are being constantly created and rem o kern/122067 geom [geom] [panic] Geom crashed during boot o kern/121559 geom [patch] [geom] geom label class allows to create inacc o kern/121364 geom [gmirror] Removing all providers create a "zombie" mir o kern/120091 geom [geom] [geli] [gjournal] geli does not prompt for pass o kern/120021 geom [geom] [panic] net-p2p/qbittorrent crashes system when o kern/119743 geom [geom] geom label for cds is keeped after dismount and o kern/115856 geom [geli] ZFS thought it was degraded when it should have o kern/115547 geom [geom] [patch] [request] let GEOM Eli get password fro o kern/114532 geom [geom] GEOM_MIRROR shows up in kldstat even if compile o kern/113957 geom [gmirror] gmirror is intermittently reporting a degrad o kern/113885 geom [gmirror] [patch] improved gmirror balance algorithm o kern/113837 geom [geom] unable to access 1024 sector size storage o kern/113419 geom [geom] geom fox multipathing not failing back p bin/110705 geom gmirror(8) control utility does not exit with correct o kern/107707 geom [geom] [patch] [request] add new class geom_xbox360 to o kern/104389 geom [geom] [patch] sys/geom/geom_dump.c doesn't encode XML o kern/98034 geom [geom] dereference of NULL pointer in acd_geom_detach o kern/94632 geom [geom] Kernel output resets input while GELI asks for o kern/90582 geom [geom] [panic] Restore cause panic string (ffs_blkfree o bin/90093 geom fdisk(8) incapable of altering in-core geometry a kern/89660 geom [vinum] [patch] [panic] due to g_malloc returning null o kern/89546 geom [geom] GEOM error o kern/88601 geom [geli] geli cause kernel panic under heavy disk usage o kern/87544 geom [gbde] mmaping large files on a gbde filesystem deadlo o kern/84556 geom [geom] [panic] GBDE-encrypted swap causes panic at shu o kern/79251 geom [2TB] newfs fails on 2.6TB gbde device o kern/79035 geom [vinum] gvinum unable to create a striped set of mirro o bin/78131 geom gbde(8) "destroy" not working. s kern/73177 geom kldload geom_* causes panic due to memory exhaustion 52 problems total. From owner-freebsd-geom@FreeBSD.ORG Mon Sep 7 19:32:26 2009 Return-Path: Delivered-To: freebsd-geom@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA7B81065679; Mon, 7 Sep 2009 19:32:26 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A0F358FC08; Mon, 7 Sep 2009 19:32:26 +0000 (UTC) Received: from freefall.freebsd.org (pjd@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n87JWQgC037051; Mon, 7 Sep 2009 19:32:26 GMT (envelope-from pjd@freefall.freebsd.org) Received: (from pjd@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n87JWQLK037044; Mon, 7 Sep 2009 19:32:26 GMT (envelope-from pjd) Date: Mon, 7 Sep 2009 19:32:26 GMT Message-Id: <200909071932.n87JWQLK037044@freefall.freebsd.org> To: petefrench@ticketswitch.com, pjd@FreeBSD.org, freebsd-geom@FreeBSD.org, pjd@FreeBSD.org From: pjd@FreeBSD.org Cc: Subject: Re: kern/123630: [patch] [gmirror] gmirror doesnt allow the original drive to be preferred X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Sep 2009 19:32:26 -0000 Synopsis: [patch] [gmirror] gmirror doesnt allow the original drive to be preferred State-Changed-From-To: open->closed State-Changed-By: pjd State-Changed-When: pon 7 wrz 2009 19:31:11 UTC State-Changed-Why: It is now possible to change components priority which should fix the problem you described. You can also always stop the mirror and relabel it. Responsible-Changed-From-To: freebsd-geom->pjd Responsible-Changed-By: pjd Responsible-Changed-When: pon 7 wrz 2009 19:31:11 UTC Responsible-Changed-Why: I'll take this one. http://www.freebsd.org/cgi/query-pr.cgi?pr=123630