28ab1c
From 81f38303351391b054e28d91cb101756233d2b64 Mon Sep 17 00:00:00 2001
28ab1c
From: Hannes Reinecke <hare@suse.com>
28ab1c
Date: Mon, 28 Sep 2020 13:39:07 +0200
28ab1c
Subject: [PATCH] 95nvmf: add nvmf-autoconnect script
28ab1c
28ab1c
Add a script to run FC autoconnect.
28ab1c
28ab1c
Signed-off-by: Hannes Reinecke <hare@suse.de>
28ab1c
(cherry picked from commit 0e2ef80993858992f6219b5162289568937a1fac)
28ab1c
28ab1c
Cherry-picked from: 0e2ef80993858992f6219b5162289568937a1fac
28ab1c
Resolves: #1975707
28ab1c
---
28ab1c
 modules.d/95nvmf/module-setup.sh                | 2 ++
28ab1c
 modules.d/95nvmf/nvmf-autoconnect.sh            | 5 +++++
28ab1c
 modules.d/95nvmf/parse-nvmf-boot-connections.sh | 2 +-
28ab1c
 3 files changed, 8 insertions(+), 1 deletion(-)
28ab1c
28ab1c
diff --git a/modules.d/95nvmf/module-setup.sh b/modules.d/95nvmf/module-setup.sh
28ab1c
index 418b5e0c..3923451b 100755
28ab1c
--- a/modules.d/95nvmf/module-setup.sh
28ab1c
+++ b/modules.d/95nvmf/module-setup.sh
28ab1c
@@ -79,6 +79,8 @@ install() {
28ab1c
 
28ab1c
     inst_multiple ip sed
28ab1c
 
28ab1c
+    inst_script "${moddir}/nvmf-autoconnect.sh" /sbin/nvmf-autoconnect.sh
28ab1c
+
28ab1c
     inst_multiple nvme
28ab1c
     inst_multiple -o \
28ab1c
         "$systemdsystemunitdir/nvm*-connect@.service" \
28ab1c
diff --git a/modules.d/95nvmf/nvmf-autoconnect.sh b/modules.d/95nvmf/nvmf-autoconnect.sh
28ab1c
new file mode 100644
28ab1c
index 00000000..c8f676a7
28ab1c
--- /dev/null
28ab1c
+++ b/modules.d/95nvmf/nvmf-autoconnect.sh
28ab1c
@@ -0,0 +1,5 @@
28ab1c
+#!/bin/bash
28ab1c
+
28ab1c
+[ -f /sys/class/fc/fc_udev_device/nvme_discovery ] || exit 1
28ab1c
+echo add > /sys/class/fc/fc_udev_device/nvme_discovery
28ab1c
+exit 0
28ab1c
diff --git a/modules.d/95nvmf/parse-nvmf-boot-connections.sh b/modules.d/95nvmf/parse-nvmf-boot-connections.sh
28ab1c
index 61c6dec1..ceb52f1e 100755
28ab1c
--- a/modules.d/95nvmf/parse-nvmf-boot-connections.sh
28ab1c
+++ b/modules.d/95nvmf/parse-nvmf-boot-connections.sh
28ab1c
@@ -133,6 +133,6 @@ else
28ab1c
         /sbin/initqueue --settled --onetime --unique /usr/sbin/nvme connect-all -t tcp -a $traddr -s $trsvcid
28ab1c
         > /tmp/net.$ifname.did-setup
28ab1c
     else
28ab1c
-        /sbin/initqueue --finished --unique --name nvme-fc-autoconnect echo 1 > /sys/class/fc/fc_udev_device/nvme_discovery
28ab1c
+        /sbin/initqueue --finished --onetime --unique --name nvme-fc-autoconnect /sbin/nvmf-autoconnect.sh
28ab1c
     fi
28ab1c
 fi
28ab1c