Linux block layer
 help / color / mirror / Atom feed
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Jesse Taube <jtaubepe@redhat.com>
Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	 John Meneghini <jmeneghi@redhat.com>,
	Daniel Wagner <dwagner@suse.de>
Subject: Re: [PATCH blktests 2/2] nvme/070: Test multipath and marginal ports
Date: Fri, 14 Aug 2026 20:47:56 +0900	[thread overview]
Message-ID: <an78AkXI1SUHXBwg@shinmob> (raw)
In-Reply-To: <20260812174503.3705830-3-jtaubepe@redhat.com>

On Aug 12, 2026 / 13:45, Jesse Taube wrote:
> Add tests/nvme/070 to test various multipath and marginal port
> scenarios, while confirming the port useage and state. This test is
> intended to emulate receiving an FPIN event in a multipath environment.

The test contents are comprehensive, which looks good to me.

> 
> Suggested-by: John Meneghini <jmeneghi@redhat.com>
> Signed-off-by: Jesse Taube <jtaubepe@redhat.com>
> ---
>  tests/nvme/070     | 521 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/nvme/070.out |  43 ++++
>  2 files changed, 564 insertions(+)
>  create mode 100755 tests/nvme/070
>  create mode 100644 tests/nvme/070.out
> 
> diff --git a/tests/nvme/070 b/tests/nvme/070
> new file mode 100755
> index 0000000..a8002f8
> --- /dev/null
> +++ b/tests/nvme/070
> @@ -0,0 +1,521 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-3.0+
> +# Copyright (C) 2024 John Meneghini <jmeneghi@redhat.com>

This patch's author is Jesse, which looks inconstent with the copyright above.
Also, please reconfirm the copyright year 2024. Should it be "2026" or
"2024-2026"?

> +#
> +# Test nvme-fc marginal path handling with fcloop
> +
> +. tests/nvme/rc
> +
> +DESCRIPTION="test nvme-fc marginal path handling"
> +

...

> +# check if all link is in state and use state if optimized
> +_rport_check_opt() {
> +	local RPORT=$1 # /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9
> +	local STATE=$2 # "Online"
> +
> +	_rport_check_online "$RPORT" "$STATE"
> +	# Only optimized paths will be in use
> +	if _rport_optimized "$RPORT"; then
> +		_rport_check_use "$RPORT" "$STATE"
> +	else
> +		_rport_check_use "$RPORT" Marginal
> +	fi
> +	# Returns Success or Fail
> +}
> +
> +# check if all link is in state and use state
> +_rport_check() {
> +	local RPORT=$1 # /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9
> +	local STATE=$2 # "Online"
> +
> +	_rport_check_online "$RPORT" "$STATE"
> +	_rport_check_use "$RPORT" "$STATE"
> +	# Returns Success or Fail
> +}
> +
> +# Check if one of the marginal paths is in use
> +_rport_check_one_use_online() {
> +	local RPORTS_PATHS=("$@") #  /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9

Nit: "local -a RPORTS_PATHS" is a bit better than "local RPORTS_PATHS" to
     clarify that it is an array. There are some more local arrays in this patch
     that are declared without -a.

> +
> +	# Check if one of the online paths is in use
> +	for subsys_path in "${RPORTS_PATHS[@]}"; do
> +		# If path is Marginal, continue to the next path
> +		_rport_check_online "$subsys_path" Online || continue
> +		# One of the online paths should be in use
> +		# "!" inverts the return code, so returns false if path is in use,
> +		# running the return statement
> +		! _rport_in_use "$subsys_path" || return 0
> +	done
> +
> +	echo No FC ports are being used, expected atleast one in use when all are online in numa mode.
> +	# None of the online paths were in use
> +	return 1
> +
> +	# Returns Success or Fail
> +}
> +
> +test_set_all_online() {
> +	local IOPOLICY=$1 # "numa" "queue-depth" "round-robin"
> +	shift
> +	local -a RPORTS_PATHS=("$@") # /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9
> +
> +	for subsys_path in "${RPORTS_PATHS[@]}"; do
> +		_rport_set_online "$subsys_path" || return 1
> +		_rport_check_online "$subsys_path" Online || return 1
> +	done
> +
> +	if [ "$IOPOLICY" == "numa" ]; then
> +		_rport_check_one_use_online "${RPORTS_PATHS[@]}" || return 1
> +	else
> +		for subsys_path in "${RPORTS_PATHS[@]}"; do
> +			# Only optimized paths will be in use
> +			_rport_check_opt "$subsys_path" Online || return 1
> +		done
> +	fi
> +}

