Summary: | swapoff runs too early during shutdown | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Radim Kolar <hsn> | ||||
Component: | conf | Assignee: | Enji Cooper <ngie> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Some People | CC: | arcade, c.kworr, emaste, freebsd-2024, jilles, koobs, ngie, pi, wosch | ||||
Priority: | --- | Keywords: | easy, needs-qa, patch | ||||
Version: | Unspecified | Flags: | jilles:
mfc-stable11+
jilles: mfc-stable10+ jilles: mfc-stable9- |
||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Bug Depends on: | 224975 | ||||||
Bug Blocks: | |||||||
Attachments: |
|
Description
Radim Kolar
2014-02-26 11:00:00 UTC
Created attachment 161855 [details]
fix "swaplate" to deal only with "late" swap devices
Hi. I like to join this heated conversation. :)
It seems to me you are bitten with /etc/rc.d/swaplate which should remove swap partitions that are not directly available. Yet due to bug in the swapon/swapoff logic it rather removes all swap partitions. I'm bored with this too as on my machine swap is used constantly and when rebooting for some weird reason I need to wait while the system gets all my sleepy daemons from swap back to the memory instead of just stopping them.
The key problem is "-a" and "-L" options to swapon/swapoff as they give only two choices:
1. Single "-a" selects only not "late" "auto" devices (the ones without "noauto" and "late") from /etc/fstab.
2. Both options ("-aL") select whole range of "auto" devices (only skipping "noauto" ones) from /etc/fstab.
This two choices doesn't give us a possibility to turn off only "late" devices, that can really be dependent on some daemons with higher priorities so they MAY fail further down "shutdown" sequence and as such they SHOULD be turned off early during "shutdown".
The fix I propose actually breaks compatibility but I don't think this would be an issue as:
* there's not that much consumers of mentioned options in the scripts;
* the fix brings clarity and usability.
In this fix:
* single "-a" still select only not "late" "auto" devices;
* option "-L" inverts "-a" meaning and selects only "late" "auto" devices;
* documentation and starting script are fixed.
(In reply to c.kworr from comment #1) Interesting bug/patch. I'll look at it. Looks like this ticket stalled? Re-open (unsure of progress) Ngie, have you had a chance to look at this patch? I think swapon -aL can remain unchanged and only swapoff -aL needs the proposed change. I created a Phabricator review at https://reviews.freebsd.org/D8126 . *** Bug 211466 has been marked as a duplicate of this bug. *** A commit references this bug: Author: jilles Date: Fri Oct 21 21:55:50 UTC 2016 New revision: 307755 URL: https://svnweb.freebsd.org/changeset/base/307755 Log: swapoff: Remove only late devices with -aL. Currently, '/etc/rc.d/swaplate stop' removes all swap devices. This can be very slow and may not even be possible if there is a lot of swap space in use. However, removing swap devices is only needed for late swap devices that may depend on daemons that subsequent shutdown steps stop. Normal swap devices such as hard disk partitions will remain available throughout the shutdown process and need not be removed. In swapoff, interpret -aL to remove late swap devices only, and use this in etc/rc.d/swaplate. The meaning of -aL in swapon remains unchanged (add all swap devices, both normal and late). PR: 187081 Reviewed by: wblock (man page only), ngie MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D8126 Changes: head/etc/rc.d/swaplate head/sbin/swapon/swapon.8 head/sbin/swapon/swapon.c (In reply to Jilles Tjoelker from comment #5) Nice to see this one rolling. Thank you. When I created patch I was trying to make options consistent between swapon and swapoff. Hope noone would brag about this. :) A commit references this bug: Author: jilles Date: Sat Nov 19 20:02:49 UTC 2016 New revision: 308865 URL: https://svnweb.freebsd.org/changeset/base/308865 Log: MFC r307755: swapoff: Remove only late devices with -aL. Currently, '/etc/rc.d/swaplate stop' removes all swap devices. This can be very slow and may not even be possible if there is a lot of swap space in use. However, removing swap devices is only needed for late swap devices that may depend on daemons that subsequent shutdown steps stop. Normal swap devices such as hard disk partitions will remain available throughout the shutdown process and need not be removed. In swapoff, interpret -aL to remove late swap devices only, and use this in etc/rc.d/swaplate. The meaning of -aL in swapon remains unchanged (add all swap devices, both normal and late). PR: 187081 Changes: _U stable/11/ stable/11/etc/rc.d/swaplate stable/11/sbin/swapon/swapon.8 stable/11/sbin/swapon/swapon.c A commit references this bug: Author: jilles Date: Sun Nov 20 13:44:27 UTC 2016 New revision: 308886 URL: https://svnweb.freebsd.org/changeset/base/308886 Log: MFC r307755: swapoff: Remove only late devices with -aL. Currently, '/etc/rc.d/swaplate stop' removes all swap devices. This can be very slow and may not even be possible if there is a lot of swap space in use. However, removing swap devices is only needed for late swap devices that may depend on daemons that subsequent shutdown steps stop. Normal swap devices such as hard disk partitions will remain available throughout the shutdown process and need not be removed. In swapoff, interpret -aL to remove late swap devices only, and use this in etc/rc.d/swaplate. The meaning of -aL in swapon remains unchanged (add all swap devices, both normal and late). PR: 187081 Changes: _U stable/10/ stable/10/etc/rc.d/swaplate stable/10/sbin/swapon/swapon.8 stable/10/sbin/swapon/swapon.c |