All of lore.kernel.org
 help / color / mirror / Atom feed
From: sagi@grimberg.me (Sagi Grimberg)
Subject: [PATCH rfc] nvme-cli: NVMf auto discovery systemd service
Date: Sun, 24 Sep 2017 16:01:35 +0300	[thread overview]
Message-ID: <1506258095-15916-1-git-send-email-sagi@grimberg.me> (raw)

Run a one-shot discovery (and connect) at system boot time. This
allows to auto discover and establish nvmf sessions.

If the user is interested in using this, it should fill in
one or more discovery endpoints, for example:
-t rdma -a 192.168.1.1 -s 4420

This service relies on nvme-fabrics module being loaded, hence
we add it to modules load at boot list.

Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
---
Don't have a fedora station near-by, manually tested auto
discover during boot with systemd service, and it seem to work
(although I needed to manually get mlx5_ib modules to auto-load
as for some reason it fails to auto load at boot time).

We can also add some documentation into discovery.conf to help
the user add discovery endpoints.

 nvme.spec.in                   | 19 +++++++++++++++++++
 systemd/nvmf-discovery.service | 12 ++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 systemd/nvmf-discovery.service

diff --git a/nvme.spec.in b/nvme.spec.in
index 0be61e398fd0..c22bdeec9138 100644
--- a/nvme.spec.in
+++ b/nvme.spec.in
@@ -43,12 +43,31 @@ if [ $1 = 1 ]; then # 1 : This package is being installed for the first time
         if [ ! -f /etc/nvme/hostid ]; then
                 uuidgen > /etc/nvme/hostid
         fi
+        if [ ! -f /etc/nvme/discovery.conf ]; then
+		touch /etc/nvme/discovery.conf
+        fi
 fi
 
+# NVMf auto-discovery service
+install -m 0755 systemd/nvmf-discovery.service /lib/systemd/system/
+systemctl enable nvmf-discovery.service
+
+# we rely on /dev/nvme-fabrics misc device, so auto load nvme-fabrics
+# at boot time
+echo nvme-fabrics >> /etc/modules-load.d/modules.conf
+
 %preun
 if [ "$1" = "remove" ]; then
+	sed -i 's/nvme-fabrics//e' /etc/modules-load.d/modules.conf
+
+	if [ -f /lib/systemd/system/nvmf-discovery.service]; then
+		systemctl disable nvmf-discovery.service
+		rm -f /lib/systemd/system/nvmf-discovery.service
+	fi
+
 	if [ -d /etc/nvme ]; then
 		rm -f /etc/nvme/hostnqn
+		rm -f /etc/nvme/discovery.conf
 		if [ ! -n "`ls -A /etc/nvme`" ]; then
 			rm -rf /etc/nvme
 		fi
diff --git a/systemd/nvmf-discovery.service b/systemd/nvmf-discovery.service
new file mode 100644
index 000000000000..25f7bf1f077b
--- /dev/null
+++ b/systemd/nvmf-discovery.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=NVMf auto discovery service
+After=systemd-modules-load.service network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=nvme connect-all
+StandardOutput=journal
+StandardError=journal
+
+[Install]
+WantedBy=multi-user.target
-- 
2.7.4

             reply	other threads:[~2017-09-24 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24 13:01 Sagi Grimberg [this message]
2017-09-24 14:56 ` [PATCH rfc] nvme-cli: NVMf auto discovery systemd service Christoph Hellwig
2017-09-24 15:20   ` Sagi Grimberg
2017-09-25  7:55 ` Johannes Thumshirn
2017-09-25 13:22   ` Sagi Grimberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506258095-15916-1-git-send-email-sagi@grimberg.me \
    --to=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.