Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd: order zfs-import-* before local-fs-pre #6764

Merged
merged 1 commit into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions etc/systemd/system/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ systemdunit_DATA = \
zfs-import-scan.service \
zfs-mount.service \
zfs-share.service \
zfs-import.target \
zfs.target

EXTRA_DIST = \
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions etc/systemd/system/zfs-import-cache.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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]
Expand All @@ -16,5 +17,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
4 changes: 2 additions & 2 deletions etc/systemd/system/zfs-import-scan.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Requires=systemd-udev-settle.service
After=systemd-udev-settle.service
After=cryptsetup.target
Before=dracut-mount.service
Before=zfs-import.target
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, the "WantedBy" below already implies a "Before", so this is probably redundant?

see "man systemd.unit":

       A number of unit dependencies are automatically established, depending on unit configuration. On top of that, for units with
       DefaultDependencies=yes (the default) a couple of additional dependencies are added. The precise effect of DefaultDependencies=yes
       depends on the unit type (see below).

       If DefaultDependencies=yes is set, units that are referenced by other units of type .target via a Wants= or Requires= dependency
       might automatically gain an Before= dependency too. See systemd.target(5) for details.

Copy link
Contributor Author

@aerusso aerusso Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't DefaultDependencies=no here, though?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sorry I missed it. still not really used to the GH diff view..

ConditionPathExists=!@sysconfdir@/zfs/zpool.cache

[Service]
Expand All @@ -15,5 +16,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
6 changes: 6 additions & 0 deletions etc/systemd/system/zfs-import.target.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Description=ZFS pool import target

[Install]
WantedBy=zfs-mount.service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO also redundant, zfs-mount.service already has an After=, and the main zfs.target already ensures that it is enabled by default

Copy link
Contributor Author

@aerusso aerusso Oct 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zfs-mount.service also has DefaultDependencies=no.

I might be missing something though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but we already have a default chain of
multi-user.target wants zfs.target wants zfs-FOO.target/service that makes sure all the services and targets are enabled. so we only need ordering between mount and import, if both are enabled.

zfs-mount.service works independently of zfs-import.target and the zfs-import-FOO services (e.g., if your rpool has been imported but only the bootfs mounted in initramfs/dracut), it should just run after them if they are also enabled.

it's just a minor nitpick though, and the old units had that WantedBy as well, so feel free to ignore this ;) the same would IMHO also apply to zfs-share -> zfs-mount, which is entirely unrelated to this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are absolutely right. I'm pretty sure I was mirroring the other units dependencies, and worried that someone might enable zfs-mount without zfs.target. Or something quirky that the other units seemed to allow for.

I'll probably leave this as-is so as to not break anyone's (weird) existing setup, unless there's a strong opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a good time to cleanup the other unit dependencies that don't make sense. Although it should be done with two patches so we have the option of cherry-picking the minimal change back to the 0.7 releases.

WantedBy=zfs.target
3 changes: 1 addition & 2 deletions etc/systemd/system/zfs-mount.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Description=Mount ZFS filesystems
Documentation=man:zfs(8)
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

Expand Down
11 changes: 10 additions & 1 deletion man/man8/zfs.8
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,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
Expand Down