-
Notifications
You must be signed in to change notification settings - Fork 402
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
NVMeoF / TCP boot support #2184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -25,17 +25,27 @@ 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is not part of the PR, but does anyone know why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it just checking that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is indeed not part of this PR, therefore I'd like to close this conversation. AFAICS, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, good to know the origin of it. Thanks for the response! |
||
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 | ||
echo "No discovery arguments present" | ||
return 255 | ||
fi | ||
if [ ! -f /sys/class/fc/fc_udev_device/nvme_discovery ] \ | ||
&& [ ! -f /etc/nvme/discovery.conf ] \ | ||
&& [ ! -f /etc/nvme/config.json ] && ! has_nbft; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note: same usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
echo "No discovery arguments present" | ||
return 255 | ||
fi | ||
} | ||
return 0 | ||
|
@@ -50,7 +60,7 @@ depends() { | |
# called by dracut | ||
installkernel() { | ||
instmods nvme_fc lpfc qla2xxx | ||
hostonly="" instmods nvme_tcp nvme_fabrics | ||
hostonly="" instmods nvme_tcp nvme_fabrics 8021q | ||
} | ||
|
||
# called by dracut | ||
|
@@ -126,10 +136,12 @@ 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" | ||
inst_rules /usr/lib/udev/rules.d/71-nvmf-iopolicy-netapp.rules | ||
inst_rules "$moddir/95-nvmf-initqueue.rules" | ||
dracut_need_initqueue | ||
|
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 |
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 | ||
aafeijoo-suse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# 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 ] \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note: same usage of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack, thanks! |
||
|| echo add > /sys/class/fc/fc_udev_device/nvme_discovery | ||
/usr/sbin/nvme connect-all | ||
aafeijoo-suse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks only for regular files. Is that intentional?
You could check for
-e
(existence) instead.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.Actually, no. Technically, this check serves to avoid a case where no
NBFT*
file exists, in which case$f
would equal/sys/firmware/acpi/tables/NBFT*
(as we don't usenullglob
). But in the (extremely unlikely) case that a directory entryNBFT*
existed in sysfs, and was not a regular file, we'd definitely want to skip it, too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, folders, I didn't think of that - but It might be symlink or other file-like type as well f.e.; but if only regular files are expected/accepted, I'm fine with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only regular files should be accepted.
Note that
[
(akatest
) dereferences symlinks for all flags except-h
and-L
. Thus if/sys/firmware/acpi/tables/NBFT*
was a symlink to some existing regular file, this test wouldn't skip it, which looks wrong. But this case would indicate a severely broken kernel. I believe we can ignore it. In the worst case, we'd include the NBFT code in the initramfs on a broken system.