From: Matthias Goergens <matthias.goergens@gmail.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH e2fsprogs 2/2] tests: add f_cache_mtx_deadlock for the flush_cached_blocks() retry lock
Date: Tue, 22 Sep 2026 19:04:35 +0800 [thread overview]
Message-ID: <20260922110435.1528332-3-matthias.goergens@gmail.com> (raw)
In-Reply-To: <20260922110435.1528332-1-matthias.goergens@gmail.com>
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
diff --git a/tests/f_cache_mtx_deadlock/expect b/tests/f_cache_mtx_deadlock/expect
new file mode 100644
index 0000000..6dd5466
--- /dev/null
+++ b/tests/f_cache_mtx_deadlock/expect
@@ -0,0 +1,2 @@
+Exit status is 12
+crc did not change.
diff --git a/tests/f_cache_mtx_deadlock/image.gz b/tests/f_cache_mtx_deadlock/image.gz
new file mode 100644
index 0000000000000000000000000000000000000000..956a1774ec0c88a1f5ed54b968acce77c77e61b9
GIT binary patch
literal 695
zcmb2|=HPf6wK0o{xhS=uC|@r#H=W___0#zwsWQhOmM>GD&LqYnIw8w(!t6^*CuF@A
z#ykn~ir87sta`WPVBd*DI|^RLAFyZW%obzWrgLY9@f%J?;X{)m?mMYVwg_;V@Yc*<
z{`2gUCv(nyne+1b*_lBN5#6t4bW)?kHIu8oEAIq*EiSIV|K&{eHp{B-w_1bL)X)FD
zTTylA#O1f?xAt#Os7em6&APTyKlWc$QU2>6=hb)D?=F3C?#SYg^6Ae~*y4AVKYsey
z-e!-<m)Gy>@8$m~eEjY3%KhaJzwA5rd4^~0*X4qr)_?W(j(fkzxs>m^<htU$-#^|-
ztNhn&6LP)zaB17?J1^!&N!DEWu<ymIVqS$%@Bad?ng2SkvlL_KFb)4NkUj68;<cK;
z&TI1iI<H~<)gHn9m4BnyOZlYQ74;og7yti$BWQX<c+{Huj;${L1zs!vb$(~=^4EDy
z>aX?)`PcGEwTtRIzOMYIc&+HK^BU1#?Gf5v`8V2Kwm%ZJw7%o&>iUkaJO3$O6aUp7
zQTwYsV)a-4jn`htC)KX3@7NmlUm$z#KgDa|zuF^Sf92n3_Ch`>_lo_ITTALYwnqLJ
zc%A*%c}@No{*BvS$R~Y$EuX{-QgGG&$S;u2+5Z%;mHl;I^ZpC}#<CakNpC?qm)3V|
zjs7o?-TzPVTHIgfH6S~Gf92oE_d-62_mzB->=pYXQkU$H%&N(j(o@@${r7vse}&N9
z%@cQD*W04L@;|%t*M(m<eSWWXw(oJ<Y~#=W{{Q_owd`->&Ci#o{xZ0bwRguq(^K~O
zKW?S}KRzq-Z}ZLK;#dFDAEbV_Kf7tq;~mOdpDr%#yJ{Kt{I`|*t2t|mSDkxlrCfUM
zieznX_0pT~>OW;^7QgzOQG5T}mh1cd{tAnq@9#hR=kNU$U-=mr7#J$7|FPD4_*#e<
HFfsrD8IOQ`
literal 0
HcmV?d00001
diff --git a/tests/f_cache_mtx_deadlock/name b/tests/f_cache_mtx_deadlock/name
new file mode 100644
index 0000000..6911823
--- /dev/null
+++ b/tests/f_cache_mtx_deadlock/name
@@ -0,0 +1 @@
+e2fsck self-deadlocks flushing the write-error cache (regression test for libext2fs CACHE_MTX retry double-lock)
diff --git a/tests/f_cache_mtx_deadlock/script b/tests/f_cache_mtx_deadlock/script
new file mode 100644
index 0000000..8de8533
--- /dev/null
+++ b/tests/f_cache_mtx_deadlock/script
@@ -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
--
2.55.0
prev parent reply other threads:[~2026-09-22 11:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 11:04 [PATCH e2fsprogs 0/2] e2fsck: fix a self-deadlock that hangs fsck on corrupt images Matthias Goergens
2026-09-22 11:04 ` [PATCH e2fsprogs 1/2] libext2fs: fix self-deadlock in flush_cached_blocks() write-error retry Matthias Goergens
2026-09-22 18:18 ` Darrick J. Wong
2026-09-22 11:04 ` Matthias Goergens [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922110435.1528332-3-matthias.goergens@gmail.com \
--to=matthias.goergens@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox