summaryrefslogtreecommitdiffstats
path: root/sys/geom
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2012-05-18 09:22:21 +0000
committerae <ae@FreeBSD.org>2012-05-18 09:22:21 +0000
commitc16abb371bff05e19a93487842c3254fe6cc3078 (patch)
treec6cb5c202a4c5c407d1e4c8b60a3e5751eb2ef16 /sys/geom
parenta243137af2073d22d4fc581771aeb8a5330031fc (diff)
downloadFreeBSD-src-c16abb371bff05e19a93487842c3254fe6cc3078.zip
FreeBSD-src-c16abb371bff05e19a93487842c3254fe6cc3078.tar.gz
Prevent removing of the last active component from a mirror.
PR: kern/154860 Reviewed by: pjd MFC after: 1 week
Diffstat (limited to 'sys/geom')
-rw-r--r--sys/geom/mirror/g_mirror_ctl.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/geom/mirror/g_mirror_ctl.c b/sys/geom/mirror/g_mirror_ctl.c
index dc59e18..c024bd9 100644
--- a/sys/geom/mirror/g_mirror_ctl.c
+++ b/sys/geom/mirror/g_mirror_ctl.c
@@ -560,7 +560,7 @@ g_mirror_ctl_remove(struct gctl_req *req, struct g_class *mp)
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, struct g_class *mp)
"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, struct g_class *mp)
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);
}
OpenPOWER on IntegriCloud