mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 19:19:32 +03:00
scripts: zfs.sh: unload zfs with dependencies
Reviewed-by: Tony Hutter <hutter2@llnl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13274
This commit is contained in:
parent
d18da59d30
commit
469b8481aa
@ -18,6 +18,7 @@ STACK_TRACER="no"
|
|||||||
|
|
||||||
ZED_PIDFILE=${ZED_PIDFILE:-/var/run/zed.pid}
|
ZED_PIDFILE=${ZED_PIDFILE:-/var/run/zed.pid}
|
||||||
LDMOD=${LDMOD:-/sbin/modprobe}
|
LDMOD=${LDMOD:-/sbin/modprobe}
|
||||||
|
DELMOD=${DELMOD:-/sbin/modprobe -r}
|
||||||
|
|
||||||
KMOD_ZLIB_DEFLATE=${KMOD_ZLIB_DEFLATE:-zlib_deflate}
|
KMOD_ZLIB_DEFLATE=${KMOD_ZLIB_DEFLATE:-zlib_deflate}
|
||||||
KMOD_ZLIB_INFLATE=${KMOD_ZLIB_INFLATE:-zlib_inflate}
|
KMOD_ZLIB_INFLATE=${KMOD_ZLIB_INFLATE:-zlib_inflate}
|
||||||
@ -110,10 +111,11 @@ check_modules_linux() {
|
|||||||
load_module_linux() {
|
load_module_linux() {
|
||||||
KMOD=$1
|
KMOD=$1
|
||||||
|
|
||||||
if [ "$VERBOSE" = "yes" ]; then
|
FILE=$(modinfo "$KMOD" 2>&1 | awk 'NR == 1 && /zlib/ && /not found/ {print "(builtin)"; exit} /^filename:/ {print $2}')
|
||||||
FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
|
[ "$FILE" = "(builtin)" ] && return
|
||||||
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
|
||||||
|
|
||||||
|
if [ "$VERBOSE" = "yes" ]; then
|
||||||
|
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
||||||
echo "Loading: $FILE ($VERSION)"
|
echo "Loading: $FILE ($VERSION)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -138,15 +140,7 @@ load_modules_freebsd() {
|
|||||||
load_modules_linux() {
|
load_modules_linux() {
|
||||||
mkdir -p /etc/zfs
|
mkdir -p /etc/zfs
|
||||||
|
|
||||||
if modinfo "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1; then
|
for KMOD in "$KMOD_ZLIB_DEFLATE" "$KMOD_ZLIB_INFLATE" $KMOD_SPL $KMOD_ZFS; do
|
||||||
modprobe "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if modinfo "$KMOD_ZLIB_INFLATE">/dev/null 2>&1; then
|
|
||||||
modprobe "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
for KMOD in $KMOD_SPL $KMOD_ZFS; do
|
|
||||||
load_module_linux "$KMOD" || return 1
|
load_module_linux "$KMOD" || return 1
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -157,24 +151,6 @@ load_modules_linux() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
unload_module_linux() {
|
|
||||||
KMOD=$1
|
|
||||||
|
|
||||||
NAME="${KMOD##*/}"
|
|
||||||
NAME="${NAME%.ko}"
|
|
||||||
|
|
||||||
if [ "$VERBOSE" = "yes" ]; then
|
|
||||||
FILE=$(modinfo "$KMOD" | awk '/^filename:/ {print $2}')
|
|
||||||
VERSION=$(modinfo "$KMOD" | awk '/^version:/ {print $2}')
|
|
||||||
|
|
||||||
echo "Unloading: $FILE ($VERSION)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
rmmod "$NAME" || echo "Failed to unload $NAME"
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
unload_modules_freebsd() {
|
unload_modules_freebsd() {
|
||||||
kldunload "$KMOD_FREEBSD" || echo "Failed to unload $KMOD_FREEBSD"
|
kldunload "$KMOD_FREEBSD" || echo "Failed to unload $KMOD_FREEBSD"
|
||||||
|
|
||||||
@ -186,32 +162,13 @@ unload_modules_freebsd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unload_modules_linux() {
|
unload_modules_linux() {
|
||||||
for KMOD in $KMOD_ZFS $KMOD_SPL; do
|
NAME="${KMOD_ZFS##*/}"
|
||||||
NAME="${KMOD##*/}"
|
NAME="${NAME%.ko}"
|
||||||
NAME="${NAME%.ko}"
|
$DELMOD "$NAME" || return
|
||||||
USE_COUNT=$(lsmod | awk '/^'"${NAME}"'/ {print $3}')
|
|
||||||
|
|
||||||
if [ "$USE_COUNT" = "0" ] ; then
|
|
||||||
unload_module_linux "$KMOD" || return 1
|
|
||||||
elif [ "$USE_COUNT" != "" ] ; then
|
|
||||||
echo "Module ${NAME} is still in use!"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if modinfo "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1; then
|
|
||||||
modprobe -r "$KMOD_ZLIB_DEFLATE" >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if modinfo "$KMOD_ZLIB_INFLATE">/dev/null 2>&1; then
|
|
||||||
modprobe -r "$KMOD_ZLIB_INFLATE" >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$VERBOSE" = "yes" ]; then
|
if [ "$VERBOSE" = "yes" ]; then
|
||||||
echo "Successfully unloaded ZFS module stack"
|
echo "Successfully unloaded ZFS module stack"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stack_clear_linux() {
|
stack_clear_linux() {
|
||||||
|
Loading…
Reference in New Issue
Block a user