Reorder zfs-* services to allow /var on separate dataset

ZED depends on /var.  When /var is a separate dataset, it must be
mounted before starting ZED.  This change moves the zfs-zed service
from starting first, to starting after zfs-mount, but before zfs-share.

As discussed in issue #3513, ZED does not need to start first in order
to consume events made during the zfs-import and zfs-mount services.
The events will be queued and can be handled later in the boot process.

ZED may, however, handle sharing in the future, so it should be started
before the zfs-share service.

This commit also stops the zfs-import service from writing temp files
to /var/tmp on shutdown and it corrects the return code for the OpenRC
service.

Other OpenRC-specific changes noted in issue #3513 were reitereated in
issue #3715 and committed in da619f3.

Signed-off-by: James Lee <jlee@thestaticvoid.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3513
This commit is contained in:
James Lee
2015-08-30 14:36:41 -04:00
committed by Brian Behlendorf
parent fb40095f5f
commit 3f1cc17c90
5 changed files with 45 additions and 46 deletions
+20 -9
View File
@@ -10,8 +10,8 @@
#
### BEGIN INIT INFO
# Provides: zfs-import
# Required-Start: zfs-zed
# Required-Stop: zfs-zed
# Required-Start: mtab
# Required-Stop: $local_fs mtab
# Default-Start: S
# Default-Stop: 0 1 6
# X-Start-Before: checkfs
@@ -20,6 +20,11 @@
# Description: Run the `zpool import` or `zpool export` commands.
### END INIT INFO
#
# NOTE: Not having '$local_fs' on Required-Start but only on Required-Stop
# is on purpose. If we have '$local_fs' in both (and X-Start-Before=checkfs)
# we get conflicts - import needs to be started extremely early,
# but not stopped too late.
#
# Released under the 2-clause BSD license.
#
# The original script that acted as a template for this script came from
@@ -34,7 +39,7 @@
do_depend()
{
after sysfs udev zfs-zed
after sysfs udev
keyword -lxc -openvz -prefix -vserver
}
@@ -246,15 +251,18 @@ do_import()
# Export all pools
do_export()
{
local pool root_pool RET r
local already_imported pool root_pool RET r
RET=0
root_pool=$(get_root_pool)
[ -n "$init" ] && zfs_log_begin_msg "Exporting ZFS pool(s)"
TMPFILE=$(mktemp --tmpdir=/var/tmp zpool.XXXXX)
"$ZPOOL" list -H -oname > "$TMPFILE"
while read pool; do
# Find list of already imported pools.
already_imported=$(find_pools "$ZPOOL" list -H -oname)
OLD_IFS="$IFS" ; IFS=";"
for pool in $already_imported; do
[ "$pool" = "$root_pool" ] && continue
if [ -z "$init" ]
@@ -269,9 +277,12 @@ do_export()
"$ZPOOL" export "$pool"
r="$?" ; RET=$((RET + r))
[ -z "$init" ] && zfs_log_end_msg "$r"
done < "$TMPFILE"
rm -f "$TMPFILE"
done
IFS="$OLD_IFS"
[ -n "$init" ] && zfs_log_end_msg "$RET"
return "$RET"
}
# Output the status and list of pools