From owner-freebsd-geom@FreeBSD.ORG Tue Jan 15 10:10:02 2013 Return-Path: Delivered-To: freebsd-geom@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4DB24C00 for ; Tue, 15 Jan 2013 10:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 40AB59A7 for ; Tue, 15 Jan 2013 10:10:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r0FAA2oO059946 for ; Tue, 15 Jan 2013 10:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r0FAA2LR059945; Tue, 15 Jan 2013 10:10:02 GMT (envelope-from gnats) Date: Tue, 15 Jan 2013 10:10:02 GMT Message-Id: <201301151010.r0FAA2LR059945@freefall.freebsd.org> To: freebsd-geom@FreeBSD.org Cc: From: dfilter@FreeBSD.ORG (dfilter service) Subject: Re: kern/160562: commit references a PR X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: dfilter service List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Jan 2013 10:10:02 -0000 The following reply was made to PR kern/160562; it has been noted by GNATS. From: dfilter@FreeBSD.ORG (dfilter service) To: bug-followup@FreeBSD.org Cc: Subject: Re: kern/160562: commit references a PR Date: Tue, 15 Jan 2013 10:06:43 +0000 (UTC) Author: mav Date: Tue Jan 15 10:06:35 2013 New Revision: 245456 URL: http://svnweb.freebsd.org/changeset/base/245456 Log: Allow to insert new component to geom_raid3 without specifying number. PR: kern/160562 MFC after: 2 weeks Modified: head/sbin/geom/class/raid3/geom_raid3.c head/sbin/geom/class/raid3/graid3.8 head/sys/geom/raid3/g_raid3_ctl.c Modified: head/sbin/geom/class/raid3/geom_raid3.c ============================================================================== --- head/sbin/geom/class/raid3/geom_raid3.c Tue Jan 15 09:56:20 2013 (r245455) +++ head/sbin/geom/class/raid3/geom_raid3.c Tue Jan 15 10:06:35 2013 (r245456) @@ -76,7 +76,7 @@ struct g_command class_commands[] = { { "insert", G_FLAG_VERBOSE, NULL, { { 'h', "hardcode", NULL, G_TYPE_BOOL }, - { 'n', "number", NULL, G_TYPE_NUMBER }, + { 'n', "number", G_VAL_OPTIONAL, G_TYPE_NUMBER }, G_OPT_SENTINEL }, "[-hv] <-n number> name prov" Modified: head/sbin/geom/class/raid3/graid3.8 ============================================================================== --- head/sbin/geom/class/raid3/graid3.8 Tue Jan 15 09:56:20 2013 (r245455) +++ head/sbin/geom/class/raid3/graid3.8 Tue Jan 15 10:06:35 2013 (r245456) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 5, 2010 +.Dd January 15, 2012 .Dt GRAID3 8 .Os .Sh NAME @@ -53,7 +53,7 @@ .Nm .Cm insert .Op Fl hv -.Fl n Ar number +.Op Fl n Ar number .Ar name .Ar prov .Nm @@ -171,6 +171,8 @@ Add the given component to the existing removed previously with the .Cm remove command or if one component is missing and will not be connected again. +If no number is given, new component will be added instead of first missed +component. .Pp Additional options include: .Bl -tag -width ".Fl h" Modified: head/sys/geom/raid3/g_raid3_ctl.c ============================================================================== --- head/sys/geom/raid3/g_raid3_ctl.c Tue Jan 15 09:56:20 2013 (r245455) +++ head/sys/geom/raid3/g_raid3_ctl.c Tue Jan 15 10:06:35 2013 (r245456) @@ -404,7 +404,7 @@ g_raid3_ctl_insert(struct gctl_req *req, u_char *sector; off_t compsize; intmax_t *no; - int *hardcode, *nargs, error; + int *hardcode, *nargs, error, autono; nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); if (nargs == NULL) { @@ -425,11 +425,10 @@ g_raid3_ctl_insert(struct gctl_req *req, gctl_error(req, "No 'arg%u' argument.", 1); return; } - no = gctl_get_paraml(req, "number", sizeof(*no)); - if (no == NULL) { - gctl_error(req, "No '%s' argument.", "no"); - return; - } + if (gctl_get_param(req, "number", NULL) != NULL) + no = gctl_get_paraml(req, "number", sizeof(*no)); + else + no = NULL; if (strncmp(name, "/dev/", 5) == 0) name += 5; g_topology_lock(); @@ -465,16 +464,30 @@ g_raid3_ctl_insert(struct gctl_req *req, gctl_error(req, "No such device: %s.", name); goto end; } - if (*no >= sc->sc_ndisks) { - sx_xunlock(&sc->sc_lock); - gctl_error(req, "Invalid component number."); - goto end; - } - disk = &sc->sc_disks[*no]; - if (disk->d_state != G_RAID3_DISK_STATE_NODISK) { - sx_xunlock(&sc->sc_lock); - gctl_error(req, "Component %jd is already connected.", *no); - goto end; + if (no != NULL) { + if (*no < 0 || *no >= sc->sc_ndisks) { + sx_xunlock(&sc->sc_lock); + gctl_error(req, "Invalid component number."); + goto end; + } + disk = &sc->sc_disks[*no]; + if (disk->d_state != G_RAID3_DISK_STATE_NODISK) { + sx_xunlock(&sc->sc_lock); + gctl_error(req, "Component %jd is already connected.", + *no); + goto end; + } + } else { + disk = NULL; + for (autono = 0; autono < sc->sc_ndisks && disk == NULL; autono++) + if (sc->sc_disks[autono].d_state == + G_RAID3_DISK_STATE_NODISK) + disk = &sc->sc_disks[autono]; + if (disk == NULL) { + sx_xunlock(&sc->sc_lock); + gctl_error(req, "No disconnected components."); + goto end; + } } if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) { sx_xunlock(&sc->sc_lock); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"