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644
@@ -0,0 +1 @@
+e2fsck self-deadlocks flushing the write-error cache (regression test for libext2fs CACHE_MTX retry double-lock)
new file mode 100644
@@ -0,0 +1,44 @@
+FSCK_OPT=-fn
+OUT=$test_name.log
+EXP=$test_dir/expect
+
+# This test is about termination, not output: an unfixed e2fsck
+# self-deadlocks here and ignores SIGTERM, so bound the run or a failure
+# stops the whole suite indefinitely. The probe-then-use form is from
+# tests/r_corrupt_fs/script; -k escalates to SIGKILL.
+if timeout -v 1s true > /dev/null 2>&1 ; then
+ TIMEOUT="timeout -v -k 5s 30s"
+else
+ TIMEOUT=
+fi
+
+gzip -d < $test_dir/image.gz > $TMPFILE
+old="$($CRCSUM < $TMPFILE)"
+
+# The transcript is a thousand lines of repeated write errors and is not
+# what is under test; only record that e2fsck came back, with the status
+# it should have, and that -n left the image alone.
+$TIMEOUT $FSCK $FSCK_OPT -N test_filesys $TMPFILE > /dev/null 2>&1
+status=$?
+echo "Exit status is $status" > $OUT
+
+new="$($CRCSUM < $TMPFILE)"
+if [ "${old}" != "${new}" ]; then
+ echo "ERROR: crc mismatch! ${old} ${new}" >> $OUT
+else
+ echo "crc did not change." >> $OUT
+fi
+rm -f $TMPFILE
+
+cmp -s $OUT $EXP
+status=$?
+
+if [ "$status" = 0 ] ; then
+ echo "$test_name: $test_description: ok"
+ touch $test_name.ok
+else
+ echo "$test_name: $test_description: failed"
+ diff $DIFF_OPTS $EXP $OUT > $test_name.failed
+fi
+
+unset FSCK_OPT OUT EXP old new status TIMEOUT
Regression test for the previous patch. The image has group descriptors that force bitmap and inode table relocation, so e2fsck -fn fails its writes on the read-only test file and reaches the write-error retry loop in flush_cached_blocks() with a handler registered. Two departures from the usual f_* shape, both because the bug is a hang rather than a wrong answer. The e2fsck run is wrapped in timeout(1). A deadlocked e2fsck ignores SIGTERM, so without a bound this test does not fail against an affected build, it stops the suite indefinitely. The probe-then-use form is taken from tests/r_corrupt_fs/script, with -k so the SIGTERM escalates to SIGKILL. The transcript is not compared. It is about a thousand lines of repeated "Error writing block N" that say nothing about this bug and would need updating whenever those messages change. The test records the exit status and that -n left the image unmodified, which is what it is actually asserting. On an affected build the diff is -Exit status is 12 +Exit status is 137 Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com> --- tests/f_cache_mtx_deadlock/expect | 2 ++ tests/f_cache_mtx_deadlock/image.gz | Bin 0 -> 695 bytes tests/f_cache_mtx_deadlock/name | 1 + tests/f_cache_mtx_deadlock/script | 44 ++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 tests/f_cache_mtx_deadlock/expect create mode 100644 tests/f_cache_mtx_deadlock/image.gz create mode 100644 tests/f_cache_mtx_deadlock/name create mode 100644 tests/f_cache_mtx_deadlock/script