From owner-freebsd-bugs@FreeBSD.ORG Fri May 23 19:10:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DD8E9CB0 for ; Fri, 23 May 2014 19:10:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (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 B76A12D15 for ; Fri, 23 May 2014 19:10:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s4NJA0EX067497 for ; Fri, 23 May 2014 19:10:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s4NJA0Tt067493; Fri, 23 May 2014 19:10:00 GMT (envelope-from gnats) Resent-Date: Fri, 23 May 2014 19:10:00 GMT Resent-Message-Id: <201405231910.s4NJA0Tt067493@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Paul J Murphy Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3C679C52 for ; Fri, 23 May 2014 19:08:08 +0000 (UTC) Received: from srv00.inetstat.net (srv00.inetstat.net [91.121.154.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "srv00.inetstat.net", Issuer "srv00.inetstat.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E3EC12CF2 for ; Fri, 23 May 2014 19:08:07 +0000 (UTC) Received: from srv00.inetstat.net (localhost [127.0.0.1]) by srv00.inetstat.net (Postfix) with ESMTP id C8A833ACDC for ; Fri, 23 May 2014 19:07:58 +0000 (UTC) Received: from srv00.inetstat.net ([IPv6:::1]) by srv00.inetstat.net (srv00.inetstat.net [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id nJHUUAKEjC7H; Fri, 23 May 2014 19:07:55 +0000 (UTC) Received: by srv00.inetstat.net (Postfix, from userid 1001) id 566AA3ACDB; Fri, 23 May 2014 19:07:55 +0000 (UTC) Message-Id: <20140523190755.566AA3ACDB@srv00.inetstat.net> Date: Fri, 23 May 2014 19:07:55 +0000 (UTC) From: Paul J Murphy Reply-To: Paul J Murphy To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: conf/190152: [patch] [rc] gmirror savecore support X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 May 2014 19:10:00 -0000 >Number: 190152 >Category: conf >Synopsis: [patch] [rc] gmirror savecore support >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri May 23 19:10:00 UTC 2014 >Closed-Date: >Last-Modified: >Originator: Paul J Murphy >Release: FreeBSD 10.0-RELEASE-p3 amd64 >Organization: iNetStat.net >Environment: >Description: (Calling this a sw-bug, rather than change-request, as I consider it a bug that savecore is basically broken on a very common setup.) Adding long-overdue basic gmirror savecore support. In a perfect world, it would support AUTO for simple configurations, but I've left that as a TODO for now, and think that it's better to get this basic support into the OS, and someone can figure out a nice AUTO implementation later. RC-wizards, please feel free to decide that the gmirror commands would be better executed inside the savecore_start() instead of pre/post. Also fixes doc-bugs in gmirror(8), which suggested addressing the issue through the removed rc.early/rc.late scripts, and removes mention of not being able to change priority of gmirror components (seems to work just fine on 10.0-RELEASE, not sure when it was fixed). Small section on boot on gmirror added to the NOTES section of gmirror(8), since there really should be some mention of that in there. >How-To-Repeat: >Fix: Proposed for CURRENT & 10-STABLE. It should probably also go into older -STABLE too. This patch was developed and tested on 10.0-RELEASE, but can probably be easily applied to just about any recent-ish release. Is this simple and low-risk enough that it should go into existing releng branches as well? There's a possible small benefit in security terms, in that any attacks or exploits which end up causing a panic might be more detectable/diagnosable with this patch installed. --- savecore.patch begins here --- Index: etc/defaults/rc.conf =================================================================== --- etc/defaults/rc.conf (revision 266549) +++ etc/defaults/rc.conf (working copy) @@ -595,6 +595,9 @@ savecore_flags="-m 10" # Used if dumpdev is enabled above, and present. # By default, only the 10 most recent kernel dumps # are saved. +savecore_gmirror_name="" # gmirror provider name containing dumpdev +savecore_gmirror_balance="load" # gmirror balance algorithm to set after + # savecore has run crashinfo_enable="YES" # Automatically generate crash dump summary. crashinfo_program="/usr/sbin/crashinfo" # Script to generate crash dump summary. quota_enable="NO" # turn on quotas on startup (or NO). Index: etc/rc.d/savecore =================================================================== --- etc/rc.d/savecore (revision 266549) +++ etc/rc.d/savecore (working copy) @@ -12,6 +12,7 @@ name="savecore" start_cmd="savecore_start" start_precmd="savecore_prestart" +start_postcmd="savecore_poststart" stop_cmd=":" savecore_prestart() @@ -40,6 +41,22 @@ ;; esac + case ${savecore_gmirror_name} in + [Nn][Oo] | '') + savecore_gmirror_name='' + ;; + [Aa][Uu][Tt][Oo]) + # TODO: figure out a reasonable method for auto mode + ;; + esac + + # If there is no balance algorithm, use the default for new mirrors + case ${savecore_gmirror_balance} in + '') + savecore_gmirror_balance='load' + ;; + esac + if [ ! -c "${dumpdev}" ]; then warn "Dump device does not exist. Savecore not run." return 1 @@ -49,6 +66,11 @@ warn "Dump directory does not exist. Savecore not run." return 1 fi + + if [ "${savecore_gmirror_name}" ]; then + gmirror configure -b prefer ${savecore_gmirror_name} + fi + return 0 } @@ -76,5 +98,12 @@ fi } +savecore_poststart() +{ + if [ "${savecore_gmirror_name}" ]; then + gmirror configure -b ${savecore_gmirror_balance} ${savecore_gmirror_name} + fi +} + load_rc_config $name run_rc_command "$1" Index: sbin/geom/class/mirror/gmirror.8 =================================================================== --- sbin/geom/class/mirror/gmirror.8 (revision 266549) +++ sbin/geom/class/mirror/gmirror.8 (working copy) @@ -298,10 +298,23 @@ gmirror activate data da1 .Ed .Sh NOTES -Doing kernel dumps to +.Ss Booting from a gmirror provider +Systems which boot from a .Nm -providers. +provider will need to make the geom_mirror kernel module available at +boot time. If it is not included in the base kernel, but is available +as a loadable module (the normal situation with the standard GENERIC +kernel build), the following should be added to the +.Pa /boot/loader.conf +file: +.Bd -literal -offset indent +geom_mirror_load="YES" +.Ed .Pp +Obviously, normal partitioning and boot code will be required in +addition to loading the kernel module. +.Ss Doing kernel dumps to gmirror providers. +.Pp This is possible, but some conditions have to be met. First of all, a kernel dump will go only to one component and .Nm @@ -313,18 +326,12 @@ will read only from the component with the highest priority). If you use a different balance algorithm, you should add: .Bd -literal -offset indent -gmirror configure -b prefer data +.No savecore_gmirror_name= Ns Qq Ar name +.No savecore_gmirror_balance= Ns Qq Ar balance .Ed .Pp to the -.Pa /etc/rc.early -script and: -.Bd -literal -offset indent -gmirror configure -b round-robin data -.Ed -.Pp -to the -.Pa /etc/rc.local +.Pa /etc/rc.conf script. The decision which component to choose for dumping is made when .Xr dumpon 8 @@ -353,8 +360,6 @@ .Sh AUTHORS .An Pawel Jakub Dawidek Aq pjd@FreeBSD.org .Sh BUGS -There should be a way to change a component's priority inside a running mirror. -.Pp There should be a section with an implementation description. .Pp Documentation for sysctls --- savecore.patch ends here --- >Release-Note: >Audit-Trail: >Unformatted: