Linux block layer
 help / color / mirror / Atom feed
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Daniel Wagner <dwagner@suse.de>
Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org
Subject: Re: [PATCH blktests 07/10] common/nvme: support the ports of a remote target
Date: Wed, 11 Nov 2026 19:30:27 +0900	[thread overview]
Message-ID: <avRDFXYVmzax74cy@shinmob> (raw)
In-Reply-To: <20261104-nvme-target-control-v1-7-b31b40537bb4@suse.de>

On Nov 04, 2026 / 17:44, Daniel Wagner wrote:
> With NVME_TARGET_CONTROL the port helpers still use the local nvmet
> configfs. _create_nvmet_port, _remove_nvmet_port and
> _setup_nvmet_port_ana write to it. _get_nvmet_ports and
> _get_nvmet_port_params read from it. The ports of a remote subsystem
> are not there. _nvmet_target_setup doesn't pass the number of ports to
> the script, and _nvmet_target_add_ports only reports that add-ports is a
> stub. The tests which use more than one port don't work with a remote
> target, e.g. nvme/057 finds no port and connects to none.
> 
> Use the port commands of the script instead: setup --ports, add-ports,
> add-port, remove-port, list-ports, show-port and set-ana, with --tls or
> --force-tls for the TLS mode. _nvme_connect_subsys finds the port of the
> subsystem with list-ports, as it does with the local target. If the
> script lists no port, e.g. for a target which is configured already, it
> connects to the address config shows, as before.
> 
> Document the port commands in running-tests.md.
> 
> Signed-off-by: Daniel Wagner <dwagner@suse.de>
[...]
> diff --git a/common/nvme b/common/nvme
> index dfe85b6e281f..698d6bf780ef 100644
> --- a/common/nvme
> +++ b/common/nvme
> @@ -888,20 +888,21 @@ _nvme_connect_subsys() {
>  		esac
>  	done
>  
> +	if [[ -z "${port}" ]]; then
> +		local ports
> +
> +		_get_nvmet_ports "${subsysnqn}" ports
> +		port="${ports[0]##*/}"
> +	fi
>  	if [[ -n "${nvme_target_control}" && -z "${port}" ]]; then
> +		# The target doesn't list ports, e.g. it is configured already.
>  		ARGS+=(--transport "$(${nvme_target_control} config --show-trtype)")
>  		ARGS+=(--traddr "${def_traddr}")
>  		ARGS+=(--trsvcid "${def_trsvcid}")
>  	else
>  		if [[ -z "${port}" ]]; then
> -			local ports
> -
> -			_get_nvmet_ports "${subsysnqn}" ports
> -			port="${ports[0]##*/}"
> -			if [[ -z "${port}" ]]; then
> -				echo "WARNING: no port found"
> -				return 1
> -			fi
> +			echo "WARNING: no port found"
> +			return 1
>  		fi
>  		_get_nvmet_port_params "${port}" ARGS
>  	fi
> @@ -1079,6 +1080,18 @@ _fc_host_traddr() {
>  	printf "nn-%s:pn-%s" "$(_host_wwnn $port)" "$(_host_wwpn $port)"
>  }
>  
> +# Print the nvme-target-control option for the TLS mode of a port.
> +_nvme_target_control_tls() {
> +	case "$1" in
> +	not-required)
> +		echo "--tls"
> +		;;
> +	required)
> +		echo "--force-tls"
> +		;;
> +	esac
> +}
> +
>  _create_nvmet_port() {
>  	local tls="${1:-none}"
>  	local host_port="${2:-0}"
> @@ -1088,6 +1101,13 @@ _create_nvmet_port() {
>  	local trsvcid="${def_trsvcid}"
>  	local portcfs
>  
> +	if [[ -n "${nvme_target_control}" ]]; then
> +		# shellcheck disable=SC2046

I think the shellcheck exception above can be by,

> +		"${nvme_target_control}" add-port \
> +			$(_nvme_target_control_tls "${tls}")

adding double quotations in the line above.

			"$(_nvme_target_control_tls "${tls}")"

> +		return
> +	fi
> +
>  	local port
>  	for ((port = 0; ; port++)); do
>  		if [[ ! -e "${NVMET_CFS}/ports/${port}" ]]; then
> @@ -1157,6 +1177,12 @@ _setup_nvmet_port_ana() {
>  	local cfsport="${NVMET_CFS}/ports/${port}"
>  	local anaport="${cfsport}/ana_groups/${anagrpid}"
>  
> +	if [[ -n "${nvme_target_control}" ]]; then
> +		"${nvme_target_control}" set-ana --port "${port}" \
> +			--grpid "${anagrpid}" --state "${anastate}"
> +		return
> +	fi
> +
>  	if [[ ! -d "${anaport}" ]] ; then
>  		if [[ "${anagrpid}" -eq 1 ]]; then
>  			echo "FAIL target setup failed, ANA not supported"
> @@ -1173,6 +1199,11 @@ _remove_nvmet_port() {
>  	local cfsport="${NVMET_CFS}/ports/${port}"
>  	local a
>  
> +	if [[ -n "${nvme_target_control}" ]]; then
> +		"${nvme_target_control}" remove-port --port "${port}"
> +		return
> +	fi
> +
>  	if [[ "${nvme_trtype}" == "fc" ]]; then
>  		_nvme_fcloop_del_tport "$(_remote_wwnn "$port")" \
>  				       "$(_remote_wwpn "$port")"
> @@ -1446,6 +1477,13 @@ _get_nvmet_ports() {
>  	local -n nvmet_ports="$2"
>  	local cfs_path="${NVMET_CFS}/ports"
>  
> +	if [[ -n "${nvme_target_control}" ]]; then
> +		mapfile -t -O "${#nvmet_ports[@]}" nvmet_ports < <(
> +			"${nvme_target_control}" list-ports \
> +				--subsysnqn "${nvmet_subsysnqn}")
> +		return
> +	fi
> +
>  	for port in "${cfs_path}/"*; do
>  		if [[ -e "${port}/subsystems/${nvmet_subsysnqn}" ]]; then
>  			nvmet_ports+=("${port##*/}")
> @@ -1473,7 +1511,12 @@ _get_nvmet_port_params() {
>  	local trsvcid="${def_trsvcid}"
>  
>  	# When port is specified, get port dependent parameter values
> -	if [[ $port != none ]]; then
> +	if [[ $port != none && -n "${nvme_target_control}" ]]; then
> +		read -r trtype traddr trsvcid < <(
> +			"${nvme_target_control}" show-port --port "${port}")
> +		[[ -n "${trsvcid}" ]] || exit 1
> +		args+=(--traddr "${traddr}")
> +	elif [[ $port != none ]]; then
>  		[[ -d "${cfs_path}" ]] || exit 1
>  		trtype=$(cat "${cfs_path}/addr_trtype")
>  		traddr=$(cat "${cfs_path}/addr_traddr")
> @@ -1621,10 +1664,13 @@ _nvmet_target_setup() {
>  			ARGS+=(--ctrlkey "${ctrlkey}")
>  		fi
>  
> +		# shellcheck disable=SC2046

Same here, I suggest to add,

>  		"${nvme_target_control}" setup \
>  					 --subsysnqn "${subsysnqn}" \
>  					 --subsys-uuid "${subsys_uuid:-$def_subsys_uuid}" \
>  					 --hostnqn "${def_hostnqn}" \
> +					 --ports "${num_ports}" \
> +					 $(_nvme_target_control_tls "${tls}") \

double quotations in the line above.

>  					 "${ARGS[@]}" &> /dev/null
>  		p=0
>  		while (( p < num_ports )); do
> @@ -1719,19 +1765,20 @@ _nvmet_target_add_ports() {
>  			ARGS+=(--ctrlkey "${ctrlkey}")
>  		fi
>  
> +		# shellcheck disable=SC2046

Again, same here,

>  		"${nvme_target_control}" add-ports \
>  					 --ports "${num_ports}" \
>  					 --subsysnqn "${subsysnqn}" \
>  					 --subsys-uuid "${subsys_uuid:-$def_subsys_uuid}" \
>  					 --hostnqn "${def_hostnqn}" \
> -					 "${ARGS[@]}" &> /dev/null
> +					 $(_nvme_target_control_tls "${tls}") \

double qutotaions above.

> +					 "${ARGS[@]}" > /dev/null
>  		p=0
>  		while (( p < num_ports )); do
>  			# Set ports_to_hosts so that _get_fc_host_port() can return the correct host port
>  			ports_to_hosts+=("${host_port}")
>  			p=$(( p + 1 ))
>  		done
> -		echo "'${nvme_target_control} add-ports' is a stub"
>  		return
>  	fi
>  
> 
> -- 
> 2.56.0
> 

  reply	other threads:[~2026-11-11 10:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 16:44 [PATCH blktests 00/10] nvme: make NVME_TARGET_CONTROL work with remote targets Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 01/10] common/nvme: pass --ctrlkey to the target control script Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 02/10] common/nvme: wait for the namespace of a remote target Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 03/10] common/nvme: check the subsystem in _nvmet_target_add_ports Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 04/10] nvme: skip the tests which need the kernel target with a remote target Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 05/10] nvme/029: skip if the I/O exceeds the maximum transfer size Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 06/10] contrib: make nvme-target-control a standalone project Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 07/10] common/nvme: support the ports of a remote target Daniel Wagner
2026-11-11 10:30   ` Shin'ichiro Kawasaki [this message]
2026-11-04 16:44 ` [PATCH blktests 08/10] nvme/rc: change the host keys on " Daniel Wagner
2026-11-04 16:44 ` [PATCH blktests 09/10] nvme: skip the tests which need a feature the remote target lacks Daniel Wagner
2026-11-11 10:33   ` Shin'ichiro Kawasaki
2026-11-04 16:44 ` [PATCH blktests 10/10] contrib/nvme-target-control: add a NetApp ONTAP target Daniel Wagner
2026-11-11 10:36 ` [PATCH blktests 00/10] nvme: make NVME_TARGET_CONTROL work with remote targets 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=avRDFXYVmzax74cy@shinmob \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=dwagner@suse.de \
    --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