-
Notifications
You must be signed in to change notification settings - Fork 2
Usage
This page provides a guide for setting up and using the testing block device, as well as interacting with the library API.
You can build both the lib and block dev by running
make allor just make. After compiling, module object files lz4e_compress.ko, lz4e_decompress.ko and lz4e_bdev.ko
can be found in the output directory build.
If you wish to build only the library you can run:
make libIt is also possible to build the block device separately by running:
make bdevAlthough, it requires symbols obtained from compiling the library.
Following commands require root privileges. If you wish to run using sudo it is recommended to use -E flag
to preserve the current environment.
After compiling the modules, they can be dynamically inserted into the running kernel (via insmod) by calling
make insertmake lib_insertmake bdev_insertfor all modules, library, or the block device respectively.
Alternatively, you can install them into the modules directory of your kernel by running one of the following:
make installmake lib_installmake bdev_installAfter that, the modules can be inserted using modprobe.
After your work is done, you can remove the modules from the kernel by running (as root or with sudo -E):
make removemake lib_removemake bdev_removeTo clear the output directory build, you can run:
make cleanTo use the functions described in API in your own code, modules lz4e_compress and lz4e_decompress must be
inserted into your kernel. After that, to be able to access exported symbols you can either:
- compile your module against ours using a top-level Makefile/Kbuild file;
- set
KBUILD_EXTRA_SYMBOLSvariable in your Makefile to contain an absolute path toModule.symversfile of the built library.
See more details: https://docs.kernel.org/kbuild/modules.html#symbols-from-another-external-module.
As examples for both cases, you can see how the block dev module is compiled when running make and make bdev:
After the symbols can be accessed by your module, to use functions provided by the header
lz4e.h
you can add it to your includes using gcc's -I flag, or by directly copying it into your sources.
After module lz4e_bdev is inserted into the kernel, its parameters can be accessed using sysfs:
/sys/module/lz4e_bdev/parameters
├── /sys/module/lz4e_bdev/parameters/mapper # create a proxy block device over the given one
├── /sys/module/lz4e_bdev/parameters/unmapper # remove the proxy block device
└── /sys/module/lz4e_bdev/parameters/stats # access I/O request statisticsFor example, you can create a block device by running:
echo -n "<path_to_underlying_device>" > /sys/module/lz4e_bdev/parameters/mapperTo remove the created device, run:
echo -n "unmap" > /sys/module/lz4e_bdev/parameters/unmapperTo print I/O statistics of device, use:
cat /sys/module/lz4e_bdev/parameters/statsAnd to reset the request statistics:
echo -n "reset" > /sys/module/lz4e_bdev/parameters/stats