Bug 178818

Summary: gmirror savecore support / gmirror(8) says to use rc.early which is no longer available
Product: Base System Reporter: Lawrence Chen <beastie>
Component: confAssignee: Mateusz Piotrowski <0mp>
Status: Closed FIXED    
Severity: Affects Some People CC: 0mp, allanjude, beastie_t, chris, christian.baltini, debdrup, joelh, paul, rc, unitrunker
Priority: Normal Keywords: feature, needs-patch, needs-qa
Version: CURRENTFlags: koobs: mfc-stable12?
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=190152
Attachments:
Description Flags
gmirror(8) manpage patch none

Description Lawrence Chen 2013-05-21 19:20:00 UTC
	
	gmirror(8) has NOTES section on doing kernel dumps to gmirror
	providers and wanting to use a different balance algorithm through use
	of /etc/rc.early and /etc/rc.local.

	But, /etc/rc.early is no more.

Fix: 

Provide an alternative solution to /etc/rc.early, such as create
	an equilavalent /etc/rc.d/early? create some other /etc/rc.d/<file>
	that is "BEFORE: dumpon"?  Some other way?

	Plus the original early script wouldn't work, since it would get called
	after dumpon.  Since it is "REQUIRE: disks" while dumpon is
	"BEFORE: disks".
Comment 1 Chris Rees 2013-05-31 15:52:58 UTC
I think this shouldn't be too hard to automate in the dumpon script,
to be honest.

Please can you try the patch at [1], and set

