Disable tasting through sysctl

Dag-Erling Smørgrav des at des.no
Sat Sep 21 23:48:17 UTC 2013


The patch below is a workaround for the "bouncing geom" problem that
occurs primarily with labels.  Say da0p1 and da1p1 are labeled "mir0"
and "mir1" respectively, so they exist both as /dev/da[01]p1 and as
/dev/gpt/mir[01].  Create a mirror on top of gpt/mir[01], then stop the
mirror.  GEOM won't retaste gpt/root[01], but it will see and taste
da[01]p1, and the mirror will immediately reappear.  The patch adds a
sysctl which can be used to temporarily disable tasting so you can stop
the mirror and safely disconnect the disks.

DES
-- 
Dag-Erling Smørgrav - des at des.no

Index: sys/geom/geom_int.h
===================================================================
--- sys/geom/geom_int.h	(revision 255780)
+++ sys/geom/geom_int.h	(working copy)
@@ -75,6 +75,7 @@
 /* geom_kern.c / geom_kernsim.c */
 void g_init(void);
 extern int g_shutdown;
+extern int g_notaste;
 
 /* geom_ctl.c */
 void g_ctl_init(void);
Index: sys/geom/geom_kern.c
===================================================================
--- sys/geom/geom_kern.c	(revision 255780)
+++ sys/geom/geom_kern.c	(working copy)
@@ -66,6 +66,7 @@
 int g_debugflags;
 int g_collectstats = 1;
 int g_shutdown;
+int g_notaste;
 
 /*
  * G_UP and G_DOWN are the two threads which push I/O through the
@@ -208,6 +209,9 @@
 SYSCTL_INT(_kern_geom, OID_AUTO, debugflags, CTLFLAG_RW,
 	&g_debugflags, 0, "Set various trace levels for GEOM debugging");
 
+SYSCTL_INT(_kern_geom, OID_AUTO, notaste, CTLFLAG_RW,
+	&g_notaste, 0, "Prevent GEOM tasting");
+
 SYSCTL_INT(_kern_geom, OID_AUTO, collectstats, CTLFLAG_RW,
 	&g_collectstats, 0,
 	"Control statistics collection on GEOM providers and consumers");
Index: sys/geom/geom_subr.c
===================================================================
--- sys/geom/geom_subr.c	(revision 255780)
+++ sys/geom/geom_subr.c	(working copy)
@@ -271,7 +271,7 @@
 	g_topology_assert();
 	if (flag == EV_CANCEL)  /* XXX: can't happen ? */
 		return;
-	if (g_shutdown)
+	if (g_shutdown || g_notaste)
 		return;
 
 	hh = arg;
@@ -540,6 +540,8 @@
 		    cp->geom->attrchanged != NULL)
 			cp->geom->attrchanged(cp, "GEOM::media");
 	}
+	if (g_notaste)
+		return;
 	LIST_FOREACH(mp, &g_classes, class) {
 		if (mp->taste == NULL)
 			continue;


More information about the freebsd-geom mailing list