]> www.infradead.org Git - users/sagi/blktests.git/commitdiff
scsi: add test that toggles cache_type
authorOmar Sandoval <osandov@fb.com>
Tue, 28 Aug 2018 22:10:06 +0000 (15:10 -0700)
committerOmar Sandoval <osandov@fb.com>
Tue, 28 Aug 2018 22:20:08 +0000 (15:20 -0700)
This is Jens' easy reproducer for
https://www.spinics.net/lists/linux-block/msg29942.html.

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

diff --git a/tests/scsi/006 b/tests/scsi/006
new file mode 100755 (executable)
index 0000000..24be06d
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+#
+# Test that changing the cache type on a SCSI disk succeeds. Regression test
+# for commit d772a65d8a6c ("Revert "scsi: core: avoid host-wide host_busy
+# counter for scsi_mq""). Without the revert, this test will hang.
+#
+# 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/>.
+
+. tests/scsi/rc
+
+DESCRIPTION="toggle SCSI cache type"
+
+QUICK=1
+
+device_requires() {
+       _test_dev_is_scsi_disk
+}
+
+test_device() {
+       echo "Running ${TEST_NAME}"
+
+       local cache_types=(
+               "write through"
+               "none"
+               "write back"
+               "write back, no read (daft)"
+       )
+       local cache_type
+       local original_cache_type
+
+       original_cache_type="$(cat "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type)"
+       for cache_type in "${cache_types[@]}"; do
+               echo "$cache_type" > "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type
+               cat "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type
+       done
+       echo "$original_cache_type" > "${TEST_DEV_SYSFS}"/device/scsi_disk/*/cache_type
+
+       echo "Test complete"
+}
diff --git a/tests/scsi/006.out b/tests/scsi/006.out
new file mode 100644 (file)
index 0000000..38d8100
--- /dev/null
@@ -0,0 +1,6 @@
+Running scsi/006
+write through
+none
+write back
+write back, no read (daft)
+Test complete
index 62033faa49061439e76b28c5236e937b73d2c2fe..e80b70395650978448944b09494e5c00161f1bb3 100644 (file)
@@ -39,6 +39,14 @@ _test_dev_is_scsi() {
        return 0
 }
 
+_test_dev_is_scsi_disk() {
+       if [[ ! -d ${TEST_DEV_SYSFS}/device/scsi_disk ]]; then
+               SKIP_REASON="$TEST_DEV is not a SCSI disk"
+               return 1
+       fi
+       return 0
+}
+
 _get_test_dev_sg() {
        echo "${TEST_DEV_SYSFS}"/device/scsi_generic/sg* | grep -Eo "sg[0-9]+"
 }