From owner-svn-src-projects@FreeBSD.ORG Tue Oct 4 16:47:18 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B792E106566B; Tue, 4 Oct 2011 16:47:18 +0000 (UTC) (envelope-from lev@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9C8BD8FC0A; Tue, 4 Oct 2011 16:47:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p94GlIOx066150; Tue, 4 Oct 2011 16:47:18 GMT (envelope-from lev@svn.freebsd.org) Received: (from lev@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p94GlIo3066146; Tue, 4 Oct 2011 16:47:18 GMT (envelope-from lev@svn.freebsd.org) Message-Id: <201110041647.p94GlIo3066146@svn.freebsd.org> From: "Lev A. Serebryakov" Date: Tue, 4 Oct 2011 16:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225984 - in projects/geom-events: sbin/geom/class/raid3 sys/geom/raid3 X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Oct 2011 16:47:18 -0000 Author: lev (ports committer) Date: Tue Oct 4 16:47:18 2011 New Revision: 225984 URL: http://svn.freebsd.org/changeset/base/225984 Log: Locally fix kern/160562: Allow to insert new component to geom_raid3 without specifying number. Now "geom_raid3" requires "-n " argument for "insert" command, which insert new component instead of removed (or failed) one. It is not convient in most cases (one lost component). This patch allows not to specify component number. In such case new component is added instead of first missed component. Modified: projects/geom-events/sbin/geom/class/raid3/geom_raid3.c projects/geom-events/sbin/geom/class/raid3/graid3.8 projects/geom-events/sys/geom/raid3/g_raid3_ctl.c Modified: projects/geom-events/sbin/geom/class/raid3/geom_raid3.c ============================================================================== --- projects/geom-events/sbin/geom/class/raid3/geom_raid3.c Tue Oct 4 15:06:11 2011 (r225983) +++ projects/geom-events/sbin/geom/class/raid3/geom_raid3.c Tue Oct 4 16:47:18 2011 (r225984) @@ -76,10 +76,10 @@ 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" + "[-hv] [-n number] name prov" }, { "label", G_FLAG_VERBOSE, raid3_main, { Modified: projects/geom-events/sbin/geom/class/raid3/graid3.8 ============================================================================== --- projects/geom-events/sbin/geom/class/raid3/graid3.8 Tue Oct 4 15:06:11 2011 (r225983) +++ projects/geom-events/sbin/geom/class/raid3/graid3.8 Tue Oct 4 16:47:18 2011 (r225984) @@ -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, the new component will be added instead of the first +missed component. .Pp Additional options include: .Bl -tag -width ".Fl h" Modified: projects/geom-events/sys/geom/raid3/g_raid3_ctl.c ============================================================================== --- projects/geom-events/sys/geom/raid3/g_raid3_ctl.c Tue Oct 4 15:06:11 2011 (r225983) +++ projects/geom-events/sys/geom/raid3/g_raid3_ctl.c Tue Oct 4 16:47:18 2011 (r225984) @@ -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,28 @@ 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 >= 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 unconnected components."); + goto end; + } } if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) { sx_xunlock(&sc->sc_lock);