Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Dec 2015 00:53:03 +0000 (UTC)
From:      Steven Hartland <smh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r291548 - stable/10/sys/geom
Message-ID:  <201512010053.tB10r3VM030983@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: smh
Date: Tue Dec  1 00:53:03 2015
New Revision: 291548
URL: https://svnweb.freebsd.org/changeset/base/291548

Log:
  MFC r291004:
  
  Fix early kernel dump via dumpdev env
  
  Sponsored by:	Multiplay

Modified:
  stable/10/sys/geom/geom_dev.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/geom/geom_dev.c
==============================================================================
--- stable/10/sys/geom/geom_dev.c	Tue Dec  1 00:48:31 2015	(r291547)
+++ stable/10/sys/geom/geom_dev.c	Tue Dec  1 00:53:03 2015	(r291548)
@@ -150,24 +150,38 @@ g_dev_setdumpdev(struct cdev *dev, struc
 	return (error);
 }
 
-static void
+static int
 init_dumpdev(struct cdev *dev)
 {
+	struct g_consumer *cp;
 	const char *devprefix = "/dev/", *devname;
+	int error;
 	size_t len;
 
 	if (dumpdev == NULL)
-		return;
+		return (0);
+
 	len = strlen(devprefix);
 	devname = devtoname(dev);
 	if (strcmp(devname, dumpdev) != 0 &&
 	   (strncmp(dumpdev, devprefix, len) != 0 ||
 	    strcmp(devname, dumpdev + len) != 0))
-		return;
-	if (g_dev_setdumpdev(dev, curthread) == 0) {
+		return (0);
+
+	cp = (struct g_consumer *)dev->si_drv2;
+	error = g_access(cp, 1, 0, 0);
+	if (error != 0)
+		return (error);
+
+	error = g_dev_setdumpdev(dev, curthread);
+	if (error == 0) {
 		freeenv(dumpdev);
 		dumpdev = NULL;
 	}
+
+	(void)g_access(cp, -1, 0, 0);
+
+	return (error);
 }
 
 static void
@@ -329,7 +343,10 @@ g_dev_taste(struct g_class *mp, struct g
 
 	dev->si_iosize_max = MAXPHYS;
 	dev->si_drv2 = cp;
-	init_dumpdev(dev);
+	error = init_dumpdev(dev);
+	if (error != 0)
+		printf("%s: init_dumpdev() failed (gp->name=%s, error=%d)\n",
+		    __func__, gp->name, error);
 	if (adev != NULL) {
 		adev->si_iosize_max = MAXPHYS;
 		adev->si_drv2 = cp;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512010053.tB10r3VM030983>