]> www.infradead.org Git - users/sagi/nvme-cli.git/commit
nvme-cli: nvmf auto-connect scripts
authorJames Smart <jsmart2021@gmail.com>
Thu, 1 Aug 2019 23:13:48 +0000 (16:13 -0700)
committerKeith Busch <kbusch@kernel.org>
Fri, 2 Aug 2019 15:43:14 +0000 (09:43 -0600)
commit391d3b12248aaff008ef9b7c6d5a430373aeab29
tree9f0614d15e04d3cb4ef2ef1b40ef670b5c39fae6
parent547f4b752c49b144304b1e33d63d9325e02ca50a
nvme-cli: nvmf auto-connect scripts

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>
Makefile
nvme.spec.in
nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf [new file with mode: 0644]
nvmf-autoconnect/systemd/nvmefc-boot-connections.service [new file with mode: 0644]
nvmf-autoconnect/systemd/nvmf-connect.target [new file with mode: 0644]
nvmf-autoconnect/systemd/nvmf-connect@.service [new file with mode: 0644]
nvmf-autoconnect/udev-rules/70-nvmf-autoconnect.rules [new file with mode: 0644]