Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: honor rd.timeout for nvme ctrl_loss_tmo #11

Open
wants to merge 2 commits into
base: timberland_final
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions man/dracut.cmdline.7.asc
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,15 @@ NVMf
**rd.nonvmf**::
Disable NVMf

**rd.nvmf.nonbft**::
Disable connecting to targets from the NVMe Boot Firmware Table. Without
this parameter, NBFT connections will take precedence over _rd.nvmf.discover_.

**rd.nvmf.nostatic**::
Disable connecting to targets that have been statically configured when
the initramfs was built. Targets specified with rd.nvmf.discover on the
kernel command line will still be tried.

**rd.nvmf.hostnqn=**__<hostNQN>__::
NVMe host NQN to use

Expand Down
17 changes: 14 additions & 3 deletions modules.d/95nvmf/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# called by dracut
check() {
require_binaries nvme || return 1
require_binaries nvme jq || return 1
[ -f /etc/nvme/hostnqn ] || return 255
[ -f /etc/nvme/hostid ] || return 255

Expand All @@ -25,14 +25,24 @@ check() {
[[ $trtype == "fc" ]] || [[ $trtype == "tcp" ]] || [[ $trtype == "rdma" ]]
}

has_nbft() {
local f found=
for f in /sys/firmware/acpi/tables/NBFT*; do
[ -f "$f" ] || continue
found=1
break
done
[[ $found ]]
}

[[ $hostonly ]] || [[ $mount_needs ]] && {
pushd . > /dev/null
for_each_host_dev_and_slaves is_nvmf
local _is_nvmf=$?
popd > /dev/null || exit
[[ $_is_nvmf == 0 ]] || return 255
if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then
if [ ! -f /etc/nvme/discovery.conf ]; then
if [ ! -f /etc/nvme/discovery.conf ] && ! has_nbft; then
echo "No discovery arguments present"
return 255
fi
Expand Down Expand Up @@ -126,8 +136,9 @@ install() {
inst_multiple ip sed

inst_script "${moddir}/nvmf-autoconnect.sh" /sbin/nvmf-autoconnect.sh
inst_script "${moddir}/nbftroot.sh" /sbin/nbftroot

inst_multiple nvme
inst_multiple nvme jq
inst_hook cmdline 92 "$moddir/parse-nvmf-boot-connections.sh"
inst_simple "/etc/nvme/discovery.conf"
inst_simple "/etc/nvme/config.json"
Expand Down
5 changes: 5 additions & 0 deletions modules.d/95nvmf/nbftroot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#! /bin/sh
# This script is called from /sbin/netroot

/sbin/nvmf-autoconnect.sh online
exit 0
55 changes: 52 additions & 3 deletions modules.d/95nvmf/nvmf-autoconnect.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
#!/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

if [ "$1" = timeout ]; then
[ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ] \
|| echo add > /sys/class/fc/fc_udev_device/nvme_discovery
/usr/sbin/nvme connect-all
exit 0
fi

NVMF_HOSTNQN_OK=
[ ! -f "/etc/nvme/hostnqn" ] || [ ! -f "/etc/nvme/hostid" ] || NVMF_HOSTNQN_OK=1

# Only nvme-cli 2.5 or newer supports the options --nbft and --no-nbft
# for the connect-all command.
# Make sure we don't use unsupported options with earlier versions.
NBFT_SUPPORTED=
# shellcheck disable=SC2016
/usr/sbin/nvme connect-all --help 2>&1 | sed -n '/[[:space:]]--nbft[[:space:]]/q1;$q0' \
|| NBFT_SUPPORTED=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
exit 0
fi
if [ "$NBFT_SUPPORTED" ] && [ -e /tmp/valid_nbft_entry_found ]; then
# prio 2: NBFT
/usr/sbin/nvme connect-all --nbft
exit 0
fi
if [ -f /etc/nvme/discovery.conf ] || [ -f /etc/nvme/config.json ] \
&& [ "$NVMF_HOSTNQN_OK" ]; then
# prio 3: configuration from initrd and/or kernel command line
# We can get here even if "rd.nvmf.nonbft" was given, thus use --no-nbft
if [ "$NBFT_SUPPORTED" ]; then
/usr/sbin/nvme connect-all --no-nbft
else
/usr/sbin/nvme connect-all
fi
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
Loading