This set of scripts is a combination of those sent by Hannes, Sagi,
and I in earlier patches and RFC's.
Auto-connect operates by the nvme core layer or nvme-fc transport
generating a udev event with directory-controller addressing
information. The nvme core layer generates an event when a
persistent discovery controller generates a Discovery Log Change
Notification AEN. The nvme-fc transport generates an event when
an FC rport that has a NVME Discovery controller is detected or
when a FC state change event occurs for for an FC rport that has
a NVME Discovery controller
The udev event is handled by a script that extracts the Discovery
controller addressing information and initiates a systemd service
to perform a "nvme connect-all" to the Discovery controller.
The "nvme connect-all" request is not called directly from the udev
handler itself as the request may take some time or stall altogether,
which would block other udev event handling. By transitioning to
a sytemd service, the call can take as much time as needed to
complete.
The scripts consist of:
- A udev script that handles nvme core and nvme-fc udev events.
The udev handler starts a nvmf-connect systemd service.
- A nvmf-connect systemd service. The service, in its instance
name, is passed the connect arguments for the discovery
controller. The service performs a "nvme connect-all" to the
discovery controller.
- A nvmefc-boot-connections systemd service. This is a run-once
service run after udev is enabled, which will replay events
generated by NVME-FC devices detected during boot while udev
is not yet running.
- To stop autoconnect an additional nvmefc-connect.target has
been added, which will instruct systemd to cancel all
outstanding autoconnect services.
Note: Although the nvme-fc subsystem is converting to use the
same nvme core layer event mechanism, the nvme-fc-specific
udev event that has been in existence for a while is contained
in in the script so that the utilities may run against older
kernels.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Hannes Reinecke <hare@suse.com> CC: Simon Schricker <sschricker@suse.com>