nvme-discoverd(8)
=================

NAME
----
nvme-discoverd - NVMe-oF discovery and connectivity daemon

SYNOPSIS
--------
[verse]
'nvme-discoverd' [--config=<FILE>] [--nvme-path=<PATH>] [--debug] [--help]

DESCRIPTION
-----------
nvme-discoverd is a persistent daemon that connects the host's desired
NVMe-oF controllers and keeps them connected. It reads three sources to
build its set of desired connections: the connections of the pre-OS
environment (the NBFT ACPI table and @RUNDIR@/nvme/pre-os.conf, see
below), the shared NVMe-oF fabrics configuration
(nvme-fabrics.conf(5)), and the Discovery Log Pages of any Discovery
Controllers it connects to (including FC targets found via FC
kickstart). It never disconnects a live controller in response to a
discovery change; the only disconnects it causes are a side effect of
stopping its own systemd units, at shutdown or on request.

At shutdown, a unit is stopped only after the file systems mounted
with the '_netdev' option are unmounted. A file system on an NVMe-oF
namespace must use '_netdev' in fstab(5). Without it, the controller
can be disconnected while the file system is still mounted.

Every connection attempt is delegated to 'nvme connect', which runs
inside a systemd transient unit instead of writing directly to
/dev/nvme-fabrics. As a result, a stuck connect attempt never blocks
the daemon's event loop. Each unit is named after a hash of the
controller's transport identity.

Failed connections retry with exponential backoff. What an admin asked
for retries forever: the controllers from NBFT and the fabrics config,
and the I/O controllers and referrals a Discovery Log Page lists (an
admin configures them on the storage system). A referral stops when
the Discovery Controller that lists it no longer does, or is given up.
A Discovery Controller found only through mDNS or FC kickstart is
different: no admin asked for it, so it gives up after
'dc-giveup-timeout' (default 72hours) of unbroken failure and is
dropped from tracking.

A Discovery Log Page entry of an I/O controller can have NCC (No CDC
Connectivity) set: a Centralized Discovery Controller sets it while it
has no connection to the subsystem. With 'connect-attempts-on-ncc' set,
nvme-discoverd stops after that many failed attempts while NCC is set,
and tries again when the entry no longer has NCC set. This does not
apply to an I/O controller from NBFT, pre-os.conf or the fabrics config.

A TLS connection needs tlshd(8) from ktls-utils. Enable it with
'systemctl enable --now tlshd'. When both are enabled, nvme-discoverd
starts after tlshd.

Before connecting or reconnecting anything, nvme-discoverd checks the
system-wide exclusion list. It also registers ownership of every
controller it connects (--owner discoverd) in the NVMe-oF ownership
registry. See nvme-registry-list(1) and nvme-exclusion-add(1).

The pre-OS environment, the firmware and the initrd, connects the paths
the system boots from with the owner 'pre-os' (once called 'nbft'). In
the initrd, nvme records each connection it makes with this owner in a
drop-in of @RUNDIR@/nvme/pre-os.conf.d, also when the connect fails; the
NBFT lists the firmware's. nvme-discoverd keeps these connections
connected, but never owns them: it connects a lost or never connected
path again with --owner pre-os and the parameters the pre-OS
environment used, and so is everything a pre-OS Discovery Controller
lists. Their units never disconnect, also not at the shutdown: the
kernel keeps the connection until the root file system is gone. The
exclusion list does not apply to them.

A Discovery Controller that has no owner, for example one connected
with 'nvme discover --persistent', is not tracked. When its discovery
log changes, or when it reconnects, nvme-discoverd runs
'nvme connect-all' for it in a transient unit, as the legacy udev
rules do. The connections it makes have no owner, and
'nvme disconnect-all' removes them. Events from a Discovery
Controller with another owner are ignored.

nvme-discoverd is still experimental. It is meant to replace the
older udev-rule/systemd-unit autoconnect mechanism. By default, the
legacy mechanism is built only when nvme-discoverd is not. Building
with '-Dnvmf-autoconnect=enabled' installs both. The legacy udev
rules are active as soon as they are installed. nvme-discoverd runs
only when the administrator enables it with
'systemctl enable --now nvme-discoverd'. While nvme-discoverd is
active, its service masks the legacy udev rule
70-nvmf-autoconnect.rules with a link to /dev/null in
/run/udev/rules.d, and nvmf-autoconnect.service and the FC kickstart
skip their connect step. The mask also covers a rule of that name
left over from an older installation. Stopping nvme-discoverd removes
the mask.

OPTIONS
-------
-c <FILE>::
--config=<FILE>::
	Path to the daemon's own configuration file. Default:
	@SYSCONFDIR@/nvme/nvme-discoverd.conf; see CONFIGURATION below.
	A missing file is not an error -- every knob keeps its default.

--nvme-path=<PATH>::
	Absolute or relative path to the 'nvme' binary that transient
	connection units exec. Default: @SBINDIR@/nvme. Mainly useful for
	running nvme-discoverd against a locally built 'nvme' instead of
	the installed one.