...

> +run_test() {
> +	local IOPOLICY=$1 # "numa" "queue-depth" "round-robin"
> +	shift
> +	local ARGS=("$@")
> +	local RPORTS_CNT="$(( $# / 2 ))"
> +	local -a RPORTS_PATHS # /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9
> +	local -a RPORTS_HOSTS # host1 host2
> +	local PATHS_POS # /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9
> +	local HOSTS_POS # host1 host2
> +
> +	# recrate the arrays
> +	for (( PATHS_POS=0; PATHS_POS < RPORTS_CNT; PATHS_POS++ )); do
> +		HOSTS_POS+="$(( RPORTS_CNT + PATHS_POS ))"
> +		RPORTS_PATHS+=("${ARGS[$PATHS_POS]}")
> +		RPORTS_HOSTS+=("${ARGS[$HOSTS_POS]}")
> +	done
> +
> +
> +	echo Changing FC links to online
> +	# Initial check to see if FC is operational and set ports to online

The lines below in this function have more than 80 characters and hard to read
in small terminals. I suggest to fold each of them into multiple lines.

> +	test_set_all_online "$IOPOLICY" "${RPORTS_PATHS[@]}" && echo "Set all online: pass" || echo "Set all online: fail"
> +
> +	test_set_one_host_marginal "${RPORTS_HOSTS[0]}" "${RPORTS_PATHS[@]}" "${RPORTS_HOSTS[@]}" && echo "One host marginal: pass" || echo "One host marginal: fail"
> +	test_set_all_marginal "${RPORTS_PATHS[@]}" && echo "All marginal: pass" || echo "All marginal: fail"
> +
> +	test_set_one_non_optimized_online "${RPORTS_PATHS[@]}" && echo "One remote non-optimized online: pass" || echo "One remote non-optimized online: fail"
> +	test_set_all_non_optimized_online "$IOPOLICY" "${RPORTS_PATHS[@]}" && echo "Two remote non-optimized online: pass" || echo "Two remote non-optimized online: fail"
> +
> +	test_set_all_non_one_optimized_online "${RPORTS_PATHS[@]}" && echo "Two remote non-optimized, One remote optimized: pass" || echo "Two remote non-optimized, One remote optimized: fail"
> +	test_set_all_online "$IOPOLICY" "${RPORTS_PATHS[@]}" && echo "Set all online: pass" || echo "Set all online: fail"
> +
> +	test_set_all_marginal "${RPORTS_PATHS[@]}" && echo "All marginal: pass" || echo "All marginal: fail"
> +
> +	test_set_one_optimized_online "${RPORTS_PATHS[@]}" && echo "One remote optimized online: pass" || echo "One remote optimized online: fail"
> +	test_set_two_optimized_online "$IOPOLICY" "${RPORTS_PATHS[@]}" && echo "Two remote optimized online: pass" || echo "Two remote optimized online: fail"
> +	test_set_all_online "$IOPOLICY" "${RPORTS_PATHS[@]}" && echo "All online: pass" || echo "All online: fail"
> +}
> +
> +_nvmet_get_rport() {
> +	local PORT="$1"
> +
> +	local dev
> +	for dev in /sys/class/nvme/nvme*; do
> +		grep -q "io" "$dev/cntrltype" || continue

Nit: I suggest long option --quiet instaed of short option -q.

> +		[ -e "$dev" ] || continue
> +		dev="$(basename "$dev")"
> +		grep -q traddr="$(_fc_traddr "$PORT")" "/sys/class/nvme/$dev/address" && echo "$dev" || true

Nit: same here, replacing -q with --quiet, and folding the long line
     to multiple lines.

> +	done
> +	# nvme9
> +}
> +
> +run_tests() {
> +	local SUBSYS_PATH="$1"
> +	shift
> +	local PORTS=("$@")
> +	local -a RPORTS_PATHS # /sys/devices/virtual/nvme-subsystem/nvme-subsys3/nvme9
> +	local -a RPORTS_HOSTS # host1 host2
> +	local rport
> +
> +	for port in "${PORTS[@]}"; do
> +		RPORTS_HOSTS+=("$(_get_fc_host_port "$port")")
> +		rport="$(_nvmet_get_rport "$port")"
> +		if [ -z "$rport" ]; then
> +			echo "Could not find rport for port $port"
> +			return 1
> +		fi
> +		if [[ "$( echo "$rport" | sed -n '$=' )" -gt 1 ]]; then
> +			# One traddr has multiple /sys/class/nvme/nvme devices
> +			echo "Port $port has multiple rports with address"
> +			grep  traddr="$(_fc_traddr "$port")" /sys/class/nvme/nvme*/address
> +			return 1
> +		fi
> +		RPORTS_PATHS+=( "${SUBSYS_PATH}/$rport")
> +	done
> +
> +	local IOPOLICYS="numa queue-depth round-robin"
> +	for IOPOLICY in $IOPOLICYS; do
> +		_rport_set_iopolicy "$SUBSYS_PATH" "$IOPOLICY"
> +		echo "Testing iopolicy: $IOPOLICY"
> +		run_test "$IOPOLICY" "${RPORTS_PATHS[@]}" "${RPORTS_HOSTS[@]}"
> +	done
> +}
> +
> +_find_nvme_subsys() {
> +	local subsys=$1
> +	local subsysnqn
> +	local subsys_path
> +	for subsys_path in /sys/class/nvme-subsystem/nvme-subsys*; do
> +		[ -e "$subsys_path" ] || continue
> +		subsysnqn="$(cat "${subsys_path}/subsysnqn" 2>/dev/null)"
> +		if [[ "$subsysnqn" == "$subsys" ]]; then
> +			echo "$subsys_path"
> +			return
> +		fi
> +	done
> +}
> +
> +test() {
> +	local -a ports
> +	local ns
> +	local fio_pid
> +
> +	echo "Running ${TEST_NAME}"
> +
> +	_setup_nvmet 2

When I ran this test case on the kernel without the patch series
"nvme-fc: FPIN link integrity handling", this test case just failed.
I think it should be skipped if the kernel does not have set_marginal_rport
sysfs attribute. I suggest to add the check below:

       if [[ ! -w /sys/class/fcloop/ctl/set_marginal_rport ]]; then
               SKIP_REASONS+=("fcloop does not support set_marginal_rport")
               return 1
       fi

> +
> +	_nvmet_target_setup --ports 2
> +	_nvmet_target_add_ports --host_port 1 --ports 2
> +
> +	_get_nvmet_ports "${def_subsysnqn}" ports
> +

...

  parent reply	other threads:[~2026-08-14 11:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 17:45 [PATCH blktests 0/2] Test multipath and marginal ports Jesse Taube
2026-08-12 17:45 ` [PATCH blktests 1/2] nvme: Add _setup_nvmet_port_marginal Jesse Taube
2026-08-12 19:03   ` John Meneghini
2026-08-14 11:28   ` Shin'ichiro Kawasaki
2026-08-12 17:45 ` [PATCH blktests 2/2] nvme/070: Test multipath and marginal ports Jesse Taube
2026-08-12 19:03   ` John Meneghini
2026-08-14 11:47   ` Shin'ichiro Kawasaki [this message]
2026-08-14 11:24 ` [PATCH blktests 0/2] " Shin'ichiro Kawasaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=an78AkXI1SUHXBwg@shinmob \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=dwagner@suse.de \
    --cc=jmeneghi@redhat.com \
    --cc=jtaubepe@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox