Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[PATCH] control which tmpfs get unmounted at swapoff



The swap1_stop() function of /etc/rc.d/swap1 is currently set up to
forcibly unmount all tmpfs filesystems before removing block-type swap
devices.  The reason for this is explained here:
https://mail-index.netbsd.org/current-users/2015/10/22/msg028267.html
In short: swap has to be removed before filesystems are unmounted
(because files could be used for swap), and any (potentially large)
files in a tmpfs would have to be moved into (potentially limited) RAM
when this happens.  So as a safety measure the tmpfs filesystems are
removed first.

Unfortunately, this leads to crashes for systems where /dev is mounted
on tmpfs because /dev gets unmounted when swap is removed, which is
before userland is finished running the shutdown scripts.

I attach patches that implement a proposed solution to this problem.
There is a new rc.conf variable "swap_backed_tmpfs".  This can be
set to "ALL" or to an explicit space-separated list of filesystems to
be unmounted before swapoff.  I've set the default to "ALL", which
maintains the current behaviour.  Those who run /dev-on-tmpfs can
instead set it to something like "/var/shm /tmp", or set it to the
empty string, to avoid the untimely disappearence of /dev.  I've tested
all three possibilities (ALL, explicit list, empty list) on my machine
without any problems.

The explanation added to the manpage is a bit too verbose.  Suggestions
for how to explain the new variable more concisely would be appreciated.

Any questions/comments/suggestions?

--
IDL


Attachment: swap1.patch
Description: Binary data

Attachment: rc.conf.patch
Description: Binary data

Attachment: manpage.patch
Description: Binary data



Home | Main Index | Thread Index | Old Index