From 1aaa2e95c576bffb310a686ca39f9cb0ca47e61b Mon Sep 17 00:00:00 2001
From: kotauskas <v.toncharov@gmail.com>
Date: Sat, 14 Dec 2024 00:50:50 +0300
Subject: [PATCH] Remount datasets on soft-reboot

The one-shot zfs-mount.service is incorrectly deemed active by
Systemd after a systemctl soft-reboot. As such, soft-rebooting
prevents zfs mount -a from being ran automatically.

This commit makes it so that zfs-mount.service is marked as being
undone by the time umount.target is reached, so that zfs.target then
pulls it in again and gets it restarted after a soft reboot.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: kotauskas <v.toncharov@gmail.com>
Closes #16845
---
 etc/systemd/system/zfs-mount.service.in | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/etc/systemd/system/zfs-mount.service.in b/etc/systemd/system/zfs-mount.service.in
index 66d894923f4a..41c02c8238ca 100644
--- a/etc/systemd/system/zfs-mount.service.in
+++ b/etc/systemd/system/zfs-mount.service.in
@@ -8,6 +8,13 @@ After=systemd-remount-fs.service
 Before=local-fs.target
 ConditionPathIsDirectory=/sys/module/zfs
 
+# This merely tells the service manager
+# that unmounting everything undoes the
+# effect of this service. No extra logic
+# is ran as a result of these settings.
+Conflicts=umount.target
+Before=umount.target
+
 [Service]
 Type=oneshot
 RemainAfterExit=yes