From: hare@suse.de (Hannes Reinecke) Date: Thu, 18 Jul 2019 08:02:28 +0200 Subject: [PATCH 10/10] nvme-cli: nvmf auto-connect scripts In-Reply-To: <20190716211241.7650-11-jsmart2021@gmail.com> References: <20190716211241.7650-1-jsmart2021@gmail.com> <20190716211241.7650-11-jsmart2021@gmail.com> Message-ID: <2bd2a068-dbbd-84e8-250e-d9d4afa640d3@suse.de> On 7/16/19 11:12 PM, James Smart wrote: > 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 > CC: Simon Schricker > CC: Hannes Reinecke > CC: Sagi Grimberg > > --- > from rfc to actual posting: > Changed udev device variable to NVME_CTRL_NAME > Removed full pathname for nvme and echo in systemd service that > invokes connect-all > Moved --quiet option. Rather than include in "arguments" in > systemd service name, add directly to systemd service that > invokes connect-all > Created install-systemd and install-dracut Make targets > Changed PREFIX to /usr to match nvme.spec.in's %install target > Changed LIBDIR to use PREFIX as base path > --- > Makefile | 22 +++++++++++++++++++--- > nvme.spec.in | 9 +++++++++ > nvmf-autoconnect/70-nvmf-autoconnect.conf | 1 + > nvmf-autoconnect/70-nvmf-autoconnect.rules | 18 ++++++++++++++++++ > nvmf-autoconnect/nvmefc-boot-connections.service | 9 +++++++++ > nvmf-autoconnect/nvmf-connect.target | 2 ++ > nvmf-autoconnect/nvmf-connect at .service | 14 ++++++++++++++ > 7 files changed, 72 insertions(+), 3 deletions(-) > create mode 100644 nvmf-autoconnect/70-nvmf-autoconnect.conf > create mode 100644 nvmf-autoconnect/70-nvmf-autoconnect.rules > create mode 100644 nvmf-autoconnect/nvmefc-boot-connections.service > create mode 100644 nvmf-autoconnect/nvmf-connect.target > create mode 100644 nvmf-autoconnect/nvmf-connect at .service > The install sequence is slightly odd, but not enough to complain. (udevadm trigger before systemd daemon-reload? I'd rather do it the other way round. Anyway.) So: Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes Reinecke Teamlead Storage & Networking hare at suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Mary Higgins, Sri Rasiah HRB 21284 (AG N?rnberg)