Automatic rebuilding of the Kernel Module

If a backup client has many files to backup, merely finding all the files that have been modified since the last backup takes much time. IBM solves this by offering a kernel module that keeps track of modified files. They call this 'journaling', not to be confused with the filesystem journal itself. In order to provide a host with a working kernel module, they propose that the sysadmin recompile the module on every host, every time the kernel is upgraded. Right...

I made a DKMS module that does this automatically.

The Makefile depends on RELNUM being set to the package version, even in 'Make clean'. Fix the Makefile by setting RELNUM inside it:

sed -i '/^RELNUM/ d ; /^MODULE_NAME/ aRELNUM=' Makefile

Do make sure it's the right RELNUM!

The Makefile distinguishes between compiling inside and outside the kernel tree. When Make is called from outside the kernel tree, KERNELVERSION is not set. The Makefile reacts by adding -D_KERNEL to the compiler options (which #defines _KERNEL in the sources). Inside mem.c, this defines getmem as PF_GetMem (which is defined in pf.c).

If OTOH the module is compiled from inside the kernel tree, KERNELVERSION is indeed set. The Makefile therefore doesn't set _KERNEL, and as a result, in mem.c, getmem is defined as malloc.

I do not understand the intention of the inside-the-kernel behaviour. When inside the kernel, one does not use malloc; one uses kmalloc or vmalloc (as PF_GetMem dutifully does). The compiler finds it silly too: malloc is not available, so mem.c doesn't compile any more. (Stdlib.h is not included either, so malloc is unknown, as it should be.)

A solution would be to always build outside the kernel source tree. After all, that is what IBM describes doing in their instructions: build manually on a system that has the new kernel running already. But that is impossible, precisely because IBM assumes the kernel to build for is the running kernel. (THat in itself is bad: maintenance now involves installing the new kernel, rebooting, then compiling the new module, and then either manually installing it and praying it will run automatically next boot, or performing another reboot.

So I use the alternative solution: build inside the kernel tree, but add the compiler flags from the IBM Makefile:

sed -i '/^ifneq/,/^else/ s/^/#/ ; 0,/^debpackage/! s/^endif/#endif/' Makefile

DKMS packages by default build modules for

They do *NOT* build for *all* kernels. If you want that, do: >literallayout>ls /var/lib/initramfs-tools/|xargs -i dkms install tivsm-filepath-dkms/ -k {} (The first part just lists the kernels. The second part installs the module on them.)

ToDo: describe how to fetch the DKMS package and the other fixes from our repo.