Bug 2010 - 执行modprobe --remove-dependencies卸载模块依赖不生效或把其他依赖模块安装上
Summary: 执行modprobe --remove-dependencies卸载模块依赖不生效或把其他依赖模块安装上
Status: RESOLVED BYDESIGN
Alias: None
Product: Anolis OS 23
Classification: Anolis OS
Component: Others (show other bugs) Others
Version: 23.0
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: xuchunmei
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-30 13:13 UTC by zhixin01
Modified: 2022-09-26 16:35 UTC (History)
5 users (show)

See Also:


Attachments
具体执行步骤 (268.45 KB, image/jpeg)
2022-08-30 13:13 UTC, zhixin01
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zhixin01 alibaba_cloud_group 2022-08-30 13:13:33 UTC
Created attachment 377 [details]
具体执行步骤

Description of problem:
执行modprobe --remove-dependencies卸载模块依赖不生效或把其他依赖模块安装上
具体步骤查看附件

Version-Release number of selected component (if applicable):
# cat /etc/os-release
NAME="Anolis OS"
VERSION="23"
ID="anolis"
VERSION_ID="23"
PLATFORM_ID="platform:an23"
PRETTY_NAME="Anolis OS 23"
ANSI_COLOR="0;31"
HOME_URL="https://openanolis.cn/"
BUG_REPORT_URL="https://bugzilla.openanolis.cn/"

# modprobe --version
kmod version 29
+ZSTD +XZ +ZLIB +LIBCRYPTO -EXPERIMENTAL

How reproducible:


Steps to Reproduce:
1.modprobe vfat,安装vfat模块
2.modprobe --remove-dependencies vfat,卸载vfat模块及依赖
3.卸载vfat模块及fat模块
4.modprobe --remove-dependencies vfat,卸载vfat模块及依赖

Actual results:
步骤2:卸载vfat模块及依赖失败(具体查看附件)
步骤4:未执行卸载,反而将vfat模块及fat模块安装上了(具体查看附件)

Expected results:
步骤2:卸载vfat模块及依赖成功
步骤4:卸载vfat模块及依赖成功

Additional info:
Comment 1 xuchunmei alibaba_cloud_group 2022-09-26 15:52:53 UTC
查看modprobe的man手册:
       -r, --remove
           This option causes modprobe to remove rather than insert a module. If the modules it depends on are also unused, modprobe will try to remove them too. Unlike insertion, more than one module can be specified
           on the command line (it does not make sense to specify module parameters when removing modules).

modprobe -r会卸载内核模块,同时如果该内核模块依赖的模块没有被引用,modprobe也会同步删除。

从lsmod信息查看,vfat依赖fat,加载时自动加载fat。
# lsmod | grep fat
vfat                   20480  0
fat                    86016  1 vfat

卸载后fat也会被自动卸载:
# modprobe -r vfat
# lsmod | grep fat
# echo $?
1

modprobe -r可以同时删除依赖,不必使用--remove-dependencies
Comment 2 xuchunmei alibaba_cloud_group 2022-09-26 16:35:39 UTC
从代码逻辑上看,加上--remove-dependencies是添加标记位,需要去获取模块的依赖项,单纯使用modprobe --remove-dependencies xxx并不会真正触发rmmod xxx操作。
这个行为在Anolis OS 8上也是同样的表现。

另外kmod已升级到30版本,--remove-dependencies选项已被Deprecated.
# modprobe --version
kmod version 30

# modprobe --help
Usage:
	modprobe [options] [-i] [-b] modulename
	modprobe [options] -a [-i] [-b] modulename [modulename...]
	modprobe [options] -r [-i] modulename
	modprobe [options] -r -a [-i] modulename [modulename...]
	modprobe [options] -c
	modprobe [options] --dump-modversions filename
Management Options:
	-a, --all                   Consider every non-argument to
	                            be a module name to be inserted
	                            or removed (-r)
	-r, --remove                Remove modules instead of inserting
	    --remove-dependencies   Deprecated: use --remove-holders
	    --remove-holders        Also remove module holders (use together with -r)
	-w, --wait <MSEC>           When removing a module, wait up to MSEC for
	                            module's refcount to become 0 so it can be
	                            removed (use together with -r)
	    --first-time            Fail if module already inserted or removed
	-i, --ignore-install        Ignore install commands
	-i, --ignore-remove         Ignore remove commands
	-b, --use-blacklist         Apply blacklist to resolved alias.
	-f, --force                 Force module insertion or removal.
	                            implies --force-modversions and
	                            --force-vermagic
	    --force-modversion      Ignore module's version
	    --force-vermagic        Ignore module's version magic