common/rc: allow the loop driver to be built into the kernel
PATCH 1/1 common/rc: allow the loop driver to be built into the kernel
A number of kernel modules used by blktests must be compiled as modules, since the module needs to be loaded with specific options, or part of the test is to exercise what what happens when the kernel module is loaded. This is not true for the loop driver, so add a new bash function, _have_kernel_module which works like _have_module but will not fail if the driver is compiled directly into the kernel.
--- common/rc | 10 +++++++++- tests/nvme/002 | 4 ++-- tests/nvme/003 | 4 ++-- tests/nvme/004 | 4 ++-- tests/nvme/005 | 6 +++--- tests/nvme/006 | 5 +++-- tests/nvme/008 | 5 +++-- tests/nvme/010 | 2 +- tests/nvme/012 | 2 +- tests/nvme/014 | 5 +++-- tests/nvme/015 | 4 ++-- tests/nvme/019 | 5 +++-- tests/nvme/021 | 5 +++-- tests/nvme/022 | 5 +++-- tests/nvme/023 | 5 +++-- tests/nvme/024 | 5 +++-- tests/nvme/025 | 5 +++-- tests/nvme/026 | 5 +++-- tests/nvme/027 | 5 +++-- tests/nvme/028 | 5 +++-- 20 files changed, 58 insertions(+), 38 deletions(-)
common/rc +9 -1
@@ -35,6 +35,14 @@ _have_module() { return 1 } +_have_kernel_module() { + if modprobe -n -q "$1" || test -d "/sys/module/$1" ; then + return 0 + fi + SKIP_REASON="$1 is not available as a module or built into the kernel" + return 1 +} + _have_module_param() { if ! modinfo -F parm -0 "$1" | grep -q -z "^$2:"; then SKIP_REASON="$1 module does not have parameter $2"
@@ -60,7 +68,7 @@ _have_src_program() { } _have_loop() { - _have_module loop && _have_program losetup + _have_kernel_module loop && _have_program losetup } _have_blktrace() {
tests/nvme/002 +2 -2
@@ -10,8 +10,8 @@ DESCRIPTION="create many subsystems and test discovery" requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_configfs } test() {
tests/nvme/003 +2 -2
@@ -11,8 +11,8 @@ DESCRIPTION="test if we're sending keep-alives to a discovery controller" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop \ - && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_configfs } test() {
tests/nvme/004 +2 -2
@@ -12,8 +12,8 @@ DESCRIPTION="test nvme and nvmet UUID NS descriptors" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_configfs } test() {
tests/nvme/005 +3 -3
@@ -11,9 +11,9 @@ DESCRIPTION="reset local loopback target" QUICK=1 requires() { - _have_module nvme-loop && _have_module nvmet && _have_module loop && \ - _have_configfs && _have_module nvme-core && \ - _have_module_param nvme-core multipath + _have_module nvme-loop && _have_module nvmet && \ + _have_kernel_module loop && _have_configfs && \ + _have_module nvme-core && _have_module_param nvme-core multipath } test() {
tests/nvme/006 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="create an NVMeOF target with a block device-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/008 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="create an NVMeOF host with a block device-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/010 +1 -1
@@ -10,7 +10,7 @@ DESCRIPTION="run data verification fio job on NVMeOF block device-backed ns" TIMED=1 requires() { - _have_program nvme && _have_fio && _have_module loop && \ + _have_program nvme && _have_fio && _have_kernel_module loop && \ _have_configfs && _have_module nvme-loop && \ _have_module nvmet }
tests/nvme/012 +1 -1
@@ -11,7 +11,7 @@ TIMED=1 requires() { _have_program nvme && _have_program mkfs.xfs && _have_program fio && \ - _have_module loop && _have_module nvmet && \ + _have_kernel_module loop && _have_module nvmet && \ _have_module nvme-loop && _have_configfs }
tests/nvme/014 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="flush a NVMeOF block device-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/015 +2 -2
@@ -10,8 +10,8 @@ DESCRIPTION="unit test for NVMe flush for file backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_configfs } test() {
tests/nvme/019 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe DSM Discard command on NVMeOF block-device ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/021 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe list command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/022 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe reset command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/023 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe smart-log command on NVMeOF block-device ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/024 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe smart-log command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/025 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe effects-log command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/026 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe ns-descs command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/027 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe ns-rescan command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
tests/nvme/028 +3 -2
@@ -10,8 +10,9 @@ DESCRIPTION="test NVMe list-subsys command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_module nvme-loop && _have_module loop && \ - _have_module nvmet && _have_configfs + _have_program nvme && _have_module nvme-loop && \ + _have_kernel_module loop && _have_module nvmet && \ + _have_configfs } test() {
Signature · 1 line
2.18.0.rc0
Quoted 6 lines · Theodore Ts'o
A number of kernel modules used by blktests must be compiled as modules, since the module needs to be loaded with specific options, or part of the test is to exercise what what happens when the kernel module is loaded. This is not true for the loop driver, so add a new bash function,
_have_kernel_modulewhich works like_have_modulebut will not fail if the driver is compiled directly into the kernel.
modprobe loop works for me if the module is built in, are you using one from busybox or something? According to strace, it looks at the depmod information (namely, /lib/modules/$(uname -r)/modules.builtin.bin).
Quoted 11 lines · Omar Sandoval
Quoted 6 lines · Theodore Ts'o
A number of kernel modules used by blktests must be compiled as modules, since the module needs to be loaded with specific options, or part of the test is to exercise what what happens when the kernel module is loaded. This is not true for the loop driver, so add a new bash function,
_have_kernel_modulewhich works like_have_modulebut will not fail if the driver is compiled directly into the kernel.
modprobe loopworks for me if the module is built in, are you using one from busybox or something? According to strace, it looks at the depmod information (namely, /lib/modules/$(uname -r)/modules.builtin.bin).
Ah, you're right. When I was first trying to use blktests, I was integrating it into my xfstests test appliance, and normally I build a completely module-free kernel. This allows me to boot directly into a kernel by using kvm's "--kernel /path/to/bzImage" option without having to deal with the extra work of trying to install modules into a test appliance.
So when I noticed that modprobe loop wasn't working, this was because I didn't have any of /lib/modules/($uname -r)/ in existence at all. After I patched blktests to not complain when modprobe loop was failing, I noticed that something like only 3 tests were being run, and when I looked at most of the tests, I realized that there was no way to avoid using modules for a large number of tests (at least not without doing a lot of work to enhance things like scsi_debug to be dynamically reconfigurable).
So you're right; there's no need for this patch. The chances that someone will only want to run the loop tests using !CONFIG_MODULES kernel are... remote. :-)
- Ted
Quoted 13 lines · Theodore Y. Ts'o
Quoted 11 lines · Omar Sandoval
Quoted 6 lines · Theodore Ts'o
A number of kernel modules used by blktests must be compiled as modules, since the module needs to be loaded with specific options, or part of the test is to exercise what what happens when the kernel module is loaded. This is not true for the loop driver, so add a new bash function,
_have_kernel_modulewhich works like_have_modulebut will not fail if the driver is compiled directly into the kernel.
modprobe loopworks for me if the module is built in, are you using one from busybox or something? According to strace, it looks at the depmod information (namely, /lib/modules/$(uname -r)/modules.builtin.bin).
Quoted 6 lines
Ah, you're right. When I was first trying to use blktests, I was integrating it into my xfstests test appliance, and normally I build a completely module-free kernel. This allows me to boot directly into a kernel by using kvm's "--kernel /path/to/bzImage" option without having to deal with the extra work of trying to install modules into a test appliance.
FWIW, I have a VM setup that uses --kernel and a virtfs mount in the guest to use modules without needing a manual install step:
https://github.com/osandov/osandov-linux#running-custom-kernel-builds.