summaryrefslogtreecommitdiffstats
path: root/etc/init.d/zfs-import.in
diff options
context:
space:
mode:
authorJames Lee <[email protected]>2015-08-30 14:36:41 -0400
committerBrian Behlendorf <[email protected]>2015-09-02 09:16:39 -0700
commit3f1cc17c9005d19faba91fe7236332ed502b1a3f (patch)
tree3499392a3fe8255ad8dbcb2c3673fbc7a372e312 /etc/init.d/zfs-import.in
parentfb40095f5f0853946f8150481ca22602d1334dfe (diff)
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 <[email protected]> Signed-off-by: Richard Yao <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #3513
Diffstat (limited to 'etc/init.d/zfs-import.in')
-rwxr-xr-xetc/init.d/zfs-import.in29
1 files changed, 20 insertions, 9 deletions
diff --git a/etc/init.d/zfs-import.in b/etc/init.d/zfs-import.in
index b02d8a92c..a3d6c1442 100755
--- a/etc/init.d/zfs-import.in
+++ b/etc/init.d/zfs-import.in
@@ -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