Skip to contentSkip to conversation

fc transport cleanups

PATCH In review Daniel Wagner 2 participants 7 messages Feb 12, 2024 – Feb 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover fc transport cleanups

Fixed the typos and collected the RB tags.

changes:
v2:
- typo fixes
- collected RB tags

v1:
- initial version
- https://lore.kernel.org/linux-nvme/[email protected]/

Daniel Wagner (5):
nvme/029: fix local variable declarations
nvme/rc: filter out errors from cat when reading files nvme/rc: do not issue warnings on cleanup when using fc transport nvme/rc: do not issue errors when disconnecting when using fc
transport
nvme/rc: revert nvme-cli context tracking

 tests/nvme/029 |  2 +-
 tests/nvme/rc  | 73 +++++---------------------------------------------
 2 files changed, 8 insertions(+), 67 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/5 nvme/029: fix local variable declarations

The syntax for local variables declarations uses whitespace as separator and not commas:

tests/nvme/029: line 24: local: bs,': not a valid identifier tests/nvme/029: line 24: local: size,': not a valid identifier tests/nvme/029: line 24: local: `img,': not a valid identifier

---
 tests/nvme/029 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/nvme/029 +1 -1
index caed0f7ec476..db6e8b91f707 100755
@@ -21,7 +21,7 @@ test_user_io()
 	local disk="$1"
 	local start=$2
 	local cnt=$3
-	local bs, size, img, img1
+	local bs size img img1
 
 	bs="$(blockdev --getss "$disk")"
 	size=$((cnt * bs))
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/5 nvme/rc: filter out errors from cat when reading files

In reply to Daniel Wagner

When running the tests with FC as transport and the udev auto connect enabled, discovery controllers are created and destroyed while the tests are running. This races with the cleanup code and also the _find_nvme_dev() which iterates over all device entries and tries to read the connect of transport and subsysnqn sysfs attributes. Since these steps are not locked in anyway, the resources can go away in between.

Thus filter out 'cat' reporting non existing subsysnqn or transport attributes. The tests will still fail if they can't find the device etc. But without filtering these errors out the tests fail randomly.

---
 tests/nvme/rc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tests/nvme/rc +2 -2
index e0461f1cd53a..9cc83afe0668 100644
@@ -350,7 +350,7 @@ _cleanup_nvmet() {
 
 	for dev in /sys/class/nvme/nvme*; do
 		dev="$(basename "$dev")"
-		transport="$(cat "/sys/class/nvme/${dev}/transport")"
+		transport="$(cat "/sys/class/nvme/${dev}/transport" 2>/dev/null)"
 		if [[ "$transport" == "${nvme_trtype}" ]]; then
 			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
 			_nvme_disconnect_ctrl "${dev}"
@@ -840,7 +840,7 @@ _find_nvme_dev() {
 	for dev in /sys/class/nvme/nvme*; do
 		[ -e "$dev" ] || continue
 		dev="$(basename "$dev")"
-		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn")"
+		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn" 2>/dev/null)"
 		if [[ "$subsysnqn" == "$subsys" ]]; then
 			echo "$dev"
 		fi
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/5 nvme/rc: do not issue warnings on cleanup when using fc transport

In reply to Daniel Wagner

When running the tests with FC as transport and the udev auto connect enabled, discovery controllers are created and destroyed while the tests are running.

The cleanup code expects that all devices are under blktests control, but this isn't the case. So just disable the warning as it is reporting a lot of false positives.

---
 tests/nvme/rc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tests/nvme/rc +4 -1
index 9cc83afe0668..ca6a284a1e25 100644
@@ -352,7 +352,10 @@ _cleanup_nvmet() {
 		dev="$(basename "$dev")"
 		transport="$(cat "/sys/class/nvme/${dev}/transport" 2>/dev/null)"
 		if [[ "$transport" == "${nvme_trtype}" ]]; then
-			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
+			# if udev auto connect is enabled for FC we get false positives
+			if [[ "$transport" != "fc" ]]; then
+				echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
+			fi
 			_nvme_disconnect_ctrl "${dev}"
 		fi
 	done
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/5 nvme/rc: do not issue errors when disconnecting when using fc transport

In reply to Daniel Wagner

When running the tests with FC as transport and the udev auto connect enabled, discovery controllers are created and destroyed while the tests are running.

The cleanup code expects that all devices are under blktests control, but this isn't the case. Thus filter out disconnect failures as well.

---
 tests/nvme/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/nvme/rc +1 -1
index ca6a284a1e25..cdfc738d3aec 100644
@@ -356,7 +356,7 @@ _cleanup_nvmet() {
 			if [[ "$transport" != "fc" ]]; then
 				echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
 			fi
-			_nvme_disconnect_ctrl "${dev}"
+			_nvme_disconnect_ctrl "${dev}" 2>/dev/null
 		fi
 	done
 
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 5/5 nvme/rc: revert nvme-cli context tracking

In reply to Daniel Wagner

This feature is not needed anymore, after fixing nvmet-fc. The nvmet target code is able to handle parallel operations and doesn't crash anymore. Furthermore, it can't prevent from discovery controller created by the udev rules, so let's rip it out.

---
 tests/nvme/rc | 62 ---------------------------------------------------
 1 file changed, 62 deletions(-)
tests/nvme/rc +0 -62
index cdfc738d3aec..dfc4c1ef1975 100644
@@ -189,57 +189,6 @@ _nvme_calc_rand_io_size() {
 	echo "${io_size_kb}k"
 }
 
-_have_nvme_cli_context() {
-	# ignore all non-fc transports for now
-	if [[ "${nvme_trtype}" != "fc" ]] ||
-	   ! nvme connect --help 2>&1 | grep -q -- '--context=<STR>' > /dev/null; then
-		return 1
-	fi
-	return 0
-}
-
-_setup_nvme_cli() {
-	local local_wwnn="${1}"
-	local local_wwpn="${2}"
-	local remote_wwnn="${3}"
-	local remote_wwpn="${4}"
-
-	if ! _have_nvme_cli_context; then
-		return
-	fi
-
-	mkdir -p /run/nvme
-	cat >> /run/nvme/blktests.json <<-EOF
-	[
-	  {
-	    "hostnqn": "${def_hostnqn}",
-	    "hostid": "${def_hostid}",
-	    "subsystems": [
-	      {
-	        "application": "blktests",
-	        "nqn": "blktests-subsystem-1",
-	        "ports": [
-	          {
-	            "transport": "fc",
-	            "traddr": "nn-${remote_wwnn}:pn-${remote_wwpn}",
-	            "host_traddr": "nn-${local_wwnn}:pn-${local_wwpn}"
-	          }
-	        ]
-	      }
-	    ]
-	  }
-	]
-	EOF
-}
-
-_cleanup_nvme_cli() {
-	if ! _have_nvme_cli_context; then
-		return
-	fi
-
-	rm -f /run/nvme/blktests.json
-}
-
 _nvme_fcloop_add_rport() {
 	local local_wwnn="$1"
 	local local_wwpn="$2"
@@ -272,9 +221,6 @@ _setup_fcloop() {
 	local remote_wwnn="${3:-$def_remote_wwnn}"
 	local remote_wwpn="${4:-$def_remote_wwpn}"
 
-	_setup_nvme_cli "${local_wwnn}" "${local_wwpn}" \
-			"${remote_wwnn}" "${remote_wwpn}"
-
 	_nvme_fcloop_add_tport "${remote_wwnn}" "${remote_wwpn}"
 	_nvme_fcloop_add_lport "${local_wwnn}" "${local_wwpn}"
 	_nvme_fcloop_add_rport "${local_wwnn}" "${local_wwpn}" \
@@ -317,8 +263,6 @@ _cleanup_fcloop() {
 	_nvme_fcloop_del_lport "${local_wwnn}" "${local_wwpn}"
 	_nvme_fcloop_del_rport "${local_wwnn}" "${local_wwpn}" \
 			       "${remote_wwnn}" "${remote_wwpn}"
-
-	_cleanup_nvme_cli
 }
 
 _cleanup_blkdev() {
@@ -544,9 +488,6 @@ _nvme_connect_subsys() {
 	subsysnqn="$2"
 
 	ARGS=(-t "${trtype}" -n "${subsysnqn}")
-	if _have_nvme_cli_context; then
-		ARGS+=(--context="blktests")
-	fi
 	if [[ "${trtype}" == "fc" ]] ; then
 		ARGS+=(-a "${traddr}" -w "${host_traddr}")
 	elif [[ "${trtype}" != "loop" ]]; then
@@ -618,9 +559,6 @@ _nvme_discover() {
 	ARGS=(-t "${trtype}")
 	ARGS+=(--hostnqn="${def_hostnqn}")
 	ARGS+=(--hostid="${def_hostid}")
-	if _have_nvme_cli_context; then
-		ARGS+=(--context="blktests")
-	fi
 	if [[ "${trtype}" = "fc" ]]; then
 		ARGS+=(-a "${traddr}" -w "${host_traddr}")
 	elif [[ "${trtype}" != "loop" ]]; then
Signature · 1 line
2.43.0