The Linux® system call interface permits user-space applications to invoke functionality in the kernel, but what about invoking user-space applications from the kernel? Explore the usermode-helper API, and learn how to invoke user-space applications and manipulate their output.
[...]
The usermode-helper API is a simple API with a well-known set of options. For example, to create a process from user space, you commonly provide the name of the executable, the options for the executable, and a set of environment variables (refer to the man page for execve). The same applies for creating a process from the kernel.
[...]
One of the most straightforward applications of the usermode-helper API is loading kernel modules from kernel space. The function request_module encapsulates the functionality of the usermode-helper API and provides a simple interface. In a common usage model, the kernel identifies a device or needed service and makes a call to request_module to have the module loaded. Through the usermode-helper API, the module is loaded into the kernel via modprobe (the application invoked in user space via request_module).
A similar application to module loading is device hot-plugging (to add or remove devices at run time). This feature is implemented with the usermode-helper API, invoking the /sbin/hotplug utility in user space.
Bon, avec udev et tout, ces deux exemples sont carrément démodés. Mais c'est toujours utilisé par les cgroups ou DRBD, par exemple.
Dans le cas de DRBD, par exemple, le module noyau exécute drbdadm pour gérer les split-brain et autres événements désastreux : drbdadm split-brain
, drbdadm initial-split-brain
, drbdadm fence-peer
(outdated peer), drbdadm local-io-error
, etc. Notons que, pour cette même liste d'événements, DRBD permet de lancer des exécutables de notre choix pour les traiter. Voir https://www.drbd.org/en/doc/users-guide-84/re-drbdconf, section handlers.
Et c'est probablement pour cela que Ganeti demande à ce que l'on change le usermode_helper program de DRBD en /bin/true : les devs Ganeti ont posé comme postulat de ne jamais traiter automatiquement les cas de split-brain car il n'existe pas d'algorithme qui convienne à tout le monde ni qui permette d'identifier vraiment laquelle des copies est en moins piteux état. Quoi de mieux que /bin/true pour annihiler tout ça ?