From owner-svn-src-stable-10@FreeBSD.ORG Wed Oct 29 11:07:41 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4161E3E9; Wed, 29 Oct 2014 11:07:41 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2210A837; Wed, 29 Oct 2014 11:07:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9TB7f9C070398; Wed, 29 Oct 2014 11:07:41 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9TB7eKW070396; Wed, 29 Oct 2014 11:07:40 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201410291107.s9TB7eKW070396@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Wed, 29 Oct 2014 11:07:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r273817 - in stable/10: sbin/dumpon sys/geom X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Oct 2014 11:07:41 -0000 Author: ae Date: Wed Oct 29 11:07:40 2014 New Revision: 273817 URL: https://svnweb.freebsd.org/changeset/base/273817 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/10/sbin/dumpon/dumpon.8 stable/10/sys/geom/geom_dev.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/dumpon/dumpon.8 ============================================================================== --- stable/10/sbin/dumpon/dumpon.8 Wed Oct 29 09:36:02 2014 (r273816) +++ stable/10/sbin/dumpon/dumpon.8 Wed Oct 29 11:07:40 2014 (r273817) @@ -28,7 +28,7 @@ .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd April 29, 2013 +.Dd October 8, 2014 .Dt DUMPON 8 .Os .Sh NAME @@ -124,9 +124,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 @@ -136,6 +145,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/10/sys/geom/geom_dev.c ============================================================================== --- stable/10/sys/geom/geom_dev.c Wed Oct 29 09:36:02 2014 (r273816) +++ stable/10/sys/geom/geom_dev.c Wed Oct 29 11:07:40 2014 (r273817) @@ -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, 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, devtoname(dev)); + 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) { @@ -260,9 +316,11 @@ g_dev_taste(struct g_class *mp, struct g dev->si_iosize_max = MAXPHYS; dev->si_drv2 = cp; + init_dumpdev(dev); if (adev != NULL) { adev->si_iosize_max = MAXPHYS; adev->si_drv2 = cp; + init_dumpdev(adev); } g_dev_attrchanged(cp, "GEOM::physpath"); @@ -356,10 +414,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; @@ -394,21 +450,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, 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, devtoname(dev)); - 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);