diff -Nru zfs-linux-0.8.3/debian/changelog zfs-linux-0.8.3/debian/changelog --- zfs-linux-0.8.3/debian/changelog 2021-06-10 13:39:25.000000000 +0000 +++ zfs-linux-0.8.3/debian/changelog 2021-07-12 14:36:13.000000000 +0000 @@ -1,3 +1,12 @@ +zfs-linux (0.8.3-1ubuntu12.11) focal; urgency=medium + + * Fix dependency loop preventing swap partitions from being mounted + correctly (LP: #1875577) + - d/p/4900-Fix-a-dependency-loop.patch + - d/p/4901-Fix-another-dependency-loop.patch + + -- Heitor Alves de Siqueira Mon, 12 Jul 2021 14:36:13 +0000 + zfs-linux (0.8.3-1ubuntu12.10) focal; urgency=medium * fix uio partial copies (LP: #1904589) diff -Nru zfs-linux-0.8.3/debian/patches/4900-Fix-a-dependency-loop.patch zfs-linux-0.8.3/debian/patches/4900-Fix-a-dependency-loop.patch --- zfs-linux-0.8.3/debian/patches/4900-Fix-a-dependency-loop.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.8.3/debian/patches/4900-Fix-a-dependency-loop.patch 2021-07-12 14:33:05.000000000 +0000 @@ -0,0 +1,103 @@ +From aa1f71b103697cb8ae3e27fac7e3696237837f0d Mon Sep 17 00:00:00 2001 +From: Richard Laager +Date: Sat, 30 May 2020 18:40:45 -0500 +Subject: [PATCH 1/2] Fix a dependency loop + +When generating units with zfs-mount-generator, if the pool is already +imported, zfs-import.target is not needed. This avoids a dependency +loop on root-on-ZFS systems: + systemd-random-seed.service After (via RequiresMountsFor) + var-lib.mount After + zfs-import.target After + zfs-import-{cache,scan}.service After + cryptsetup.service After + systemd-random-seed.service + +Reviewed-by: Antonio Russo +Reviewed-by: InsanePrawn +Signed-off-by: Richard Laager +Closes #10388 + +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1875577 +Origin: backport, https://github.com/openzfs/zfs/commit/ec41cafee1da +--- + .../system-generators/zfs-mount-generator.in | 27 +++++++++++++++++-- + etc/systemd/system/zfs-mount.service.in | 1 - + 2 files changed, 25 insertions(+), 3 deletions(-) + +diff --git a/etc/systemd/system-generators/zfs-mount-generator.in b/etc/systemd/system-generators/zfs-mount-generator.in +index 1f88b02179d2..298b301e1983 100755 +--- a/etc/systemd/system-generators/zfs-mount-generator.in ++++ b/etc/systemd/system-generators/zfs-mount-generator.in +@@ -42,6 +42,8 @@ else + do_fail "zero or three arguments required" + fi + ++pools=$(zpool list -H -o name || true) ++ + # For ZFSs marked "auto", a dependency is created for local-fs.target. To + # avoid regressions, this dependency is reduced to "wants" rather than + # "requires". **THIS MAY CHANGE** +@@ -58,10 +60,10 @@ process_line() { + # zfs list -H -o name,... + # fields are tab separated + IFS="$(printf '\t')" +- # protect against special characters in, e.g., mountpoints +- set -f + set -- $1 ++ + dataset="${1}" ++ pool="${dataset%%/*}" + p_mountpoint="${2}" + p_canmount="${3}" + p_atime="${4}" +@@ -77,6 +79,25 @@ process_line() { + # Minimal pre-requisites to mount a ZFS dataset + wants="zfs-import.target" + ++ # If the pool is already imported, zfs-import.target is not needed. This ++ # avoids a dependency loop on root-on-ZFS systems: ++ # systemd-random-seed.service After (via RequiresMountsFor) var-lib.mount ++ # After zfs-import.target After zfs-import-{cache,scan}.service After ++ # cryptsetup.service After systemd-random-seed.service. ++ # ++ # Pools are newline-separated and may contain spaces in their names. ++ # There is no better portable way to set IFS to just a newline. Using ++ # $(printf '\n') doesn't work because $(...) strips trailing newlines. ++ IFS=" ++" ++ for p in $pools ; do ++ if [ "$p" = "$pool" ] ; then ++ after="" ++ wants="" ++ break ++ fi ++ done ++ + # Handle encryption + if [ -n "${p_encroot}" ] && + [ "${p_encroot}" != "-" ] ; then +@@ -335,6 +356,8 @@ initzsys + + # Feed each line into process_line + for cachefile in "${FSLIST}/"* ; do ++ # Disable glob expansion to protect against special characters when parsing. ++ set -f + while read -r fs ; do + process_line "${fs}" + done < "${cachefile}" +diff --git a/etc/systemd/system/zfs-mount.service.in b/etc/systemd/system/zfs-mount.service.in +index c2f2fa567541..a99e8343eb1f 100644 +--- a/etc/systemd/system/zfs-mount.service.in ++++ b/etc/systemd/system/zfs-mount.service.in +@@ -6,7 +6,6 @@ After=systemd-udev-settle.service + After=zfs-import.target + After=systemd-remount-fs.service + Before=local-fs.target +-Before=systemd-random-seed.service + After=zfs-load-module.service + ConditionPathExists=/sys/module/zfs + +-- +2.32.0 + diff -Nru zfs-linux-0.8.3/debian/patches/4901-Fix-another-dependency-loop.patch zfs-linux-0.8.3/debian/patches/4901-Fix-another-dependency-loop.patch --- zfs-linux-0.8.3/debian/patches/4901-Fix-another-dependency-loop.patch 1970-01-01 00:00:00.000000000 +0000 +++ zfs-linux-0.8.3/debian/patches/4901-Fix-another-dependency-loop.patch 2021-07-12 14:33:05.000000000 +0000 @@ -0,0 +1,45 @@ +From 25c312ec22065123f0d9cb1b55be8dd9b3e62589 Mon Sep 17 00:00:00 2001 +From: Richard Laager +Date: Sat, 30 May 2020 20:39:31 -0500 +Subject: [PATCH 2/2] Fix another dependency loop + +zfs-load-key-DATASET.service was gaining an +After=systemd-journald.socket due to its stdout/stderr going to the +journal (which is the default). systemd-journald.socket has an After +(via RequiresMountsFor=/run/systemd/journal) on -.mount. If the root +filesystem is encrypted, -.mount gets an After +zfs-load-key-DATASET.service. + +By setting stdout and stderr to null on the key load services, we avoid +this loop. + +Reviewed-by: Antonio Russo +Reviewed-by: InsanePrawn +Signed-off-by: Richard Laager +Closes #10356 +Closes #10388 + +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1875577 +Origin: upstream, https://github.com/openzfs/zfs/commit/62663fb7ec19 +--- + etc/systemd/system-generators/zfs-mount-generator.in | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/etc/systemd/system-generators/zfs-mount-generator.in b/etc/systemd/system-generators/zfs-mount-generator.in +index 298b301e1983..31352b05659f 100755 +--- a/etc/systemd/system-generators/zfs-mount-generator.in ++++ b/etc/systemd/system-generators/zfs-mount-generator.in +@@ -140,6 +140,10 @@ ${pathdep} + [Service] + Type=oneshot + RemainAfterExit=yes ++# This avoids a dependency loop involving systemd-journald.socket if this ++# dataset is a parent of the root filesystem. ++StandardOutput=null ++StandardError=null + ExecStart=${keyloadcmd} + ExecStop=@sbindir@/zfs unload-key '${dataset}' + EOF +-- +2.32.0 + diff -Nru zfs-linux-0.8.3/debian/patches/series zfs-linux-0.8.3/debian/patches/series --- zfs-linux-0.8.3/debian/patches/series 2021-06-10 13:36:43.000000000 +0000 +++ zfs-linux-0.8.3/debian/patches/series 2021-07-12 14:35:34.000000000 +0000 @@ -25,3 +25,5 @@ 4701-Bugfix-fix-uio-partial-copies.patch 4702-Revert-Let-zfs-mount-all-tolerate-in-progress-mounts.patch 4800-fix-iput-race-in-zfs_iput_async.patch +4900-Fix-a-dependency-loop.patch +4901-Fix-another-dependency-loop.patch