28ab1c
From dc316701f752f5197a6a926a9a401688ffdb9bca Mon Sep 17 00:00:00 2001
28ab1c
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
28ab1c
Date: Thu, 26 Nov 2020 13:04:44 +0100
28ab1c
Subject: [PATCH] fix(mdraid): remove offroot
28ab1c
28ab1c
offroot is deprecated and can be safety removed.
28ab1c
28ab1c
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
28ab1c
(cherry picked from commit 30e49d51751c695be85782cfc162de2a63db471c)
28ab1c
28ab1c
Resolves: #1958899
28ab1c
---
28ab1c
 modules.d/90mdraid/65-md-incremental-imsm.rules |  2 +-
28ab1c
 modules.d/90mdraid/md-shutdown.sh               |  5 ++---
28ab1c
 modules.d/90mdraid/mdraid-cleanup.sh            |  7 +++----
28ab1c
 modules.d/90mdraid/mdraid-waitclean.sh          |  7 +++----
28ab1c
 modules.d/90mdraid/mdraid_start.sh              | 10 +++-------
28ab1c
 modules.d/90mdraid/parse-md.sh                  |  2 --
28ab1c
 6 files changed, 12 insertions(+), 21 deletions(-)
28ab1c
28ab1c
diff --git a/modules.d/90mdraid/65-md-incremental-imsm.rules b/modules.d/90mdraid/65-md-incremental-imsm.rules
28ab1c
index 52f5b195..6697f159 100644
28ab1c
--- a/modules.d/90mdraid/65-md-incremental-imsm.rules
28ab1c
+++ b/modules.d/90mdraid/65-md-incremental-imsm.rules
28ab1c
@@ -39,6 +39,6 @@ RUN+="/sbin/initqueue --timeout --name 50-mdraid_start --onetime --unique /sbin/
28ab1c
 #
28ab1c
 LABEL="md_incremental"
28ab1c
 
28ab1c
-RUN+="/sbin/mdadm $env{rd_MD_OFFROOT} -I $env{DEVNAME}"
28ab1c
+RUN+="/sbin/mdadm -I $env{DEVNAME}"
28ab1c
 
28ab1c
 LABEL="md_end"