dumpdev=/dev/mirror/*your_target_mirror*

in /etc/rc.conf, and let me know if it works OK?

Pawel, does this look sane?

Chris

[1] http://www.bayofrum.net/~crees/patches/gmirror-dumps.diff
Comment 2 Lawrence Chen 2013-11-06 13:56:05 UTC
Sorry for not replying sooner, but it didn't quite work for me and
forgot to come back later to see why, since what I hacked seemed to be
working...until recently.

So, I revisited this problem.

One change to your diff... http://lkc.me/5D



-- 
  Name: Lawrence "The Dreamer" Chen      Email: beastie@tardisi.com
 Snail: 1530 College Ave, A5              Blog: http://lawrencechen.net
        Manhattan, KS 66502-2768         Phone: 785-789-4132
Comment 3 Lawrence Chen 2014-04-29 20:18:52 UTC
On 2013-11-06 07:56, The BSD Dreamer wrote:
> Sorry for not replying sooner, but it didn't quite work for me and
> forgot to come back later to see why, since what I hacked seemed to be
> working...until recently.
> 
> So, I revisited this problem.
> 
> One change to your diff... http://lkc.me/5D

System: FreeBSD zen.lhaven.homeip.net 9.2-RELEASE-p4 FreeBSD 9.2-RELEASE-p4 
#0: Tue Apr  8 18:08:22 UTC 2014     
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

So, recently, I had the system panic twice, where it did dumps but they 
couldn't be found by /etc/rc.d/savecore.

Leads me to suspect that this rc script needs a similar tweak.

http://lkc.me/5I
Comment 4 Lawrence Chen 2014-06-10 14:08:00 UTC
Discovered the dumpon script wasn't working as expected...turns out its because I have /usr as a separate filesystem and dumpon is called before such things are mounted.  So it can't find 'grep' (/usr/bin/grep), other commands reside in /sbin or /bin....

But, in bug 190152 it sounds like the modification to dumpon is unnecessary.

Since my balance preference is for 'load' (the default) and savecore (at least) 
needs to get switched to 'prefer'...I just hard coded both dumpon and savecore on my system to switch to prefer and then back to load.

Perhaps, an rc.conf variable to specify what balance preference is used (possibly defaulting to 'load' if not set), to avoid trying to grep the output of 'gmirror list <name>'.

'grep' works in savecore, since its called much later...well after FILESYSTEMS (in fact between NETWORKING and SERVERS...closer to SERVERS.)  Guess its fortunate that nothing has touched swap during up to this point, because swapon is done a little after dumpon.
Comment 5 Christian Baltini 2019-06-11 04:29:32 UTC
I have addressed this like so:

This rc.d script fires before savecore and changes the balance to "prefer" and ensures that a specified GEOM provider has a specified priority.

https://github.com/openspork/freebsd-nas/blob/master/usr/local/etc/rc.d/gmirror_prefer

This rc.d script fires after savecore and changes the balance back to whatever is specified in rc.conf (or wherever).

https://github.com/openspork/freebsd-nas/blob/master/usr/local/etc/rc.d/gmirror_balance

I have tested it working.

In the longer term I think it would be nice if the base system could be smart enough to do something similar.  Until then this appears to do the trick.
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2019-06-11 07:29:02 UTC
Can we get an updated patch against FreeBSD head (as of today), as an attachment in this issue, that incorporates any additions/changes/fixes from those referenced in comment 1, comment 2, comment 3 and comment 5 please where appropriate/necessary

If man page changes are required, please provide that as a second patch in this issue as well

^Triage: Issues shouldn't be " in progress" without a real assignee, re-open. Re-classify (product/component)
Comment 7 Kubilay Kocak freebsd_committer freebsd_triage 2019-06-11 07:40:58 UTC
*** Bug 190152 has been marked as a duplicate of this bug. ***
Comment 8 Christian Baltini 2019-06-12 01:26:28 UTC
Created attachment 205001 [details]
gmirror(8) manpage patch

Patch for lib/geom/mirror/gmirror.8 that adds dumpon/savecore scripts for gmirror with modern rc ordering
Comment 9 Christian Baltini 2019-06-12 01:28:34 UTC
See attachment that adds handling scripts for gmirror dumpon/savecore support.
Tentative initial version.
Comment 10 Christos Chatzaras 2019-09-16 07:58:37 UTC
Can someone commit the patches? It would be great to get it in 12.1.
Comment 11 Christian Baltini 2019-10-06 23:10:59 UTC
(In reply to Christos Chatzaras from comment #10)
I would like if somebody could review and give their blessing before any merging, for I am but a scrub. :)
Comment 12 Daniel Ebdrup Jensen freebsd_committer freebsd_triage 2021-02-23 08:53:12 UTC
I'd love to get this moving, but gmirror(8) has changed considerably since, and the project has also switched VCS in the meantime, so is it possible that I can get you to supply a git diff for this?

Optionally one that's been run through `git format-patch`, as this preserves a bunch of meta-data like creation time and authorship, so that you get proper credit for your work with the name and email like you want them displayed. :)
Comment 13 commit-hook freebsd_committer freebsd_triage 2022-07-21 20:03:31 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a848315f68047ae46a5d96cbc7a890e645ce646f

commit a848315f68047ae46a5d96cbc7a890e645ce646f
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2022-07-21 19:43:14 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2022-07-21 20:02:44 +0000

    gmirror.8: Remove references rc.early

    The manual page of gmirror describes how gmirror providers can be used
    for kernel dumps. Unfortunately, the instruction references
    /etc/rc.early, which is no longer a part of rc(8).

    Remove references to rc.early and suggest creating an rc(8) service
    script instead.

    Future work: In the Problem Report on Bugzilla, Lawrence Chen suggested
    adding example rc(8) scripts to the gmirror. However, those examples
    need to be tested before they become official reference examples in the
    base. Also, those scripts should probably land directly to /etc/rc.d,
    /usr/share/examples/rc.d, or /usr/share/examples/gmirror instead of the
    gmirror manual page.

    PR:             178818
    Reported by:    Lawrence Chen <beastie@tardisi.com>
    Fixes:          dd2b024a336f Removal of early.sh
    MFC after:      1 week

 lib/geom/mirror/gmirror.8 | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
Comment 14 commit-hook freebsd_committer freebsd_triage 2023-10-04 11:24:32 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a22d61c6918c0f76ac7af2c82bc2a87a780f70b9

commit a22d61c6918c0f76ac7af2c82bc2a87a780f70b9
Author:     Mateusz Piotrowski <0mp@FreeBSD.org>
AuthorDate: 2022-07-21 19:43:14 +0000
Commit:     Mateusz Piotrowski <0mp@FreeBSD.org>
CommitDate: 2023-10-04 11:11:41 +0000

    gmirror.8: Remove references rc.early

    The manual page of gmirror describes how gmirror providers can be used
    for kernel dumps. Unfortunately, the instruction references
    /etc/rc.early, which is no longer a part of rc(8).

    Remove references to rc.early and suggest creating an rc(8) service
    script instead.

    Future work: In the Problem Report on Bugzilla, Lawrence Chen suggested
    adding example rc(8) scripts to the gmirror. However, those examples
    need to be tested before they become official reference examples in the
    base. Also, those scripts should probably land directly to /etc/rc.d,
    /usr/share/examples/rc.d, or /usr/share/examples/gmirror instead of the
    gmirror manual page.

    PR:             178818
    Reported by:    Lawrence Chen <beastie@tardisi.com>
    Fixes:          dd2b024a336f Removal of early.sh
    MFC after:      1 week

    (cherry picked from commit a848315f68047ae46a5d96cbc7a890e645ce646f)

 lib/geom/mirror/gmirror.8 | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)