From owner-svn-src-head@FreeBSD.ORG Fri May 18 09:22:21 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C36481065673; Fri, 18 May 2012 09:22:21 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AFE068FC0A; Fri, 18 May 2012 09:22:21 +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 q4I9MLk7043110; Fri, 18 May 2012 09:22:21 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4I9MLqO043108; Fri, 18 May 2012 09:22:21 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201205180922.q4I9MLqO043108@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 18 May 2012 09:22:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235600 - head/sys/geom/mirror X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 May 2012 09:22:21 -0000 Author: ae Date: Fri May 18 09:22:21 2012 New Revision: 235600 URL: http://svn.freebsd.org/changeset/base/235600 Log: Prevent removing of the last active component from a mirror. PR: kern/154860 Reviewed by: pjd MFC after: 1 week Modified: head/sys/geom/mirror/g_mirror_ctl.c Modified: head/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- head/sys/geom/mirror/g_mirror_ctl.c Fri May 18 09:19:07 2012 (r235599) +++ head/sys/geom/mirror/g_mirror_ctl.c Fri May 18 09:22:21 2012 (r235600) @@ -560,7 +560,7 @@ g_mirror_ctl_remove(struct gctl_req *req const char *name; char param[16]; int *nargs; - u_int i; + u_int i, active; nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); if (nargs == NULL) { @@ -587,6 +587,7 @@ g_mirror_ctl_remove(struct gctl_req *req "first."); return; } + active = g_mirror_ndisks(sc, G_MIRROR_DISK_STATE_ACTIVE); for (i = 1; i < (u_int)*nargs; i++) { snprintf(param, sizeof(param), "arg%u", i); name = gctl_get_asciiparam(req, param); @@ -599,6 +600,16 @@ g_mirror_ctl_remove(struct gctl_req *req gctl_error(req, "No such provider: %s.", name); continue; } + if (disk->d_state == G_MIRROR_DISK_STATE_ACTIVE) { + if (active > 1) + active--; + else { + gctl_error(req, "%s: Can't remove the last " + "ACTIVE component %s.", sc->sc_geom->name, + name); + continue; + } + } g_mirror_event_send(disk, G_MIRROR_DISK_STATE_DESTROY, G_MIRROR_EVENT_DONTWAIT); }