conf/190152: [patch] [rc] gmirror savecore support
Paul J Murphy
paul at inetstat.net
Fri May 23 19:10:00 UTC 2014
>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 at 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:
More information about the freebsd-bugs
mailing list