teknoraver / rpms / systemd

Forked from rpms/systemd a month ago
Clone

Blame SOURCES/0236-tests-make-sure-we-delay-running-mount-start-jobs-wh.patch

594167
From 94f643c328cd2d3c7376219573e0bc5dedea10d8 Mon Sep 17 00:00:00 2001
594167
From: Michal Sekletar <msekleta@redhat.com>
594167
Date: Mon, 30 May 2022 14:50:05 +0200
594167
Subject: [PATCH] tests: make sure we delay running mount start jobs when
594167
 /p/s/mountinfo is rate limited
594167
594167
(cherry picked from commit 9e15be6c8d55abd800bf33f9776dd0e307ed37bc)
594167
594167
Related: #2087652
594167
---
594167
 test/units/testsuite-60.sh | 53 ++++++++++++++++++++++++++++++++++++++
594167
 1 file changed, 53 insertions(+)
594167
594167
diff --git a/test/units/testsuite-60.sh b/test/units/testsuite-60.sh
594167
index 239d7b0d4c..8cb3f466b6 100755
594167
--- a/test/units/testsuite-60.sh
594167
+++ b/test/units/testsuite-60.sh
594167
@@ -3,6 +3,56 @@
594167
 set -eux
594167
 set -o pipefail
594167
 
594167
+test_issue_20329() {
594167
+    local tmpdir unit
594167
+    tmpdir="$(mktemp -d)"
594167
+    unit=$(systemd-escape --suffix mount --path "$tmpdir")
594167
+
594167
+    # Set up test mount unit
594167
+    cat > /run/systemd/system/"$unit" <
594167
+[Mount]
594167
+What=tmpfs
594167
+Where=$tmpdir
594167
+Type=tmpfs
594167
+Options=defaults,nofail
594167
+EOF
594167
+
594167
+    # Start the unit
594167
+    systemctl daemon-reload
594167
+    systemctl start "$unit"
594167
+
594167
+    [[ "$(systemctl show --property SubState --value "$unit")" = "mounted" ]] || {
594167
+        echo >&2 "Test mount \"$unit\" unit isn't mounted"
594167
+        return 1
594167
+    }
594167
+    mountpoint -q "$tmpdir"
594167
+
594167
+    trap 'systemctl stop $unit' RETURN
594167
+
594167
+    # Trigger the mount ratelimiting
594167
+    cd "$(mktemp -d)"
594167
+    mkdir foo
594167
+    for ((i=0;i<50;++i)); do
594167
+        mount --bind foo foo
594167
+        umount foo
594167
+    done
594167
+
594167
+    # Unmount the test mount and start it immediately again via systemd
594167
+    umount "$tmpdir"
594167
+    systemctl start "$unit"
594167
+
594167
+    # Make sure it is seen as mounted by systemd and it actually is mounted
594167
+    [[ "$(systemctl show --property SubState --value "$unit")" = "mounted" ]] || {
594167
+        echo >&2 "Test mount \"$unit\" unit isn't in \"mounted\" state"
594167
+        return 1
594167
+    }
594167
+
594167
+    mountpoint -q "$tmpdir" || {
594167
+        echo >&2 "Test mount \"$unit\" is in \"mounted\" state, actually is not mounted"
594167
+        return 1
594167
+    }
594167
+}
594167
+
594167
 systemd-analyze log-level debug
594167
 systemd-analyze log-target journal
594167
 
594167
@@ -87,6 +137,9 @@ if systemctl list-units -t mount tmp-meow* | grep -q tmp-meow; then
594167
     exit 42
594167
 fi
594167
 
594167
+# test that handling of mount start jobs is delayed when /proc/self/mouninfo monitor is rate limited
594167
+test_issue_20329
594167
+
594167
 systemd-analyze log-level info
594167
 
594167
 echo OK >/testok