It attempts to connect and disconnect the rnbd service on localhost. Actually, It also reveals a real kernel issue[0]. Please note that currently, only RTRS over RXE is supported. [0] https://lore.kernel.org/linux-rdma/20241231013416.1290920-1-lizhijian@xxxxxxxxxxx/ Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx> --- V3: new patch, add a seperate basic rnbd test and simplify the _start_rnbd_client Copy to the RDMA/rtrs guys: Cc: Jack Wang <jinpu.wang@xxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxx> Cc: Leon Romanovsky <leon@xxxxxxxxxx> Cc: "Md. Haris Iqbal" <haris.iqbal@xxxxxxxxx> Signed-off-by: Li Zhijian <lizhijian@xxxxxxxxxxx> --- tests/rnbd/001 | 39 +++++++++++++++++++++++++++++++++++ tests/rnbd/001.out | 2 ++ tests/rnbd/rc | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+) create mode 100755 tests/rnbd/001 create mode 100644 tests/rnbd/001.out create mode 100644 tests/rnbd/rc diff --git a/tests/rnbd/001 b/tests/rnbd/001 new file mode 100755 index 000000000000..ace2f8ea8a2b --- /dev/null +++ b/tests/rnbd/001 @@ -0,0 +1,39 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved. +# +# Basic RNBD test +# +. 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 + loop_dev="$(losetup -f)" + + if _start_rnbd_client "${loop_dev}"; then + sleep 0.5 + _stop_rnbd_client || echo "Failed to disconnect rnbd" + else + echo "Failed to connect rnbd" + 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..1cf98ad5c498 --- /dev/null +++ b/tests/rnbd/rc @@ -0,0 +1,51 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (c) 2024 FUJITSU LIMITED. All Rights Reserved. +# +# RNBD tests. + +. common/rc +. common/multipath-over-rdma + +_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() { + 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 +} + +_stop_rnbd_client() { + local s sessions + + sessions=$(ls -d /sys/block/rnbd* 2>/dev/null) + for s in $sessions + do + grep -qx blktest "$s"/rnbd/session && echo "normal" > "$s"/rnbd/unmap_device + done +} + +_start_rnbd_client() { + local blkdev=$1 + + # Stop potential remaining blktest sessions first + _stop_rnbd_client + echo "sessname=blktest path=ip:$def_traddr device_path=$blkdev" > /sys/devices/virtual/rnbd-client/ctl/map_device +} -- 2.47.0