From: Omar Sandoval Date: Mon, 1 May 2017 19:31:16 +0000 (-0700) Subject: block: stress test device hotplugging X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=aa36d5e716bcc8df19f4fdac8f54ba740d0e771a;p=users%2Fsagi%2Fblktests.git block: stress test device hotplugging Based on my old stress_test_scsi_debug.sh script. Signed-off-by: Omar Sandoval --- diff --git a/common/rc b/common/rc index 5593993..9ba3458 100644 --- a/common/rc +++ b/common/rc @@ -44,6 +44,10 @@ _have_program() { fi } +_have_scsi_debug() { + _have_module scsi-debug +} + _have_loop() { _have_module loop && _have_program losetup } diff --git a/tests/block/001 b/tests/block/001 new file mode 100755 index 0000000..1c7ef2f --- /dev/null +++ b/tests/block/001 @@ -0,0 +1,67 @@ +#!/bin/bash +# +# Stress test device hotplugging. Deletes and rescans several scsi-debug +# devices in parallel. Regression test for commit 165a5e22fafb ("block: Move +# bdi_unregister() to del_gendisk()"). +# +# Copyright (C) 2017 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 . + +TEST_GROUPS=(block auto quick hotplug) + +prepare() { + _have_scsi_debug +} + +stress_scsi_debug() { + modprobe -r scsi_debug + modprobe scsi_debug "$@" + + targets=() + for host in /sys/class/scsi_host/*; do + if [[ "$(cat "${host}/proc_name")" = scsi_debug ]]; then + host="$(basename "${host}")" + for target in "/sys/class/scsi_device/${host#host}:"*; do + targets+=("$(basename "${target}")") + done + fi + done + + for target in "${targets[@]}"; do + ( + host="${target%%:*}" + scan="${target#*:}" + scan="${scan//:/ }" + for ((i = 0; i < 100; i++)); do + echo "${scan}" > "/sys/class/scsi_host/host${host}/scan" + echo 1 > "/sys/class/scsi_device/${target}/device/delete" + done + ) & + done + wait + modprobe -r scsi_debug +} + +test() { + echo "Running ${TEST_NAME}" + + echo "Stressing sd" + stress_scsi_debug add_host=4 num_tgts=1 ptype=0 + + echo "Stressing sr" + stress_scsi_debug add_host=4 num_tgts=1 ptype=5 + + echo "Test complete" +} diff --git a/tests/block/001.out b/tests/block/001.out new file mode 100644 index 0000000..a8e968c --- /dev/null +++ b/tests/block/001.out @@ -0,0 +1,4 @@ +Running block/001 +Stressing sd +Stressing sr +Test complete diff --git a/tests/block/category b/tests/block/category new file mode 100644 index 0000000..92d8e56 --- /dev/null +++ b/tests/block/category @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Generic block layer tests. +# +# Copyright (C) 2017 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 . + +. common/rc + +prepare() { + return 0 +} + +prepare_device() { + return 0 +}