#!/bin/bash
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2016-2018 Western Digital Corporation or its affiliates

. tests/srp/rc

DESCRIPTION="Block I/O on top of multipath concurrently with logout and login"
TIMED=1

test_disconnect_repeatedly() {
	local dev fio_status m

	use_blk_mq y y || return $?
	dev=$(get_bdev 0) || return $?
	# Hold $dev
	exec 3< "$dev"
	simulate_network_failure_loop "$dev" "$TIMEOUT" &
	run_fio --verify=md5 --rw=randwrite --bs=4K --loops=10000 \
		--ioengine=libaio --iodepth=64 --iodepth_batch=32 \
		--group_reporting --sync=1 --direct=1 --filename="$dev" \
		--name=data-integrity-test-06 --thread --numjobs=1 \
		--runtime="${TIMEOUT}" \
		--output="${RESULTS_DIR}/srp/fio-output-011.txt" \
		>>"$FULL"
	fio_status=$?
	wait
	# Release $dev
	exec 3<&-
	log_in
	return $fio_status
}

test() {
	: "${TIMEOUT:=30}"
	trap 'trap "" EXIT; teardown' EXIT
	setup && test_disconnect_repeatedly && echo Passed
}
