[blktests v3 1/2] nvme: Add _setup_nvmet_port_marginal
Jesse Taube
jtaubepe at redhat.com
Fri Aug 28 08:30:28 PDT 2026
Adds functionality to set up a NVME port in marginal state.
This is useful for testing the behavior of the NVME driver when a port
is in a marginal state.
Signed-off-by: Jesse Taube <jtaubepe at redhat.com>
Reviewed-by: John Meneghini <jmeneghi at redhat.com>
Tested-by: John Meneghini <jmeneghi at redhat.com>
---
V1 -> V2:
- Added john's review and test-by tags
- Use != instead of ! ==
- Wrap lines over 80col
V2 -> V3:
- No change
---
common/nvme | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/common/nvme b/common/nvme
index f399937..a6d6b28 100644
--- a/common/nvme
+++ b/common/nvme
@@ -153,6 +153,16 @@ _nvme_fcloop_add_tport() {
echo "wwnn=${wwnn},wwpn=${wwpn}" > ${loopctl}/add_target_port
}
+_nvme_fcloop_set_rport_marginal() {
+ local wwnn="$1"
+ local wwpn="$2"
+ local marginal="$3"
+ local loopctl=/sys/class/fcloop/ctl
+
+ echo "wwnn=${wwnn},wwpn=${wwpn},marginal=${marginal}" \
+ > ${loopctl}/set_marginal_rport
+}
+
_nvme_fcloop_del_rport() {
local local_wwnn="$1"
local local_wwpn="$2"
@@ -763,6 +773,27 @@ _create_nvmet_port() {
echo "${port}"
}
+_setup_nvmet_port_marginal() {
+ local -i port="$1"
+ local state="${2}"
+
+ if [[ "${nvme_trtype}" != "fc" ]]; then
+ echo "FAIL _setup_nvmet_port_marginal() only supports fc transport"
+ exit 1
+ fi
+
+ if [[ "${state}" == "live" ]]; then
+ _nvme_fcloop_set_rport_marginal "$(_remote_wwnn $port)" \
+ "$(_remote_wwpn $port)" 0
+ elif [[ "${state}" == "marginal" ]]; then
+ _nvme_fcloop_set_rport_marginal "$(_remote_wwnn $port)" \
+ "$(_remote_wwpn $port)" 1
+ else
+ echo "FAIL _setup_nvmet_port_marginal() invalid state: ${state}"
+ exit 1
+ fi
+}
+
_setup_nvmet_port_ana() {
local port="$1"
local anagrpid="${2:-$def_anagrpid}"
--
2.54.0
More information about the Linux-nvme
mailing list