]> git.proxmox.com Git - mirror_zfs-debian.git/commitdiff
Unconditionally load core kernel modules
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 11 Nov 2010 18:00:39 +0000 (10:00 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 11 Nov 2010 19:38:25 +0000 (11:38 -0800)
Loading and unloading the zlib modules as part of the zfs.sh
script has proven a little problematic for a few reasons.

  * First, your kernel may not need to load either zlib_inflate
    or zlib_deflate.  This functionality may be built directly in
    to your kernel.  It depends entirely on what your distribution
    decided was the right thing to do.

  * Second, even if you do manage to load the correct modules you
    may not be able to unload them.  There may other consumers
    of the modules with a reference preventing the unload.

To avoid both of these issues the test scripts have been updated to
attempt to unconditionally load all modules listed in KERNEL_MODULES.
If the module is successfully loaded you must have needed it. If
the module can't be loaded that almost certainly means either it is
built in to your kernel or is already being used by another consumer.
In both cases this is not an issue and we can move on to the spl/zfs
modules.

Finally, by removing these kernel modules from the MODULES list
we ensure they are never unloaded during 'zfs.sh -u'.  This avoids
the issue of the script failing because there is another consumer
using the module we were not aware of.  In other words the script
restricts unloading modules to only the spl/zfs modules.

Closes #78

scripts/common.sh.in
zfs-script-config.sh.in

index 09ca818c32f14782e7f4bab8de384e238f373874..2583efcb209bb9b2e109fc481caba0629180a918 100644 (file)
@@ -11,7 +11,8 @@ SCRIPT_CONFIG=zfs-script-config.sh
 if [ -f "${basedir}/../${SCRIPT_CONFIG}" ]; then
 . "${basedir}/../${SCRIPT_CONFIG}"
 else
-MODULES=(zlib_deflate spl splat zavl znvpair zunicode zcommon zfs)
+KERNEL_MODULES=(zlib_deflate zlib_inflate)
+MODULES=(spl splat zavl znvpair zunicode zcommon zfs)
 fi
 
 PROG="<define PROG>"
@@ -162,7 +163,7 @@ load_module() {
                echo "Loading ${NAME} ($@)"
        fi
 
-       ${LDMOD} $* || ERROR="Failed to load $1" return 1
+       ${LDMOD} $* &>/dev/null || ERROR="Failed to load $1" return 1
 
        return 0
 }
@@ -170,6 +171,10 @@ load_module() {
 load_modules() {
        mkdir -p /etc/zfs
 
+       for MOD in ${KERNEL_MODULES[*]}; do
+               load_module ${MOD}
+       done
+
        for MOD in ${MODULES[*]}; do
                local NAME=`basename ${MOD} .ko`
                local VALUE=
index 5ded6dc8b1dda984514b4cb399fec3a6d14757fb..db4a846542e18c4f623c0a5560f2e669e2067c92 100644 (file)
@@ -39,6 +39,7 @@ LDMOD=/sbin/insmod
 
 KERNEL_MODULES=(                                      \
         ${KERNELMOD}/lib/zlib_deflate/zlib_deflate.ko \
+        ${KERNELMOD}/lib/zlib_inflate/zlib_inflate.ko \
 )
 
 SPL_MODULES=(                                         \
@@ -59,7 +60,6 @@ ZPIOS_MODULES=(                                       \
 )
 
 MODULES=(                                             \
-        ${KERNEL_MODULES[*]}                          \
         ${SPL_MODULES[*]}                             \
         ${ZFS_MODULES[*]}                             \
 )