File 0515-90kernel-modules-also-add-block-device-driver-revers.patch of Package dracut.12460

From a929c6f1b19cc945c119802feff2d8e111954f5c Mon Sep 17 00:00:00 2001
From: Daniel Molkentin <dmolkentin@suse.com>
Date: Thu, 20 Apr 2017 21:54:38 +0200
Subject: [PATCH] 90kernel-modules: also add block device driver reverse
 dependencies

The code finds relevant modules by symbol. Some drivers, such as
the hisi_sas has two slightly different implementations with
a common backend which contain the relevant symbols. However,
we also need to include the modules that depend on these
implementations.

Ex: hisi_sas_v{1,2}_hw -> hisi_sas_main

We use a simple reverse lookup for all modules via modules.dep to
include direct reverse dependencies.

Reference: bnc#1034597
---
 modules.d/90kernel-modules/module-setup.sh | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
index 67d0e01e..bc00991d 100755
--- a/modules.d/90kernel-modules/module-setup.sh
+++ b/modules.d/90kernel-modules/module-setup.sh
@@ -3,6 +3,28 @@
 # called by dracut
 installkernel() {
     if [[ -z $drivers ]]; then
+        # modules with symbols might have abstractions that depend on them, so let's add those
+        add_rev_deps() {
+            local _module
+            local _line
+            [[ -f "$srcmods/modules.dep" ]] || return 0
+            while read _module; do
+                local _mod
+                local _deps
+                _module=${_module##$srcmods/}
+                printf "%s\n" "$_module"
+                egrep ".*:.*$_module.*" $srcmods/modules.dep | (
+                    local _OLDIFS=$IFS
+                    IFS=:
+                    while read _mod _deps; do
+                        printf "%s\n" "$srcmods/$_mod"
+                    done
+                    IFS=$_OLDIFS
+                )
+            done | sort -u
+            return 0
+        }
+
         block_module_filter() {
             local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host'
             # subfunctions inherit following FDs
@@ -65,7 +87,7 @@ installkernel() {
         instmods virtio virtio_blk virtio_ring virtio_pci virtio_scsi \
             "=drivers/pcmcia" =ide "=drivers/usb/storage"
 
-        find_kernel_modules  |  block_module_filter  |  instmods
+        find_kernel_modules | block_module_filter | add_rev_deps | instmods
 
         # if not on hostonly mode, install all known filesystems,
         # if the required list is not set via the filesystems variable
-- 
2.12.0

openSUSE Build Service is sponsored by