svn commit: r273819 - in stable/9: sbin/dumpon sys/geom

Andrey V. Elsukov ae at FreeBSD.org
Wed Oct 29 11:47:06 UTC 2014


Author: ae
Date: Wed Oct 29 11:47:04 2014
New Revision: 273819
URL: https://svnweb.freebsd.org/changeset/base/273819

Log:
  MFC r272746:
    Add an ability to set dumpdev via loader(8) tunable.
  
  MFC r272747:
    Revert r156046. We support setting dumpdev via loader tunable again.
    Also change default disk name to ada.

Modified:
  stable/9/sbin/dumpon/dumpon.8
  stable/9/sys/geom/geom_dev.c
Directory Properties:
  stable/9/sbin/dumpon/   (props changed)
  stable/9/sys/   (props changed)

Modified: stable/9/sbin/dumpon/dumpon.8
==============================================================================
--- stable/9/sbin/dumpon/dumpon.8	Wed Oct 29 11:11:54 2014	(r273818)
+++ stable/9/sbin/dumpon/dumpon.8	Wed Oct 29 11:47:04 2014	(r273819)
@@ -28,7 +28,7 @@
 .\"     From: @(#)swapon.8	8.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd May 12, 1995
+.Dd October 8, 2014
 .Dt DUMPON 8
 .Os
 .Sh NAME
@@ -107,9 +107,18 @@ performs a
 on
 .Pa /dev/null
 and thus instructs the kernel not to save crash dumps.
+.Pp
+Since
+.Nm
+cannot be used during kernel initialization, the
+.Va dumpdev
+variable of
+.Xr loader 8
+must be used to enable dumps for system panics which occur
+during kernel initialization.
 .Sh FILES
-.Bl -tag -width "/dev/{ad,da}?s?b" -compact
-.It Pa /dev/{ad,da}?s?b
+.Bl -tag -width "/dev/{ada,da}?s?b" -compact
+.It Pa /dev/{ada,da}?s?b
 standard swap areas
 .It Pa /etc/rc.conf
 boot-time system configuration
@@ -119,6 +128,7 @@ boot-time system configuration
 .Xr rc.conf 5 ,
 .Xr config 8 ,
 .Xr init 8 ,
+.Xr loader 8 ,
 .Xr rc 8 ,
 .Xr savecore 8 ,
 .Xr swapon 8 ,

Modified: stable/9/sys/geom/geom_dev.c
==============================================================================
--- stable/9/sys/geom/geom_dev.c	Wed Oct 29 11:11:54 2014	(r273818)
+++ stable/9/sys/geom/geom_dev.c	Wed Oct 29 11:47:04 2014	(r273819)
@@ -82,6 +82,8 @@ static struct cdevsw g_dev_cdevsw = {
 	.d_flags =	D_DISK | D_TRACKCLOSE,
 };
 
+static g_init_t g_dev_init;
+static g_fini_t g_dev_fini;
 static g_taste_t g_dev_taste;
 static g_orphan_t g_dev_orphan;
 static g_attrchanged_t g_dev_attrchanged;
@@ -89,6 +91,8 @@ static g_attrchanged_t g_dev_attrchanged
 static struct g_class g_dev_class	= {
 	.name = "DEV",
 	.version = G_VERSION,
+	.init = g_dev_init,
+	.fini = g_dev_fini,
 	.taste = g_dev_taste,
 	.orphan = g_dev_orphan,
 	.attrchanged = g_dev_attrchanged
@@ -107,6 +111,58 @@ SYSCTL_QUAD(_kern_geom_dev, OID_AUTO, de
     "delete request sent to the provider. Larger requests are chunked "
     "so they can be interrupted. (0 = disable chunking)");
 
+static char *dumpdev = NULL;
+static void
+g_dev_init(struct g_class *mp)
+{
+
+	dumpdev = getenv("dumpdev");
+}
+
+static void
+g_dev_fini(struct g_class *mp)
+{
+
+	freeenv(dumpdev);
+}
+
+static int
+g_dev_setdumpdev(struct cdev *dev)
+{
+	struct g_kerneldump kd;
+	struct g_consumer *cp;
+	int error, len;
+
+	if (dev == NULL)
+		return (set_dumper(NULL));
+
+	cp = dev->si_drv2;
+	len = sizeof(kd);
+	kd.offset = 0;
+	kd.length = OFF_MAX;
+	error = g_io_getattr("GEOM::kerneldump", cp, &len, &kd);
+	if (error == 0) {
+		error = set_dumper(&kd.di);
+		if (error == 0)
+			dev->si_flags |= SI_DUMPDEV;
+	}
+	return (error);
+}
+
+static void
+init_dumpdev(struct cdev *dev)
+{
+
+	if (dumpdev == NULL)
+		return;
+	if (strcmp(devtoname(dev), dumpdev) != 0)
+		return;
+	if (g_dev_setdumpdev(dev) == 0) {
+		freeenv(dumpdev);
+		dumpdev = NULL;
+	}
+}
+
 static void
 g_dev_destroy(void *arg, int flags __unused)
 {
@@ -261,11 +317,13 @@ g_dev_taste(struct g_class *mp, struct g
 		dev->si_flags |= SI_CANDELETE;
 	dev->si_iosize_max = MAXPHYS;
 	dev->si_drv2 = cp;
+	init_dumpdev(dev);
 	if (adev != NULL) {
 		if (pp->flags & G_PF_CANDELETE)
 			adev->si_flags |= SI_CANDELETE;
 		adev->si_iosize_max = MAXPHYS;
 		adev->si_drv2 = cp;
+		init_dumpdev(adev);
 	}
 
 	g_dev_attrchanged(cp, "GEOM::physpath");
@@ -359,10 +417,8 @@ g_dev_ioctl(struct cdev *dev, u_long cmd
 {
 	struct g_consumer *cp;
 	struct g_provider *pp;
-	struct g_kerneldump kd;
 	off_t offset, length, chunk;
 	int i, error;
-	u_int u;
 
 	cp = dev->si_drv2;
 	pp = cp->provider;
@@ -397,21 +453,10 @@ g_dev_ioctl(struct cdev *dev, u_long cmd
 		error = g_io_getattr("GEOM::frontstuff", cp, &i, data);
 		break;
 	case DIOCSKERNELDUMP:
-		u = *((u_int *)data);
-		if (!u) {
-			set_dumper(NULL);
-			error = 0;
-			break;
-		}
-		kd.offset = 0;
-		kd.length = OFF_MAX;
-		i = sizeof kd;
-		error = g_io_getattr("GEOM::kerneldump", cp, &i, &kd);
-		if (!error) {
-			error = set_dumper(&kd.di);
-			if (!error)
-				dev->si_flags |= SI_DUMPDEV;
-		}
+		if (*(u_int *)data == 0)
+			error = g_dev_setdumpdev(NULL);
+		else
+			error = g_dev_setdumpdev(dev);
 		break;
 	case DIOCGFLUSH:
 		error = g_io_flush(cp);


More information about the svn-src-stable-9 mailing list