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