Fixinf SPDK

This commit is contained in:
Audiobuzz
2026-06-14 07:32:06 +00:00
parent 1a0cd5c37f
commit cada9520be
5 changed files with 54 additions and 9 deletions
+21 -4
View File
@@ -20,6 +20,22 @@ CPUMASK="${SPDK_CPUMASK:-0x1}"
TGT=$(command -v nvmf_tgt || echo /usr/libexec/spdk/spdk/build/bin/nvmf_tgt)
RPC=$(command -v rpc.py || echo /usr/libexec/spdk/scripts/rpc.py)
# Ensure hugepages exist — DPDK needs them. vm.nr_hugepages isn't namespaced,
# so a privileged container writes the host value; this re-applies after a host
# reboot (the container restarts). Best-effort: allocation can fail on a
# fragmented host, in which case set vm.nr_hugepages on the host (persistently
# via /etc/sysctl.d). Override the count with HUGEPAGES.
HUGEPAGES="${HUGEPAGES:-1024}"
if [ -w /proc/sys/vm/nr_hugepages ]; then
cur=$(cat /proc/sys/vm/nr_hugepages 2>/dev/null || echo 0)
if [ "${cur:-0}" -lt "$HUGEPAGES" ]; then
echo "==> allocating $HUGEPAGES hugepages (was ${cur:-0})"
echo "$HUGEPAGES" > /proc/sys/vm/nr_hugepages 2>/dev/null || true
fi
fi
free=$(awk '/HugePages_Free/{print $2}' /proc/meminfo 2>/dev/null || echo 0)
[ "${free:-0}" -gt 0 ] || echo "WARNING: no free hugepages — SPDK will fail; allocate vm.nr_hugepages on the host." >&2
echo "==> starting nvmf_tgt (cpumask ${CPUMASK})"
"$TGT" -m "$CPUMASK" &
TGT_PID=$!
@@ -42,10 +58,11 @@ echo "==> exposing $ROOTFS as bdev 'rootfs' (4 KiB blocks)"
echo "==> creating subsystem $SUBNQN (allow any host — lab/no-auth)"
"$RPC" nvmf_create_subsystem "$SUBNQN" -a -s SPDKLAB0000000001 -d FleetRootfs
echo "==> adding namespace 1 (read-only)"
# Newer SPDK accepts --read-only on the namespace; fall back if unsupported.
"$RPC" nvmf_subsystem_add_ns "$SUBNQN" rootfs --read-only \
|| "$RPC" nvmf_subsystem_add_ns "$SUBNQN" rootfs
echo "==> adding namespace 1"
# Read-only is enforced by the bdev_aio '-r' open above (this SPDK's add_ns has
# no --read-only flag), plus the :ro image-volume mount and the client's erofs
# ro + dm-verity.
"$RPC" nvmf_subsystem_add_ns "$SUBNQN" rootfs
echo "==> adding TCP listener ${TADDR}:${TPORT} (also serves discovery)"
"$RPC" nvmf_subsystem_add_listener "$SUBNQN" -t tcp -a "$TADDR" -s "$TPORT"