]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
block: add regression test for inflight counter
authorOmar Sandoval <osandov@fb.com>
Thu, 26 Apr 2018 07:18:22 +0000 (00:18 -0700)
committerOmar Sandoval <osandov@fb.com>
Thu, 26 Apr 2018 07:18:22 +0000 (00:18 -0700)
This is a basic sanity check for the inflight counter, which already
turned up a bug.

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

diff --git a/tests/block/017 b/tests/block/017
new file mode 100755 (executable)
index 0000000..90f187b
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+#
+# Test the inflight counter in /sys/block/$dev/inflight and /proc/diskstats.
+# Regression test for patch "blk-mq: fix sysfs inflight counter".
+#
+# 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="do I/O and check the inflight counter"
+QUICK=1
+
+requires() {
+       _have_module null_blk
+}
+
+show_inflight() {
+       awk '{ printf "sysfs reads %d\nsysfs writes %d\n", $1, $2 }' /sys/block/nullb0/inflight
+       awk '$3 == "nullb0" { print "diskstats " $12 }' /proc/diskstats
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       for ((queue_mode = 1; queue_mode <= 2; queue_mode++)) do
+               echo "queue mode $queue_mode"
+
+               modprobe -r null_blk
+               modprobe null_blk queue_mode="$queue_mode" irqmode=2 \
+                       completion_nsec=500000000 || continue
+
+               udevadm settle
+
+               dd if=/dev/nullb0 of=/dev/null bs=4096 iflag=direct count=1 status=none &
+               sleep 0.1
+               show_inflight
+
+               dd if=/dev/zero of=/dev/nullb0 bs=4096 oflag=direct count=1 status=none &
+               sleep 0.1
+               show_inflight
+
+               wait
+               show_inflight
+
+               modprobe -r null_blk
+       done
+
+       echo "Test complete"
+}
diff --git a/tests/block/017.out b/tests/block/017.out
new file mode 100644 (file)
index 0000000..c6038bb
--- /dev/null
@@ -0,0 +1,22 @@
+Running block/017
+queue mode 1
+sysfs reads 1
+sysfs writes 0
+diskstats 1
+sysfs reads 1
+sysfs writes 1
+diskstats 2
+sysfs reads 0
+sysfs writes 0
+diskstats 0
+queue mode 2
+sysfs reads 1
+sysfs writes 0
+diskstats 1
+sysfs reads 1
+sysfs writes 1
+diskstats 2
+sysfs reads 0
+sysfs writes 0
+diskstats 0
+Test complete