sw_hotplug: revert "sw_hotplug: avoid hotplug timeouts"
This reverts commit 95aa1a7337
,
which introduced a race between timeout command
and reading its subprocess PID.
Change-Id: I4450449f8bd3fa5a71a11e5ea445dce360a4ec06
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16510
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
827a01135c
commit
2013094ce3
@ -8,9 +8,6 @@ rootdir=$(readlink -f $testdir/../..)
|
|||||||
source $rootdir/scripts/common.sh
|
source $rootdir/scripts/common.sh
|
||||||
source $rootdir/test/common/autotest_common.sh
|
source $rootdir/test/common/autotest_common.sh
|
||||||
|
|
||||||
export PYTHONPATH="$rootdir/examples/nvme/hotplug/"
|
|
||||||
rpc_py=$rootdir/scripts/rpc.py
|
|
||||||
|
|
||||||
# Pci bus hotplug
|
# Pci bus hotplug
|
||||||
# Helper function to remove/attach cotrollers
|
# Helper function to remove/attach cotrollers
|
||||||
remove_attach_helper() {
|
remove_attach_helper() {
|
||||||
@ -19,6 +16,12 @@ remove_attach_helper() {
|
|||||||
local use_bdev=$3
|
local use_bdev=$3
|
||||||
local dev
|
local dev
|
||||||
|
|
||||||
|
# We need to make sure we wait long enough for hotplug to initialize the devices
|
||||||
|
# and start IO - if we start removing devices before that happens we will end up
|
||||||
|
# stepping on hotplug's toes forcing it to fail to report proper count of given
|
||||||
|
# events.
|
||||||
|
sleep "$hotplug_wait"
|
||||||
|
|
||||||
while ((hotplug_events--)); do
|
while ((hotplug_events--)); do
|
||||||
for dev in "${nvmes[@]}"; do
|
for dev in "${nvmes[@]}"; do
|
||||||
echo 1 > "/sys/bus/pci/devices/$dev/remove"
|
echo 1 > "/sys/bus/pci/devices/$dev/remove"
|
||||||
@ -69,29 +72,30 @@ remove_attach_helper() {
|
|||||||
run_hotplug() {
|
run_hotplug() {
|
||||||
trap 'killprocess $hotplug_pid; exit 1' SIGINT SIGTERM EXIT
|
trap 'killprocess $hotplug_pid; exit 1' SIGINT SIGTERM EXIT
|
||||||
|
|
||||||
test_time=$((hotplug_events * hotplug_wait * nvme_count))
|
"$SPDK_EXAMPLE_DIR/hotplug" \
|
||||||
|
|
||||||
# Hotplug may sometimes hang, so start it via timeout command.
|
|
||||||
timeout -k 2s $((test_time + hotplug_wait)) "$SPDK_EXAMPLE_DIR/hotplug" \
|
|
||||||
-i 0 \
|
-i 0 \
|
||||||
-t $((test_time)) \
|
-t $((hotplug_events * hotplug_wait + hotplug_wait * 3)) \
|
||||||
-n $((hotplug_events * nvme_count)) \
|
-n $((hotplug_events * nvme_count)) \
|
||||||
-r $((hotplug_events * nvme_count)) \
|
-r $((hotplug_events * nvme_count)) \
|
||||||
-l warning --wait-for-rpc &
|
-l warning &
|
||||||
timeout_pid=$!
|
hotplug_pid=$!
|
||||||
hotplug_pid=$(ps -o pid= --ppid "$timeout_pid")
|
|
||||||
|
|
||||||
# Make sure Hotplug started before removing and inserting devices.
|
|
||||||
waitforlisten "$hotplug_pid"
|
|
||||||
|
|
||||||
$rpc_py --plugin hotplug_plugin perform_tests
|
|
||||||
|
|
||||||
remove_attach_helper "$hotplug_events" "$hotplug_wait" false
|
remove_attach_helper "$hotplug_events" "$hotplug_wait" false
|
||||||
|
|
||||||
trap - SIGINT SIGTERM EXIT
|
# Wait in case hotplug app is lagging behind
|
||||||
|
# and kill it, if it hung.
|
||||||
|
sleep $hotplug_wait
|
||||||
|
|
||||||
# Check timeout return code.
|
if ! kill -0 "$hotplug_pid"; then
|
||||||
wait "$timeout_pid"
|
# hotplug already finished, check for the error code.
|
||||||
|
wait "$hotplug_pid"
|
||||||
|
else
|
||||||
|
echo "Killing hotplug application"
|
||||||
|
killprocess $hotplug_pid
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
trap - SIGINT SIGTERM EXIT
|
||||||
}
|
}
|
||||||
|
|
||||||
# SPDK target hotplug
|
# SPDK target hotplug
|
||||||
|
Loading…
Reference in New Issue
Block a user