-d::
--debug::
	Enable debug-level logging for both nvme-discoverd and the
	libnvme calls it makes, overriding the configured debug-level.

--set-options=<KEY=VALUE[,KEY=VALUE...]>::
	For tests, as with nvme(1). The keys are:
+
--
test-sysfs-dir=<DIR>;;
	Read sysfs under <DIR>: /sys/class/nvme becomes
	<DIR>/sys/class/nvme. This covers the controllers, the NBFT
	tables and the FC kickstart attribute.
test-base-dir=<DIR>;;
	Run in a sandbox in <DIR>, which must be under /tmp. The
	ownership registry, the state of /run/nvme/discoverd, the
	fabrics configuration (<DIR>/nvme-fabrics.conf) and pre-os.conf
	(<DIR>/pre-os.conf) are taken from <DIR>. nvme-discoverd does not use systemd: the connection units
	run in the daemon and are kept in <DIR>/units, with a journal of
	what ran. It does not listen to udev either: a test sends the
	uevents through the control socket <DIR>/discoverd.sock, which
	also answers "sync" and "dump" requests.
--
+
The option may be repeated. The nvme(1) of the connection units gets the
same test directories.

-h::
--help::
	Print usage and exit.

CONFIGURATION
-------------
nvme-discoverd.conf holds the daemon's own knobs, in a '[Global]'
section and a '[Discovery]' section:

	[Global]
	pre-os = true
	debug-level = info

	[Discovery]
	epcsd-poll-interval-minutes = 15
	fc-kickstart-interval-minutes = 0
	dc-giveup-timeout = 72hours
	connect-attempts-on-ncc = 0
	zeroconf = false

'pre-os' (boolean, default true) keeps the connections of the pre-OS
environment connected, see above. 'nbft' is its old name. 'debug-level' (err, warn, info, or debug;
default info) sets the log threshold; '--debug' on the command line
overrides it.

'epcsd-poll-interval-minutes' (default 15, minimum 1) sets how often,
in minutes, to reconnect and re-check a DC whose effective EPCSD
(Explicit Persistent Connection Support for Discovery) is 0. Such a DC
is disconnected between checks. 'fc-kickstart-interval-minutes'
(default 0) re-issues FC kickstart every N minutes; 0 = only at
startup and on every FC controller drop. 'dc-giveup-timeout' (default
72hours) is the give-up horizon described above. It takes a systemd
time span ("72hours", "3 days 5 hours") or a unit-less value in
seconds; "infinity" = never give up, 0 = give up on the first failure.
'connect-attempts-on-ncc' (default 0) is the number of failed attempts
after which an I/O controller with NCC set is no longer tried, see
above. 0 = no limit.

A DC connects with a keep-alive timeout of 30 seconds, or with its
configured 'keep-alive-tmo' (see nvme-fabrics.conf(5)). A DC
configured with 'persistent = no' connects with none.

'zeroconf' (boolean, default false) connects to and manages Discovery
Controllers found through mDNS (TP8009). It requires systemd-resolved
v258 or later with mDNS enabled ('MulticastDNS=yes'), and an
nvme-discoverd built with mDNS support. It is re-read on SIGHUP.

The connections nvme-discoverd manages come entirely from the shared
fabrics configuration, not from this file: which Discovery Controllers
and subsystems to connect, host identity, per-connection parameters.
See nvme-fabrics.conf(5).

SIGNALS
-------
SIGHUP;;
	Reload nvme-discoverd.conf, the shared fabrics configuration
	and pre-os.conf.
	Newly desired connections are started; nothing already connected
	is ever disconnected by a reload. If the fabrics configuration
	fails to reload (e.g. a syntax error), the previous one is kept
	and the failure is logged.

SIGTERM, SIGINT;;
	Shut down gracefully.

FILES
-----
@SYSCONFDIR@/nvme/nvme-discoverd.conf::
	The daemon's own configuration; see CONFIGURATION.

@SYSCONFDIR@/nvme/nvme-discoverd.conf.sample::
	A commented example of nvme-discoverd.conf with every knob at its
	default. It is not read; copy it to nvme-discoverd.conf to change a
	setting.

@SYSCONFDIR@/nvme/nvme-fabrics.conf, @SYSCONFDIR@/nvme/nvme-fabrics.conf.d/*.conf::
	The connections nvme-discoverd manages; see nvme-fabrics.conf(5).

@RUNDIR@/nvme/pre-os.conf, @RUNDIR@/nvme/pre-os.conf.d/*.conf::
	The connections of the pre-OS environment, which nvme(1) writes in
	the initrd; see DESCRIPTION.

@RUNDIR@/nvme/discoverd/::
	Runtime state linking each connected controller to the systemd
	transient unit that owns it. Does not survive a reboot.

SEE ALSO
--------
nvme-fabrics.conf(5)
tlshd(8)
nvme-connect(1)
nvme-registry-list(1)
nvme-exclusion-add(1)

NVME
----
Part of the nvme-user suite
