rc.d/zfs: Add shutdown to KEYWORDS
The problem is that Without walling /etc/rc.d/zfs on shutdown, resources
associated with ZFS mounts are not freed and the jails will remain in dying
state. In addition, the dataset is now in a dangling state, as the jail it is
attached to is dying.
A known workaround for jails was to add the following lines to /etc/jail.conf,
to make sure theat "service zfs stop" is run when the jail is stopped:
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.stop += "/usr/sbin/service zfs stop || /usr/bin/true";
While the workaround seems to be okay-ish for the jail situation, it is still
unclean. However, for physical hosts this may wreak havoc with the pool if
shared spares are used, as "zfs unshare" is never invoked on shutdown.
PR: 147444
Reported by: Mykah <mburkhardt__exavault_com>
Submitted by: Markus Stoff <markus__stoffdv_at>
MFC: 1 weekDetails
Details
- Reviewers
freqlabs cy mmacy - Commits
- rS367291: rc.d/zfs: Add shutdown to KEYWORDS
How to reproduce:
# jail.conf
test {
path = "/jails/test";
exec.clean;
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
# Make sure to unmount all ZFS datasets before stopping the jail
# Required unless the jails /etc/rc.d/zfs contains '# KEYWORD: shutdown'
exec.stop += "/usr/sbin/service zfs stop || true";
# Mandatory to use ZFS in jail
allow.mount;
allow.mount.zfs;
enforce_statfs = 1; # must be less than 2
# Attach ZFS dataset to jail
exec.created = "/sbin/zfs jail test tank/jaildata";
# Make sure the /dev/zfs device is included (it is with the default
# devfs_ruleset = 4)
mount.devfs;
}
# Create dataset
zfs create -o jailed=on -o mountpoint=/data tank/jaildata
mkdir -p /jails/test/data
sysrc -f /jails/test/etc/rc.conf zfs_enable=YES
# Start the jail
jail -c test
# List ZFS mounts
zfs mount | grep jaildata
tank/jaildata /jails/test/data
# Stop the jail
jail -r test
# List ZFS mounts (mount is still there)
zfs mount | grep jaildata
tank/jaildata /jails/test/dataDiff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable