|
|
9abf8c |
From f9883b51b1fafd30a91e9efda3260067a8f87ea5 Mon Sep 17 00:00:00 2001
|
|
|
9abf8c |
From: Enzo Matsumiya <ematsumiya@suse.de>
|
|
|
9abf8c |
Date: Mon, 3 Aug 2020 11:21:36 -0300
|
|
|
9abf8c |
Subject: [PATCH] 95nvmf: add NVMe over TCP support
|
|
|
9abf8c |
|
|
|
9abf8c |
Add support to boot from an NVMe over TCP device.
|
|
|
9abf8c |
|
|
|
9abf8c |
Example of supported command line formats:
|
|
|
9abf8c |
|
|
|
9abf8c |
nvme.discover=tcp:192.168.1.3::4420
|
|
|
9abf8c |
nvme.discover=tcp:192.168.1.3 # will use 4420 as default svcid
|
|
|
9abf8c |
|
|
|
9abf8c |
- Create is_nvmf() function to handle all fabrics types
|
|
|
9abf8c |
- Fix parse_nvmf_discover() to correctly use the default values
|
|
|
9abf8c |
- Auxiliary function to validate an IP connection
|
|
|
9abf8c |
- Fix inverted result for getargbool when reading "rd.nonvmf" command line parameter
|
|
|
9abf8c |
|
|
|
9abf8c |
Requires rd.neednet=1
|
|
|
9abf8c |
Requires adding/replacing STARTMODE in /etc/sysconfig/network/ifcfg-ethX to "nfsroot"
|
|
|
9abf8c |
to avoid shutdown hanging in initiator
|
|
|
9abf8c |
|
|
|
9abf8c |
Signed-off-by: Enzo Matsumiya <ematsumiya@suse.de>
|
|
|
9abf8c |
(cherry picked from commit 019610af266bcaef711715266bc0ca4be1044150)
|
|
|
9abf8c |
|
|
|
9abf8c |
Resolves: #1885417
|
|
|
9abf8c |
---
|
|
|
9abf8c |
modules.d/95nvmf/module-setup.sh | 25 ++++---
|
|
|
9abf8c |
modules.d/95nvmf/parse-nvmf-boot-connections.sh | 97 ++++++++++++++++++-------
|
|
|
9abf8c |
2 files changed, 84 insertions(+), 38 deletions(-)
|
|
|
9abf8c |
|
|
|
9abf8c |
diff --git a/modules.d/95nvmf/module-setup.sh b/modules.d/95nvmf/module-setup.sh
|
|
|
9abf8c |
index db43ec01..418b5e0c 100755
|
|
|
9abf8c |
--- a/modules.d/95nvmf/module-setup.sh
|
|
|
9abf8c |
+++ b/modules.d/95nvmf/module-setup.sh
|
|
|
9abf8c |
@@ -6,9 +6,9 @@ check() {
|
|
|
9abf8c |
[ -f /etc/nvme/hostnqn ] || return 255
|
|
|
9abf8c |
[ -f /etc/nvme/hostid ] || return 255
|
|
|
9abf8c |
|
|
|
9abf8c |
- is_nvme_fc() {
|
|
|
9abf8c |
+ is_nvmf() {
|
|
|
9abf8c |
local _dev=$1
|
|
|
9abf8c |
- local traddr
|
|
|
9abf8c |
+ local trtype
|
|
|
9abf8c |
|
|
|
9abf8c |
[[ -L "/sys/dev/block/$_dev" ]] || return 0
|
|
|
9abf8c |
cd -P "/sys/dev/block/$_dev" || return 0
|
|
|
9abf8c |
@@ -18,19 +18,19 @@ check() {
|
|
|
9abf8c |
for d in device/nvme* ; do
|
|
|
9abf8c |
[ -L "$d" ] || continue
|
|
|
9abf8c |
if readlink "$d" | grep -q nvme-fabrics ; then
|
|
|
9abf8c |
- traddr=$(cat "$d"/address)
|
|
|
9abf8c |
- break
|
|
|
9abf8c |
- fi
|
|
|
9abf8c |
- done
|
|
|
9abf8c |
- [[ "${traddr#traddr=nn-}" != "$traddr" ]]
|
|
|
9abf8c |
+ trtype=$(cat "$d"/transport)
|
|
|
9abf8c |
+ break
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
+ done
|
|
|
9abf8c |
+ [[ "$trtype" == "fc" ]] || [[ "$trtype" == "tcp" ]] || [[ "$trtype" == "rdma" ]]
|
|
|
9abf8c |
}
|
|
|
9abf8c |
|
|
|
9abf8c |
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
|
|
9abf8c |
pushd . >/dev/null
|
|
|
9abf8c |
- for_each_host_dev_and_slaves is_nvme_fc
|
|
|
9abf8c |
- local _is_nvme_fc=$?
|
|
|
9abf8c |
+ for_each_host_dev_and_slaves is_nvmf
|
|
|
9abf8c |
+ local _is_nvmf=$?
|
|
|
9abf8c |
popd >/dev/null
|
|
|
9abf8c |
- [[ $_is_nvme_fc == 0 ]] || return 255
|
|
|
9abf8c |
+ [[ $_is_nvmf == 0 ]] || return 255
|
|
|
9abf8c |
if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ] ; then
|
|
|
9abf8c |
if [ ! -f /etc/nvme/discovery.conf ] ; then
|
|
|
9abf8c |
echo "No discovery arguments present"
|
|
|
9abf8c |
@@ -43,13 +43,14 @@ check() {
|
|
|
9abf8c |
|
|
|
9abf8c |
# called by dracut
|
|
|
9abf8c |
depends() {
|
|
|
9abf8c |
- echo bash rootfs-block
|
|
|
9abf8c |
+ echo bash rootfs-block network
|
|
|
9abf8c |
return 0
|
|
|
9abf8c |
}
|
|
|
9abf8c |
|
|
|
9abf8c |
# called by dracut
|
|
|
9abf8c |
installkernel() {
|
|
|
9abf8c |
instmods nvme_fc lpfc qla2xxx
|
|
|
9abf8c |
+ hostonly="" instmods nvme_tcp nvme_fabrics
|
|
|
9abf8c |
}
|
|
|
9abf8c |
|
|
|
9abf8c |
# called by dracut
|
|
|
9abf8c |
@@ -76,6 +77,8 @@ install() {
|
|
|
9abf8c |
inst_simple "/etc/nvme/hostnqn"
|
|
|
9abf8c |
inst_simple "/etc/nvme/hostid"
|
|
|
9abf8c |
|
|
|
9abf8c |
+ inst_multiple ip sed
|
|
|
9abf8c |
+
|
|
|
9abf8c |
inst_multiple nvme
|
|
|
9abf8c |
inst_multiple -o \
|
|
|
9abf8c |
"$systemdsystemunitdir/nvm*-connect@.service" \
|
|
|
9abf8c |
diff --git a/modules.d/95nvmf/parse-nvmf-boot-connections.sh b/modules.d/95nvmf/parse-nvmf-boot-connections.sh
|
|
|
9abf8c |
index 0d16b871..61c6dec1 100755
|
|
|
9abf8c |
--- a/modules.d/95nvmf/parse-nvmf-boot-connections.sh
|
|
|
9abf8c |
+++ b/modules.d/95nvmf/parse-nvmf-boot-connections.sh
|
|
|
9abf8c |
@@ -8,69 +8,102 @@
|
|
|
9abf8c |
# Examples:
|
|
|
9abf8c |
# nvmf.hostnqn=nqn.2014-08.org.nvmexpress:uuid:37303738-3034-584d-5137-333230423843
|
|
|
9abf8c |
# nvmf.discover=rdma:192.168.1.3::4420
|
|
|
9abf8c |
+# nvme.discover=tcp:192.168.1.3::4420
|
|
|
9abf8c |
+# nvme.discover=tcp:192.168.1.3
|
|
|
9abf8c |
# nvmf.discover=fc:auto
|
|
|
9abf8c |
#
|
|
|
9abf8c |
# Note: FC does autodiscovery, so typically there is no need to
|
|
|
9abf8c |
# specify any discover parameters for FC.
|
|
|
9abf8c |
#
|
|
|
9abf8c |
|
|
|
9abf8c |
+type is_ip >/dev/null 2>&1 || . /lib/net-lib.sh
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+if getargbool 0 rd.nonvmf ; then
|
|
|
9abf8c |
+ warn "rd.nonvmf=0: skipping nvmf"
|
|
|
9abf8c |
+ return 0
|
|
|
9abf8c |
+fi
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+initqueue --onetime modprobe --all -b -q nvme nvme_tcp nvme_core nvme_fabrics
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+traddr="none"
|
|
|
9abf8c |
+trtype="none"
|
|
|
9abf8c |
+hosttraddr="none"
|
|
|
9abf8c |
+trsvcid=4420
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+validate_ip_conn() {
|
|
|
9abf8c |
+ if ! getargbool 0 rd.neednet ; then
|
|
|
9abf8c |
+ warn "$trtype transport requires rd.neednet=1"
|
|
|
9abf8c |
+ return 1
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+ local_address=$(ip -o route get to $traddr | sed -n 's/.*src \([0-9a-f.:]*\).*/\1/p')
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+ # confirm we got a local IP address
|
|
|
9abf8c |
+ if ! is_ip "$local_address" ; then
|
|
|
9abf8c |
+ warn "$traddr is an invalid address";
|
|
|
9abf8c |
+ return 1
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+ ifname=$(ip -o route get to $local_address | sed -n 's/.*dev \([^ ]*\).*/\1/p')
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+ if ip l show "$ifname" >/dev/null 2>&1 ; then
|
|
|
9abf8c |
+ warn "invalid network interface $ifname"
|
|
|
9abf8c |
+ return 1
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
+
|
|
|
9abf8c |
+ # confirm there's a route to destination
|
|
|
9abf8c |
+ if ip route get "$traddr" >/dev/null 2>&1 ; then
|
|
|
9abf8c |
+ warn "no route to $traddr"
|
|
|
9abf8c |
+ return 1
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
+}
|
|
|
9abf8c |
+
|
|
|
9abf8c |
parse_nvmf_discover() {
|
|
|
9abf8c |
OLDIFS="$IFS"
|
|
|
9abf8c |
IFS=:
|
|
|
9abf8c |
- trtype="none"
|
|
|
9abf8c |
- traddr="none"
|
|
|
9abf8c |
- hosttraddr="none"
|
|
|
9abf8c |
- trsvcid=4420
|
|
|
9abf8c |
-
|
|
|
9abf8c |
set $1
|
|
|
9abf8c |
IFS="$OLDIFS"
|
|
|
9abf8c |
|
|
|
9abf8c |
case $# in
|
|
|
9abf8c |
2)
|
|
|
9abf8c |
- trtype=$1
|
|
|
9abf8c |
- traddr=$2
|
|
|
9abf8c |
+ [ -n "$1" ] && trtype=$1
|
|
|
9abf8c |
+ [ -n "$2" ] && traddr=$2
|
|
|
9abf8c |
;;
|
|
|
9abf8c |
3)
|
|
|
9abf8c |
- trtype=$1
|
|
|
9abf8c |
- traddr=$2
|
|
|
9abf8c |
- hosttraddr=$3
|
|
|
9abf8c |
+ [ -n "$1" ] && trtype=$1
|
|
|
9abf8c |
+ [ -n "$2" ] && traddr=$2
|
|
|
9abf8c |
+ [ -n "$3" ] && hosttraddr=$3
|
|
|
9abf8c |
;;
|
|
|
9abf8c |
4)
|
|
|
9abf8c |
- trtype=$1
|
|
|
9abf8c |
- traddr=$2
|
|
|
9abf8c |
- hosttraddr=$3
|
|
|
9abf8c |
- trsvcid=$4
|
|
|
9abf8c |
+ [ -n "$1" ] && trtype=$1
|
|
|
9abf8c |
+ [ -n "$2" ] && traddr=$2
|
|
|
9abf8c |
+ [ -n "$3" ] && hosttraddr=$3
|
|
|
9abf8c |
+ [ -n "$4" ] && trsvcid=$4
|
|
|
9abf8c |
;;
|
|
|
9abf8c |
*)
|
|
|
9abf8c |
warn "Invalid arguments for nvmf.discover=$1"
|
|
|
9abf8c |
return 1
|
|
|
9abf8c |
;;
|
|
|
9abf8c |
esac
|
|
|
9abf8c |
- if [ -z "$traddr" ] ; then
|
|
|
9abf8c |
+ if [ "$traddr" = "none" ] ; then
|
|
|
9abf8c |
warn "traddr is mandatory for $trtype"
|
|
|
9abf8c |
return 1;
|
|
|
9abf8c |
fi
|
|
|
9abf8c |
- [ -z "$hosttraddr" ] && hosttraddr="none"
|
|
|
9abf8c |
- [ -z "$trsvcid" ] && trsvcid="none"
|
|
|
9abf8c |
if [ "$trtype" = "fc" ] ; then
|
|
|
9abf8c |
- if [ -z "$hosttraddr" ] ; then
|
|
|
9abf8c |
+ if [ "$hosttraddr" = "none" ] ; then
|
|
|
9abf8c |
warn "host traddr is mandatory for fc"
|
|
|
9abf8c |
return 1
|
|
|
9abf8c |
fi
|
|
|
9abf8c |
elif [ "$trtype" != "rdma" ] && [ "$trtype" != "tcp" ] ; then
|
|
|
9abf8c |
warn "unsupported transport $trtype"
|
|
|
9abf8c |
return 1
|
|
|
9abf8c |
- elif [ -z "$trsvcid" ] ; then
|
|
|
9abf8c |
- trsvcid=4420
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
+ if [ "$trtype" = "tcp" ]; then
|
|
|
9abf8c |
+ validate_ip_conn
|
|
|
9abf8c |
fi
|
|
|
9abf8c |
echo "--transport=$trtype --traddr=$traddr --host-traddr=$hosttraddr --trsvcid=$trsvcid" >> /etc/nvme/discovery.conf
|
|
|
9abf8c |
}
|
|
|
9abf8c |
|
|
|
9abf8c |
-if ! getargbool 0 rd.nonvmf ; then
|
|
|
9abf8c |
- info "rd.nonvmf=0: skipping nvmf"
|
|
|
9abf8c |
- return 0
|
|
|
9abf8c |
-fi
|
|
|
9abf8c |
-
|
|
|
9abf8c |
nvmf_hostnqn=$(getarg nvmf.hostnqn=)
|
|
|
9abf8c |
if [ -n "$nvmf_hostnqn" ] ; then
|
|
|
9abf8c |
echo "$nvmf_hostnqn" > /etc/nvme/hostnqn
|
|
|
9abf8c |
@@ -89,7 +122,17 @@ done
|
|
|
9abf8c |
[ -f "/etc/nvme/hostid" ] || exit 0
|
|
|
9abf8c |
|
|
|
9abf8c |
if [ -f "/etc/nvme/discovery.conf" ] ; then
|
|
|
9abf8c |
- /sbin/initqueue --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
|
|
|
9abf8c |
+ if [ "$trtype" = "tcp" ] ; then
|
|
|
9abf8c |
+ /sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
|
|
|
9abf8c |
+ > /tmp/net.$ifname.did-setup
|
|
|
9abf8c |
+ else
|
|
|
9abf8c |
+ /sbin/initqueue --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
else
|
|
|
9abf8c |
- /sbin/initqueue --finished --unique --name nvme-fc-autoconnect echo 1 > /sys/class/fc/fc_udev_device/nvme_discovery
|
|
|
9abf8c |
+ if [ "$trtype" = "tcp" ] ; then
|
|
|
9abf8c |
+ /sbin/initqueue --settled --onetime --unique /usr/sbin/nvme connect-all -t tcp -a $traddr -s $trsvcid
|
|
|
9abf8c |
+ > /tmp/net.$ifname.did-setup
|
|
|
9abf8c |
+ else
|
|
|
9abf8c |
+ /sbin/initqueue --finished --unique --name nvme-fc-autoconnect echo 1 > /sys/class/fc/fc_udev_device/nvme_discovery
|
|
|
9abf8c |
+ fi
|
|
|
9abf8c |
fi
|
|
|
9abf8c |
|