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