28ab1c
diff --git a/modules.d/90mdraid/md-shutdown.sh b/modules.d/90mdraid/md-shutdown.sh
28ab1c
index 400bb003..40c82570 100755
28ab1c
--- a/modules.d/90mdraid/md-shutdown.sh
28ab1c
+++ b/modules.d/90mdraid/md-shutdown.sh
28ab1c
@@ -3,12 +3,11 @@
28ab1c
 _do_md_shutdown() {
28ab1c
     local ret
28ab1c
     local final=$1
28ab1c
-    local _offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
28ab1c
     info "Waiting for mdraid devices to be clean."
28ab1c
-    mdadm $_offroot -vv --wait-clean --scan| vinfo
28ab1c
+    mdadm -vv --wait-clean --scan| vinfo
28ab1c
     ret=$?
28ab1c
     info "Disassembling mdraid devices."
28ab1c
-    mdadm $_offroot -vv --stop --scan | vinfo
28ab1c
+    mdadm -vv --stop --scan | vinfo
28ab1c
     ret=$(($ret+$?))
28ab1c
     if [ "x$final" != "x" ]; then
28ab1c
         info "/proc/mdstat:"
28ab1c
diff --git a/modules.d/90mdraid/mdraid-cleanup.sh b/modules.d/90mdraid/mdraid-cleanup.sh
28ab1c
index 565449a5..007e581b 100755
28ab1c
--- a/modules.d/90mdraid/mdraid-cleanup.sh
28ab1c
+++ b/modules.d/90mdraid/mdraid-cleanup.sh
28ab1c
@@ -2,7 +2,6 @@
28ab1c
 
28ab1c
 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
28ab1c
 
28ab1c
-_offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
28ab1c
 containers=""
28ab1c
 for md in /dev/md[0-9_]*; do
28ab1c
     [ -b "$md" ] || continue
28ab1c
@@ -12,11 +11,11 @@ for md in /dev/md[0-9_]*; do
28ab1c
         containers="$containers $md"
28ab1c
         continue
28ab1c
     fi
28ab1c
-    mdadm $_offroot -S "$md" >/dev/null 2>&1
28ab1c
+    mdadm -S "$md" >/dev/null 2>&1
28ab1c
 done
28ab1c
 
28ab1c
 for md in $containers; do
28ab1c
-    mdadm $_offroot -S "$md" >/dev/null 2>&1
28ab1c
+    mdadm -S "$md" >/dev/null 2>&1
28ab1c
 done
28ab1c
 
28ab1c
-unset containers udevinfo _offroot
28ab1c
+unset containers udevinfo
28ab1c
diff --git a/modules.d/90mdraid/mdraid-waitclean.sh b/modules.d/90mdraid/mdraid-waitclean.sh
28ab1c
index 5c901982..0a7480f7 100755
28ab1c
--- a/modules.d/90mdraid/mdraid-waitclean.sh
28ab1c
+++ b/modules.d/90mdraid/mdraid-waitclean.sh
28ab1c
@@ -1,7 +1,6 @@
28ab1c
 #!/bin/sh
28ab1c
 
28ab1c
 if getargbool 0 rd.md.waitclean; then
28ab1c
-    _offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
28ab1c
     type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
28ab1c
     containers=""
28ab1c
     for md in /dev/md[0-9_]*; do
28ab1c
@@ -13,13 +12,13 @@ if getargbool 0 rd.md.waitclean; then
28ab1c
             continue
28ab1c
         fi
28ab1c
         info "Waiting for $md to become clean"
28ab1c
-        mdadm $_offroot -W "$md" >/dev/null 2>&1
28ab1c
+        mdadm -W "$md" >/dev/null 2>&1
28ab1c
     done
28ab1c
 
28ab1c
     for md in $containers; do
28ab1c
         info "Waiting for $md to become clean"
28ab1c
-        mdadm $_offroot -W "$md" >/dev/null 2>&1
28ab1c
+        mdadm -W "$md" >/dev/null 2>&1
28ab1c
     done
28ab1c
 
28ab1c
-    unset containers udevinfo _offroot
28ab1c
+    unset containers udevinfo
28ab1c
 fi
28ab1c
diff --git a/modules.d/90mdraid/mdraid_start.sh b/modules.d/90mdraid/mdraid_start.sh
28ab1c
index 77e843d7..ed8d8dfe 100755
28ab1c
--- a/modules.d/90mdraid/mdraid_start.sh
28ab1c
+++ b/modules.d/90mdraid/mdraid_start.sh
28ab1c
@@ -7,7 +7,6 @@ _md_start() {
28ab1c
     local _path_s
28ab1c
     local _path_d
28ab1c
     local _md="$1"
28ab1c
-    local _offroot="$2"
28ab1c
 
28ab1c
     _udevinfo="$(udevadm info --query=env --name="${_md}")"
28ab1c
     strstr "$_udevinfo" "MD_LEVEL=container" && continue
28ab1c
@@ -19,7 +18,7 @@ _md_start() {
28ab1c
     # inactive ?
28ab1c
     [ "$(cat "$_path_s")" != "inactive" ] && continue
28ab1c
 
28ab1c
-    mdadm $_offroot -R "${_md}" 2>&1 | vinfo
28ab1c
+    mdadm -R "${_md}" 2>&1 | vinfo
28ab1c
 
28ab1c
     # still inactive ?
28ab1c
     [ "$(cat "$_path_s")" = "inactive" ] && continue
28ab1c
@@ -30,14 +29,11 @@ _md_start() {
28ab1c
 }
28ab1c
 
28ab1c
 _md_force_run() {
28ab1c
-    local _offroot
28ab1c
     local _md
28ab1c
     local _UUID
28ab1c
     local _MD_UUID=$(getargs rd.md.uuid -d rd_MD_UUID=)
28ab1c
     [ -n "$_MD_UUID" ] || getargbool 0 rd.auto || return
28ab1c
 
28ab1c
-    _offroot=$(strstr "$(mdadm --help-options 2>&1)" offroot && echo --offroot)
28ab1c
-
28ab1c
     if [ -n "$_MD_UUID" ]; then
28ab1c
         _MD_UUID=$(str_replace "$_MD_UUID" "-" "")
28ab1c
         _MD_UUID=$(str_replace "$_MD_UUID" ":" "")
28ab1c
@@ -58,13 +54,13 @@ _md_force_run() {
28ab1c
             # check if we should handle this device
28ab1c
             strstr " $_MD_UUID " " $_UUID " || continue
28ab1c
 
28ab1c
-            _md_start "${_md}" "${_offroot}"
28ab1c
+            _md_start "${_md}"
28ab1c
         done
28ab1c
     else
28ab1c
         # try to force-run anything not running yet
28ab1c
         for _md in /dev/md[0-9_]*; do
28ab1c
             [ -b "$_md" ] || continue
28ab1c
-            _md_start "${_md}" "${_offroot}"
28ab1c
+            _md_start "${_md}"
28ab1c
         done
28ab1c
     fi
28ab1c
 }
28ab1c
diff --git a/modules.d/90mdraid/parse-md.sh b/modules.d/90mdraid/parse-md.sh
28ab1c
index 4d9baa52..2cce9769 100755
28ab1c
--- a/modules.d/90mdraid/parse-md.sh
28ab1c
+++ b/modules.d/90mdraid/parse-md.sh
28ab1c
@@ -60,5 +60,3 @@ if ! getargbool 1 rd.md.ddf -n rd_NO_MDDDF -n noddfmd -n nodmraid; then
28ab1c
     info "no MD RAID for SNIA ddf raids"
28ab1c
     udevproperty rd_NO_MDDDF=1
28ab1c
 fi
28ab1c
-
28ab1c
-strstr "$(mdadm --help-options 2>&1)" offroot && udevproperty rd_MD_OFFROOT=--offroot
28ab1c