|
Harald Hoyer |
99c743 |
From 4087fd4d1a618ece6b2f8bbb1761aeccd59fcc92 Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
99c743 |
From: Hannes Reinecke <hare@suse.com>
|
|
Harald Hoyer |
99c743 |
Date: Mon, 28 Sep 2020 11:25:53 +0200
|
|
Harald Hoyer |
99c743 |
Subject: [PATCH] 95nvmf: rework parameter handling
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
Always add the nvmf.discover parameters to /etc/nvme/discovery
|
|
Harald Hoyer |
99c743 |
when parsing the dracut commandline, and rely on NVMe autodiscovery
|
|
Harald Hoyer |
99c743 |
when no parameters are given.
|
|
Harald Hoyer |
99c743 |
And modify the syntax to use a comma ',' as a separator for nvmf.discover
|
|
Harald Hoyer |
99c743 |
as the semicolon ':' is already used for the FC-NVMe transport address format.
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
Signed-off-by: Hannes Reinecke <hare@suse.de>
|
|
Harald Hoyer |
99c743 |
---
|
|
Harald Hoyer |
99c743 |
modules.d/95nvmf/module-setup.sh | 32 +++++++++++++++++++-
|
|
Harald Hoyer |
99c743 |
modules.d/95nvmf/parse-nvmf-boot-connections.sh | 39 ++++++++++++-------------
|
|
Harald Hoyer |
99c743 |
2 files changed, 50 insertions(+), 21 deletions(-)
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
diff --git a/modules.d/95nvmf/module-setup.sh b/modules.d/95nvmf/module-setup.sh
|
|
Harald Hoyer |
99c743 |
index 418b5e0c..92400c21 100755
|
|
Harald Hoyer |
99c743 |
--- a/modules.d/95nvmf/module-setup.sh
|
|
Harald Hoyer |
99c743 |
+++ b/modules.d/95nvmf/module-setup.sh
|
|
Harald Hoyer |
99c743 |
@@ -57,6 +57,31 @@ installkernel() {
|
|
Harald Hoyer |
99c743 |
cmdline() {
|
|
Harald Hoyer |
99c743 |
local _hostnqn
|
|
Harald Hoyer |
99c743 |
local _hostid
|
|
Harald Hoyer |
99c743 |
+
|
|
Harald Hoyer |
99c743 |
+ gen_nvmf_cmdline() {
|
|
Harald Hoyer |
99c743 |
+ local _dev=$1
|
|
Harald Hoyer |
99c743 |
+ local trtype
|
|
Harald Hoyer |
99c743 |
+
|
|
Harald Hoyer |
99c743 |
+ [[ -L "/sys/dev/block/$_dev" ]] || return 0
|
|
Harald Hoyer |
99c743 |
+ cd -P "/sys/dev/block/$_dev" || return 0
|
|
Harald Hoyer |
99c743 |
+ if [ -f partition ] ; then
|
|
Harald Hoyer |
99c743 |
+ cd ..
|
|
Harald Hoyer |
99c743 |
+ fi
|
|
Harald Hoyer |
99c743 |
+ for d in device/nvme* ; do
|
|
Harald Hoyer |
99c743 |
+ [ -L "$d" ] || continue
|
|
Harald Hoyer |
99c743 |
+ if readlink "$d" | grep -q nvme-fabrics ; then
|
|
Harald Hoyer |
99c743 |
+ trtype=$(cat "$d"/transport)
|
|
Harald Hoyer |
99c743 |
+ break
|
|
Harald Hoyer |
99c743 |
+ fi
|
|
Harald Hoyer |
99c743 |
+ done
|
|
Harald Hoyer |
99c743 |
+
|
|
Harald Hoyer |
99c743 |
+ [ -z "$trtype" ] && return 0
|
|
Harald Hoyer |
99c743 |
+ nvme list-subsys ${PWD##*/} | while read x dev trtype traddr host_traddr state ana; do
|
|
Harald Hoyer |
99c743 |
+ [ "$trtype" != "${trtype#NQN}" ] && continue
|
|
Harald Hoyer |
99c743 |
+ echo -n " nvmf.discover=$trtype,${traddr#traddr=},${host_traddr#host_traddr=}"
|
|
Harald Hoyer |
99c743 |
+ done
|
|
Harald Hoyer |
99c743 |
+ }
|
|
Harald Hoyer |
99c743 |
+
|
|
Harald Hoyer |
99c743 |
if [ -f /etc/nvme/hostnqn ] ; then
|
|
Harald Hoyer |
99c743 |
_hostnqn=$(cat /etc/nvme/hostnqn)
|
|
Harald Hoyer |
99c743 |
echo -n " nvmf.hostnqn=${_hostnqn}"
|
|
Harald Hoyer |
99c743 |
@@ -65,7 +90,12 @@ cmdline() {
|
|
Harald Hoyer |
99c743 |
_hostid=$(cat /etc/nvme/hostid)
|
|
Harald Hoyer |
99c743 |
echo -n " nvmf.hostid=${_hostid}"
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
- echo ""
|
|
Harald Hoyer |
99c743 |
+
|
|
Harald Hoyer |
99c743 |
+ [[ $hostonly ]] || [[ $mount_needs ]] && {
|
|
Harald Hoyer |
99c743 |
+ pushd . >/dev/null
|
|
Harald Hoyer |
99c743 |
+ for_each_host_dev_and_slaves gen_nvmf_cmdline
|
|
Harald Hoyer |
99c743 |
+ popd >/dev/null
|
|
Harald Hoyer |
99c743 |
+ }
|
|
Harald Hoyer |
99c743 |
}
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
# called by dracut
|
|
Harald Hoyer |
99c743 |
diff --git a/modules.d/95nvmf/parse-nvmf-boot-connections.sh b/modules.d/95nvmf/parse-nvmf-boot-connections.sh
|
|
Harald Hoyer |
99c743 |
index 0ed53a81..3ff731f1 100755
|
|
Harald Hoyer |
99c743 |
--- a/modules.d/95nvmf/parse-nvmf-boot-connections.sh
|
|
Harald Hoyer |
99c743 |
+++ b/modules.d/95nvmf/parse-nvmf-boot-connections.sh
|
|
Harald Hoyer |
99c743 |
@@ -3,14 +3,14 @@
|
|
Harald Hoyer |
99c743 |
# Supported formats:
|
|
Harald Hoyer |
99c743 |
# nvmf.hostnqn=<hostnqn>
|
|
Harald Hoyer |
99c743 |
# nvmf.hostid=<hostid>
|
|
Harald Hoyer |
99c743 |
-# nvmf.discover=<transport>:<traddr>:<host-traddr>:<trsvcid>
|
|
Harald Hoyer |
99c743 |
+# nvmf.discover=<transport>,<traddr>,<host-traddr>,<trsvcid>
|
|
Harald Hoyer |
99c743 |
#
|
|
Harald Hoyer |
99c743 |
# Examples:
|
|
Harald Hoyer |
99c743 |
# nvmf.hostnqn=nqn.2014-08.org.nvmexpress:uuid:37303738-3034-584d-5137-333230423843
|
|
Harald Hoyer |
99c743 |
-# nvmf.discover=rdma:192.168.1.3::4420
|
|
Harald Hoyer |
99c743 |
-# nvmf.discover=tcp:192.168.1.3::4420
|
|
Harald Hoyer |
99c743 |
-# nvmf.discover=tcp:192.168.1.3
|
|
Harald Hoyer |
99c743 |
-# nvmf.discover=fc:auto
|
|
Harald Hoyer |
99c743 |
+# nvmf.discover=rdma,192.168.1.3,,4420
|
|
Harald Hoyer |
99c743 |
+# nvmf.discover=tcp,192.168.1.3,,4420
|
|
Harald Hoyer |
99c743 |
+# nvmf.discover=tcp,192.168.1.3
|
|
Harald Hoyer |
99c743 |
+# nvmf.discover=fc,nn-0x200400a098d85236:pn-0x201400a098d85236,nn-0x200000109b7db455:pn-0x100000109b7db455
|
|
Harald Hoyer |
99c743 |
#
|
|
Harald Hoyer |
99c743 |
# Note: FC does autodiscovery, so typically there is no need to
|
|
Harald Hoyer |
99c743 |
# specify any discover parameters for FC.
|
|
Harald Hoyer |
99c743 |
@@ -25,11 +25,6 @@ fi
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
initqueue --onetime modprobe --all -b -q nvme nvme_tcp nvme_core nvme_fabrics
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
-traddr="none"
|
|
Harald Hoyer |
99c743 |
-trtype="none"
|
|
Harald Hoyer |
99c743 |
-hosttraddr="none"
|
|
Harald Hoyer |
99c743 |
-trsvcid=4420
|
|
Harald Hoyer |
99c743 |
-
|
|
Harald Hoyer |
99c743 |
validate_ip_conn() {
|
|
Harald Hoyer |
99c743 |
if ! getargbool 0 rd.neednet ; then
|
|
Harald Hoyer |
99c743 |
warn "$trtype transport requires rd.neednet=1"
|
|
Harald Hoyer |
99c743 |
@@ -59,8 +54,12 @@ validate_ip_conn() {
|
|
Harald Hoyer |
99c743 |
}
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
parse_nvmf_discover() {
|
|
Harald Hoyer |
99c743 |
+ traddr="none"
|
|
Harald Hoyer |
99c743 |
+ trtype="none"
|
|
Harald Hoyer |
99c743 |
+ hosttraddr="none"
|
|
Harald Hoyer |
99c743 |
+ trsvcid=4420
|
|
Harald Hoyer |
99c743 |
OLDIFS="$IFS"
|
|
Harald Hoyer |
99c743 |
- IFS=:
|
|
Harald Hoyer |
99c743 |
+ IFS=,
|
|
Harald Hoyer |
99c743 |
set $1
|
|
Harald Hoyer |
99c743 |
IFS="$OLDIFS"
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
@@ -101,7 +100,11 @@ parse_nvmf_discover() {
|
|
Harald Hoyer |
99c743 |
if [ "$trtype" = "tcp" ]; then
|
|
Harald Hoyer |
99c743 |
validate_ip_conn
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
- echo "--transport=$trtype --traddr=$traddr --host-traddr=$hosttraddr --trsvcid=$trsvcid" >> /etc/nvme/discovery.conf
|
|
Harald Hoyer |
99c743 |
+ if [ "$trtype" = "fc" ] ; then
|
|
Harald Hoyer |
99c743 |
+ echo "--transport=$trtype --traddr=$traddr --host-traddr=$hosttraddr" >> /etc/nvme/discovery.conf
|
|
Harald Hoyer |
99c743 |
+ else
|
|
Harald Hoyer |
99c743 |
+ echo "--transport=$trtype --traddr=$traddr --host-traddr=$hosttraddr --trsvcid=$trsvcid" >> /etc/nvme/discovery.conf
|
|
Harald Hoyer |
99c743 |
+ fi
|
|
Harald Hoyer |
99c743 |
}
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
nvmf_hostnqn=$(getarg nvmf.hostnqn=)
|
|
Harald Hoyer |
99c743 |
@@ -122,17 +125,13 @@ done
|
|
Harald Hoyer |
99c743 |
[ -f "/etc/nvme/hostid" ] || exit 0
|
|
Harald Hoyer |
99c743 |
|
|
Harald Hoyer |
99c743 |
if [ -f "/etc/nvme/discovery.conf" ] ; then
|
|
Harald Hoyer |
99c743 |
+ /sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
|
|
Harald Hoyer |
99c743 |
if [ "$trtype" = "tcp" ] ; then
|
|
Harald Hoyer |
99c743 |
- /sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
|
|
Harald Hoyer |
99c743 |
> /tmp/net.$ifname.did-setup
|
|
Harald Hoyer |
99c743 |
- else
|
|
Harald Hoyer |
99c743 |
- /sbin/initqueue --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
else
|
|
Harald Hoyer |
99c743 |
- if [ "$trtype" = "tcp" ] ; then
|
|
Harald Hoyer |
99c743 |
- /sbin/initqueue --settled --onetime --unique /usr/sbin/nvme connect-all -t tcp -a $traddr -s $trsvcid
|
|
Harald Hoyer |
99c743 |
- > /tmp/net.$ifname.did-setup
|
|
Harald Hoyer |
99c743 |
- else
|
|
Harald Hoyer |
99c743 |
- /sbin/initqueue --finished --unique --name nvme-fc-autoconnect echo 1 > /sys/class/fc/fc_udev_device/nvme_discovery
|
|
Harald Hoyer |
99c743 |
+ # No nvme command line arguments present, try autodiscovery
|
|
Harald Hoyer |
99c743 |
+ if [ "$trtype" = "fc" ] ; then
|
|
Harald Hoyer |
99c743 |
+ /sbin/initqueue --finished --onetime --unique --name nvme-fc-autoconnect echo 1 > /sys/class/fc/fc_udev_device/nvme_discovery
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
fi
|
|
Harald Hoyer |
99c743 |
|