Date: Tue, 17 Nov 2015 20:55:50 +0000 (UTC) From: Steven Hartland <smh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291004 - head/sys/geom Message-ID: <201511172055.tAHKtoIp079844@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: smh Date: Tue Nov 17 20:55:50 2015 New Revision: 291004 URL: https://svnweb.freebsd.org/changeset/base/291004 Log: Fix early kernel dump via dumpdev env Setting the dumpdev via env e.g. loader.conf provides the ability to configure the kernel dump device during early boot. When using this g_io_getattr was returning EPERM due to cp->acr == 0. Fix this by calling g_access to ensure we're a read consumer prior to calling g_dev_setdumpdev. MFC after: 2 weeks Sponsored by: Multiplay Modified: head/sys/geom/geom_dev.c Modified: head/sys/geom/geom_dev.c ============================================================================== --- head/sys/geom/geom_dev.c Tue Nov 17 20:47:16 2015 (r291003) +++ head/sys/geom/geom_dev.c Tue Nov 17 20:55:50 2015 (r291004) @@ -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 @@ -312,7 +326,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); g_dev_attrchanged(cp, "GEOM::physpath"); snprintf(buf, sizeof(buf), "cdev=%s", gp->name);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511172055.tAHKtoIp079844>