From a80d90e17e6e9b53212eaeb1051b38da58eb668a Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Thu, 26 Apr 2018 00:18:22 -0700 Subject: [PATCH] block: add regression test for inflight counter This is a basic sanity check for the inflight counter, which already turned up a bug. Signed-off-by: Omar Sandoval --- tests/block/017 | 60 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/017.out | 22 +++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 tests/block/017 create mode 100644 tests/block/017.out diff --git a/tests/block/017 b/tests/block/017 new file mode 100755 index 0000000..90f187b --- /dev/null +++ b/tests/block/017 @@ -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 . + +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 index 0000000..c6038bb --- /dev/null +++ b/tests/block/017.out @@ -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 -- 2.51.0