diff mbox series

[blktests,v2,1/2] tests/rnbd: Implement RNBD regression test

Message ID 20241225093751.307267-1-lizhijian@fujitsu.com (mailing list archive)
State Not Applicable
Headers show
Series [blktests,v2,1/2] tests/rnbd: Implement RNBD regression test | expand

Commit Message

Li Zhijian Dec. 25, 2024, 9:37 a.m. UTC
This test case has been in my possession for quite some time.
I am upstreaming it now because it has once again detected a regression in
a recent kernel release [1].

It's just stupid to connect and disconnect RNBD on localhost and expect
no dmesg exceptions, with some attempts actually succeeding.

Please note that currently, only RTRS over RXE is supported.

[1] https://lore.kernel.org/linux-rdma/20241223025700.292536-1-lizhijian@fujitsu.com/

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
---
V2:
  - address comments from Shinichiro
  - minor fixes

Copy to the RDMA/rtrs guys:

Cc: Jack Wang <jinpu.wang@ionos.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: "Md. Haris Iqbal" <haris.iqbal@ionos.com>
---
 tests/rnbd/001     | 47 +++++++++++++++++++++++++++++++++
 tests/rnbd/001.out |  2 ++
 tests/rnbd/rc      | 66 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+)
 create mode 100755 tests/rnbd/001
 create mode 100644 tests/rnbd/001.out
 create mode 100644 tests/rnbd/rc
diff mbox series

Patch

diff --git a/tests/rnbd/001 b/tests/rnbd/001
new file mode 100755
index 000000000000..ef8dff93a94a
--- /dev/null
+++ b/tests/rnbd/001
@@ -0,0 +1,47 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+#
+# Regression test for the following patch
+#  RDMA/ulp: Add missing deinit() call
+#
+# It assists in detecting a 'list_add corruption' kernel warning by repeatedly
+# connecting and disconnecting the RNBD.
+#
+. tests/rnbd/rc
+
+DESCRIPTION="Start Stop RNBD"
+CHECK_DMESG=1
+QUICK=1
+
+requires() {
+	_have_rnbd
+	_have_loop
+}
+
+test_start_stop()
+{
+	_setup_rnbd || return
+
+	local loop_dev i j=0
+	loop_dev="$(losetup -f)"
+
+	for ((i=0;i<100;i++))
+	do
+		_start_rnbd_client "${loop_dev}" &>/dev/null &&
+		_stop_rnbd_client &>/dev/null && ((j++))
+	done
+
+	# We expect at least 10% start/stop successfully
+	if [[ $j -lt 10 ]]; then
+		echo "Failed: $j/$i"
+	fi
+
+	_cleanup_rnbd
+}
+
+test() {
+	echo "Running ${TEST_NAME}"
+	test_start_stop
+	echo "Test complete"
+}
diff --git a/tests/rnbd/001.out b/tests/rnbd/001.out
new file mode 100644
index 000000000000..c1f9980d0f7b
--- /dev/null
+++ b/tests/rnbd/001.out
@@ -0,0 +1,2 @@ 
+Running rnbd/001
+Test complete
diff --git a/tests/rnbd/rc b/tests/rnbd/rc
new file mode 100644
index 000000000000..577cdbad61ef
--- /dev/null
+++ b/tests/rnbd/rc
@@ -0,0 +1,66 @@ 
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved.
+#
+# RNBD tests.
+
+. common/rc
+. common/multipath-over-rdma
+
+declare RNBD_ENTRY
+
+_have_rnbd() {
+	if [[ "$USE_RXE" != 1 ]]; then
+		SKIP_REASONS+=("Only USE_RXE=1 is supported")
+	fi
+	_have_driver rdma_rxe
+	_have_driver rnbd_server
+	_have_driver rnbd_client
+}
+
+_setup_rnbd() {
+	modprobe -q rnbd_server
+	modprobe -q rnbd_client
+	start_soft_rdma
+	for i in $(rdma_network_interfaces)
+	do
+		ipv4_addr=$(get_ipv4_addr "$i")
+		if [[ -n "${ipv4_addr}" ]]; then
+			def_traddr=${ipv4_addr}
+		fi
+	done
+}
+
+_cleanup_rnbd()
+{
+	stop_soft_rdma
+}
+
+_start_rnbd_client() {
+	local a b
+	local blkdev=$1
+	local before after
+
+	before=$(ls -d /sys/block/rnbd* 2>/dev/null)
+	if ! echo "sessname=blktest path=ip:$def_traddr device_path=$blkdev" > /sys/devices/virtual/rnbd-client/ctl/map_device; then
+		return 1
+	fi
+
+	# Retrieve the newly added rnbd entry
+	after=$(ls -d /sys/block/rnbd* 2>/dev/null)
+	for a in $after
+	do
+		[[ -n "$before" ]] || break
+
+		for b in $before
+		do
+			[[ "$a" = "$b" ]] || break
+		done
+	done
+
+	RNBD_ENTRY=$a
+}
+
+_stop_rnbd_client() {
+	echo "normal" > "$RNBD_ENTRY"/rnbd/unmap_device
+}