From: Omar Sandoval Date: Tue, 28 Aug 2018 22:10:06 +0000 (-0700) Subject: scsi: add test that toggles cache_type X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9e22384bc362d0c782bc0a23afb05eb5b9aa36f5;p=users%2Fsagi%2Fblktests.git scsi: add test that toggles cache_type This is Jens' easy reproducer for https://www.spinics.net/lists/linux-block/msg29942.html. Signed-off-by: Omar Sandoval --- diff --git a/tests/scsi/006 b/tests/scsi/006 new file mode 100755 index 0000000..24be06d --- /dev/null +++ b/tests/scsi/006 @@ -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 . + +. 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 index 0000000..38d8100 --- /dev/null +++ b/tests/scsi/006.out @@ -0,0 +1,6 @@ +Running scsi/006 +write through +none +write back +write back, no read (daft) +Test complete diff --git a/tests/scsi/rc b/tests/scsi/rc index 62033fa..e80b703 100644 --- a/tests/scsi/rc +++ b/tests/scsi/rc @@ -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]+" }