Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Apply patch from Ian D. Leroux in PR bin/51019:
details: https://anonhg.NetBSD.org/src/rev/ab8f21f7eb92
branches: trunk
changeset: 445251:ab8f21f7eb92
user: martin <martin%NetBSD.org@localhost>
date: Fri Oct 19 14:11:12 2018 +0000
description:
Apply patch from Ian D. Leroux in PR bin/51019:
when unmounting tmpfs file systems at shutdown time, avoid unmounting
a tmpfs created by init on /dev - behaviour overridable from rc.conf.
By default all tmpfs that have device nodes are not mounted.
diffstat:
etc/defaults/rc.conf | 8 +++++++-
etc/rc.d/swap1 | 39 ++++++++++++++++++++++++++++++++++++---
share/man/man5/rc.conf.5 | 23 +++++++++++++++++++++--
3 files changed, 64 insertions(+), 6 deletions(-)
diffs (128 lines):
diff -r f29da82db525 -r ab8f21f7eb92 etc/defaults/rc.conf
--- a/etc/defaults/rc.conf Fri Oct 19 14:06:13 2018 +0000
+++ b/etc/defaults/rc.conf Fri Oct 19 14:11:12 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.145 2018/09/23 07:24:19 maxv Exp $
+# $NetBSD: rc.conf,v 1.146 2018/10/19 14:11:12 martin Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -99,6 +99,12 @@
# partitions and don't want to be warned about it.
swapoff=YES # Remove block-type swap partitions upon shutdown
# This defaults to yes, so that raids shutdown cleanly
+swapoff_umount=auto # Set to 'manual' to umount the tmpfs partitions listed
+ # in swapoff_umount_fs before removing swap. Set to
+ # 'auto' to umount all tmpfs paritions that contain
+ # no device nodes.
+swapoff_umount_fs= # space-separated list of tmpfs mount points to umount
+ # before removing swap if swapoff_umount=manual
# Concatenated disk driver.
#
diff -r f29da82db525 -r ab8f21f7eb92 etc/rc.d/swap1
--- a/etc/rc.d/swap1 Fri Oct 19 14:06:13 2018 +0000
+++ b/etc/rc.d/swap1 Fri Oct 19 14:11:12 2018 +0000
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: swap1,v 1.12 2015/04/20 18:01:46 prlw1 Exp $
+# $NetBSD: swap1,v 1.13 2018/10/19 14:11:12 martin Exp $
#
# PROVIDE: localswap
@@ -13,6 +13,40 @@
start_cmd="swap1_start"
stop_cmd="swap1_stop"
+dev_free_tmpfs()
+{
+ # Generate a list of tmpfs filesystems that contain no device nodes,
+ # which can presumably be unmounted safetly at shutdown time.
+ # Filenames are quoted and the list contains no unquoted newlines,
+ # so that the output can be reparsed as a single argument list.
+ mount -t tmpfs | while read -r line
+ do
+ fs=${line#tmpfs on }
+ fs=${fs% type tmpfs*}
+ find -x "${fs}" \( -type b -or -type c \) -exit 1 &&
+ echo -n "'${fs}' "
+ done
+}
+
+umount_vm_consumers()
+{
+ case ${swapoff_umount} in
+ auto)
+ swapoff_umount_fs="$(dev_free_tmpfs)"
+ ;;
+ manual)
+ # swapoff_umount_fs set manually
+ ;;
+ esac
+ # eval so that quotes within $swapoff_umount_fs are parsed properly
+ eval set -- "${swapoff_umount_fs}"
+ for fs in "$@"
+ do
+ echo "Forcibly unmounting ${fs}"
+ umount -ft tmpfs "${fs}"
+ done
+}
+
# Add all block-type swap devices; these might be necessary
# during disk checks.
#
@@ -31,8 +65,7 @@
swap1_stop()
{
if checkyesno swapoff || [ -n "$rc_force" ]; then
- echo "Forcibly unmounting tmpfs filesystems"
- umount -aft tmpfs
+ umount_vm_consumers
echo "Removing block-type swap devices"
swapctl -U -t blk || [ $? = 2 ]
fi
diff -r f29da82db525 -r ab8f21f7eb92 share/man/man5/rc.conf.5
--- a/share/man/man5/rc.conf.5 Fri Oct 19 14:06:13 2018 +0000
+++ b/share/man/man5/rc.conf.5 Fri Oct 19 14:11:12 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rc.conf.5,v 1.177 2018/10/01 11:16:04 uwe Exp $
+.\" $NetBSD: rc.conf.5,v 1.178 2018/10/19 14:11:12 martin Exp $
.\"
.\" Copyright (c) 1996 Matthew R. Green
.\" All rights reserved.
@@ -55,7 +55,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 23, 2018
+.Dd October 19, 2018
.Dt RC.CONF 5
.Os
.Sh NAME
@@ -353,6 +353,25 @@
Boolean value.
Remove block-type swap devices at shutdown time.
Useful if swapping onto RAIDframe devices.
+.It Sy swapoff_umount
+.Dq "auto"
+or
+.Dq "manual" .
+Before removing block-type swap devices, it is wise to unmount tmpfs filesystems to avoid having to swap their contents back into RAM.
+By default
+.Dq ( "auto" )
+all tmpfs filesystems that contain no device nodes are unmounted.
+Set to
+.Dq "manual"
+to explicitly specify which filesystems to unmount before removing swap.
+.It Sy swapoff_umount_fs
+A space-separated list of absolute paths to tmpfs mount points.
+If
+.Sy swapoff_umount
+is set to
+.Dq "manual" ,
+these tmpfs filesystems will be forcibly unmounted before removing block-type
+swap devices.
.It Sy var_shm_symlink
A path.
If set, names a path that
Home |
Main Index |
Thread Index |
Old Index