summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Lallement <[email protected]>2020-06-18 19:00:04 +0200
committerBrian Behlendorf <[email protected]>2020-07-19 10:03:48 -0700
commitb717f9b95e6b85ea502318f6350a6b6b6a237ebd (patch)
tree8f0280477287092cdb03d2e10715e44a84c5f400
parentde817cc7b7c2ab3dfa8348ae0e826e84c1d416eb (diff)
BindsTo dataset keyload unit to mount associate unit
We need a stronger dependency between the mount unit and its keyload unit when we know that the dataset is encrypted. If the keyload unit fails, Wants= will still try to mount the dataset, which will then fail. It’s better to show that the failure is due to a dependency failing, the keyload unit, by tighting up the dependency. We can do this as we know that we generate both units in the generator and so, it’s not an optional dependency. BindsTo enable as well that if the keyload unit fails at any point, the associated mountpoint will be then unmounted. Reviewed-by: Richard Laager <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Co-authored-by: Didier Roche <[email protected]> Signed-off-by: Didier Roche <[email protected]> Closes #10477
-rwxr-xr-xetc/systemd/system-generators/zfs-mount-generator.in5
1 files changed, 4 insertions, 1 deletions
diff --git a/etc/systemd/system-generators/zfs-mount-generator.in b/etc/systemd/system-generators/zfs-mount-generator.in
index 197180533..f7a5161ec 100755
--- a/etc/systemd/system-generators/zfs-mount-generator.in
+++ b/etc/systemd/system-generators/zfs-mount-generator.in
@@ -115,6 +115,7 @@ process_line() {
wants="zfs-import.target"
requires=""
requiredmounts=""
+ bindsto=""
wantedby=""
requiredby=""
noauto="off"
@@ -202,7 +203,8 @@ ExecStop=@sbindir@/zfs unload-key '${dataset}'" > "${dest_norm}/${keyloadunit}
fi
# Update the dependencies for the mount file to want the
# key-loading unit.
- wants="${wants} ${keyloadunit}"
+ wants="${wants}"
+ bindsto="BindsTo=${keyloadunit}"
after="${after} ${keyloadunit}"
fi
@@ -413,6 +415,7 @@ Documentation=man:zfs-mount-generator(8)
Before=${before}
After=${after}
Wants=${wants}
+${bindsto}
${requires}
${requiredmounts}