]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block: add regression test for interruptible wait
authorOmar Sandoval <osandov@fb.com>
Tue, 24 Apr 2018 22:38:33 +0000 (15:38 -0700)
committerOmar Sandoval <osandov@fb.com>
Tue, 24 Apr 2018 22:38:33 +0000 (15:38 -0700)
Add a regression test for 1dc3039bc87a ("block: do not use interruptible
wait anywhere") using null-blk.

Signed-off-by: Omar Sandoval <osandov@fb.com>
tests/block/016 [new file with mode: 0755]
tests/block/016.out [new file with mode: 0644]

diff --git a/tests/block/016 b/tests/block/016
new file mode 100755 (executable)
index 0000000..6ccfe98
--- /dev/null
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# Test a nasty case where receiving a signal while waiting for a frozen
+# request_queue would result in EIO. Regression test for 1dc3039bc87a ("block:
+# do not use interruptible wait anywhere").
+#
+# Copyright (C) 2018 Omar Sandoval
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+DESCRIPTION="send a signal to a process waiting on a frozen queue"
+QUICK=1
+
+requires() {
+       _have_module null_blk
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       modprobe -r null_blk
+
+       modprobe null_blk queue_mode=2 irqmode=2 completion_nsec=2000000000
+
+       # Start an I/O, which will take two seconds.
+       dd if=/dev/nullb0 of=/dev/null bs=512 iflag=direct count=1 status=none &
+       sleep 0.5
+
+       # This will freeze the queue, and since we have an I/O in flight, it
+       # will stay frozen until the I/O completes.
+       echo 64 > /sys/block/nullb0/queue/nr_requests &
+       sleep 0.5
+
+       # Do an I/O, which will wait for the queue to unfreeze.
+       dd if=/dev/nullb0 of=/dev/null bs=512 iflag=direct count=1 status=none &
+       sleep 0.5
+
+       # While dd is blocked, send a signal which we know dd has a handler
+       # for.
+       kill -USR1 $!
+       wait
+
+       modprobe -r null_blk
+
+       echo "Test complete"
+}
diff --git a/tests/block/016.out b/tests/block/016.out
new file mode 100644 (file)
index 0000000..e851e8e
--- /dev/null
@@ -0,0 +1,2 @@
+Running block/016
+Test complete