diff --git a/modules.d/95nvmf/nvmf-autoconnect.sh b/modules.d/95nvmf/nvmf-autoconnect.sh index c8f676a74b..afaa569b22 100755 --- a/modules.d/95nvmf/nvmf-autoconnect.sh +++ b/modules.d/95nvmf/nvmf-autoconnect.sh @@ -1,5 +1,33 @@ -#!/bin/bash +#!/bin/sh +# Argument $1 is "settled", "online", or "timeout", indicating +# the queue from which the script is called. +# In the "timeout" case, try everything. +# Otherwise, try options according to the priorities below. -[ -f /sys/class/fc/fc_udev_device/nvme_discovery ] || exit 1 -echo add > /sys/class/fc/fc_udev_device/nvme_discovery +[ "$RD_DEBUG" != yes ] || set -x + +NVMF_HOSTNQN_OK= +[ ! -f "/etc/nvme/hostnqn" ] || [ ! -f "/etc/nvme/hostid" ] || NVMF_HOSTNQN_OK=1 + +if [ -e /tmp/nvmf-fc-auto ] && [ "$NVMF_HOSTNQN_OK" ] && + [ -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then + # prio 1: cmdline override "rd.nvmf.discovery=fc,auto" + echo add >/sys/class/fc/fc_udev_device/nvme_discovery + [ "$1" = timeout ] || exit 0 +fi +if [ -e /tmp/valid_nbft_entry_found ]; then + # prio 2: NBFT + /usr/sbin/nvme connect-nbft + [ "$1" = timeout ] || exit 0 +fi +if [ -f /etc/nvme/discovery.conf ] && [ $NVMF_HOSTNQN_OK ]; then + # prio 3: discovery.conf from initrd + /usr/sbin/nvme connect-all + [ "$1" = timeout ] || exit 0 +fi +if [ "$NVMF_HOSTNQN_OK" ] && + [ -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then + # prio 4: no discovery entries, try NVMeoFC autoconnect + echo add >/sys/class/fc/fc_udev_device/nvme_discovery +fi exit 0 diff --git a/modules.d/95nvmf/parse-nvmf-boot-connections.sh b/modules.d/95nvmf/parse-nvmf-boot-connections.sh index da45437002..85e2c7cd5d 100755 --- a/modules.d/95nvmf/parse-nvmf-boot-connections.sh +++ b/modules.d/95nvmf/parse-nvmf-boot-connections.sh @@ -301,10 +301,10 @@ if [ -n "$nvmf_hostid" ]; then echo "$nvmf_hostid" > /etc/nvme/hostid fi -NVMF_FC_AUTO= +rm -f /tmp/nvmf-fc-auto for d in $(getargs rd.nvmf.discover -d nvmf.discover=); do parse_nvmf_discover "$d" || { - NVMF_FC_AUTO=1 + : > /tmp/nvmf-fc-auto break } done @@ -314,19 +314,6 @@ if [ -e /tmp/nvmf_needs_network ] || [ -e /tmp/valid_nbft_entry_found ]; then rm -f /tmp/nvmf_needs_network fi -NVMF_HOSTNQN_OK= -[ ! -f "/etc/nvme/hostnqn" ] || [ ! -f "/etc/nvme/hostid" ] || NVMF_HOSTNQN_OK=1 - -if [ $NVMF_FC_AUTO ] && [ $NVMF_HOSTNQN_OK ]; then - # prio 1: cmdline override "rd.nvmf.discovery=fc,auto" - /sbin/initqueue --settled --onetime --unique --name nvme-fc-autoconnect /sbin/nvmf-autoconnect.sh -elif [ -e /tmp/valid_nbft_entry_found ]; then - # prio 2: NBFT - /sbin/initqueue --settled --onetime --unique --name nvme-connect-nbft /usr/sbin/nvme connect-nbft -elif [ -f /etc/nvme/discovery.conf ] && [ $NVMF_HOSTNQN_OK ]; then - # prio 3: discovery.conf from initrd - /sbin/initqueue --settled --onetime --unique --name nvme-discover /usr/sbin/nvme connect-all -elif [ $NVMF_HOSTNQN_OK ]; then - # prio 4: no discovery entries, try NVMeoFC autoconnect - /sbin/initqueue --settled --onetime --unique --name nvme-fc-autoconnect /sbin/nvmf-autoconnect.sh -fi +/sbin/initqueue --online --name nvmf-connect-online /sbin/nvmf-autoconnect.sh online +/sbin/initqueue --settled --onetime --name nvmf-connect-settled /sbin/nvmf-autoconnect.sh settled +/sbin/initqueue --timeout --onetime --name nvmf-connect-timeout /sbin/nvmf-autoconnect.sh timeout