]> granicus.if.org Git - zfs/commitdiff
systemd zfs-import.target and documentation
authorAntonio Russo <antonio.e.russo@gmail.com>
Mon, 30 Oct 2017 20:18:26 +0000 (16:18 -0400)
committerTony Hutter <hutter2@llnl.gov>
Mon, 20 Nov 2017 22:20:08 +0000 (16:20 -0600)
zfs-import-{cache,scan}.service must complete before any mounting of
filesystems can occur. To simplify this dependency, create a target
that is reached After (in the systemd sense) the pool is imported.

Additionally, recommend that legacy zfs mounts use the option

x-systemd.requires=zfs-import.target

to codify this requirement.

Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Antonio Russo <antonio.e.russo@gmail.com>
Closes #6764

etc/systemd/system/Makefile.am
etc/systemd/system/zfs-import-cache.service.in
etc/systemd/system/zfs-import-scan.service.in
etc/systemd/system/zfs-import.target.in [new file with mode: 0644]
etc/systemd/system/zfs-mount.service.in
man/man8/zfs.8

index b097497e050f406085e2efa7e4c5ff50599b597b..1586209caa6dd0f4484cc27b6b555fdf30006fd4 100644 (file)
@@ -7,6 +7,7 @@ systemdunit_DATA = \
        zfs-import-scan.service \
        zfs-mount.service \
        zfs-share.service \
+       zfs-import.target \
        zfs.target
 
 EXTRA_DIST = \
@@ -15,6 +16,7 @@ EXTRA_DIST = \
        $(top_srcdir)/etc/systemd/system/zfs-import-scan.service.in \
        $(top_srcdir)/etc/systemd/system/zfs-mount.service.in \
        $(top_srcdir)/etc/systemd/system/zfs-share.service.in \
+       $(top_srcdir)/etc/systemd/system/zfs-import.target.in \
        $(top_srcdir)/etc/systemd/system/zfs.target.in \
        $(top_srcdir)/etc/systemd/system/50-zfs.preset.in
 
index 02184a6027ff5a324cb9c93d625f2f25580eeb21..9d677f8dda3873e8b73724678e317931a3e7ed8b 100644 (file)
@@ -6,6 +6,7 @@ After=systemd-udev-settle.service
 After=cryptsetup.target
 After=systemd-remount-fs.service
 Before=dracut-mount.service
+Before=zfs-import.target
 ConditionPathExists=@sysconfdir@/zfs/zpool.cache
 
 [Service]
@@ -15,5 +16,4 @@ ExecStartPre=/sbin/modprobe zfs
 ExecStart=@sbindir@/zpool import -c @sysconfdir@/zfs/zpool.cache -aN
 
 [Install]
-WantedBy=zfs-mount.service
-WantedBy=zfs.target
+WantedBy=zfs-import.target
index 625f3a9553f84326c83883d8bd50f037b2770efb..227f5b74f36ef6754583416a3c477133ae0380f3 100644 (file)
@@ -5,6 +5,7 @@ Requires=systemd-udev-settle.service
 After=systemd-udev-settle.service
 After=cryptsetup.target
 Before=dracut-mount.service
+Before=zfs-import.target
 ConditionPathExists=!@sysconfdir@/zfs/zpool.cache
 
 [Service]
@@ -14,5 +15,4 @@ ExecStartPre=/sbin/modprobe zfs
 ExecStart=@sbindir@/zpool import -aN -o cachefile=none
 
 [Install]
-WantedBy=zfs-mount.service
-WantedBy=zfs.target
+WantedBy=zfs-import.target
diff --git a/etc/systemd/system/zfs-import.target.in b/etc/systemd/system/zfs-import.target.in
new file mode 100644 (file)
index 0000000..ef25679
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=ZFS pool import target
+
+[Install]
+WantedBy=zfs-mount.service
+WantedBy=zfs.target
index 0664fd9e7665ae55cd5cbf328d0c4937d046f224..728fc630c5c5bde4ff942425b94f73cd3dae6251 100644 (file)
@@ -2,8 +2,7 @@
 Description=Mount ZFS filesystems
 DefaultDependencies=no
 After=systemd-udev-settle.service
-After=zfs-import-cache.service
-After=zfs-import-scan.service
+After=zfs-import.target
 After=systemd-remount-fs.service
 Before=local-fs.target
 
index 44180d6031cd5362a79438fa40aed2abaebb822e..48a5e6ea73e00ee6e3f6d8b5115ebd3a1bc412fd 100644 (file)
@@ -440,7 +440,16 @@ If needed, ZFS file systems can also be managed with traditional tools
 If a file system's mount point is set to
 .Sy legacy ,
 ZFS makes no attempt to manage the file system, and the administrator is
-responsible for mounting and unmounting the file system.
+responsible for mounting and unmounting the file system. Because pools must
+be imported before a legacy mount can succeed, administrators should ensure
+that legacy mounts are only attempted after the zpool import process
+finishes at boot time. For example, on machines using systemd, the mount
+option
+.Pp
+.Nm x-systemd.requires=zfs-import.target
+.Pp
+will ensure that the zfs-import completes before systemd attempts mounting
+the filesystem. See systemd.mount(5) for details.
 .Ss Deduplication
 Deduplication is the process for removing redundant data at the block level,
 reducing the total amount of data stored. If a file system has the