mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-11 19:00:02 +01:00
Due to internal retry-overengineering in libdevmapper, some dm-ioctl failures can disappear. One such case is when there is a device creation race and DM device is created but reload fails. this can heppen because some block device used in table mapping is already claimed (it needs exclusive access for bdev_open in kernel). The kernel ioctl properly returns EBUSY, this errno is lost in libdevmapper (dm_task_get_errno returns 0). While this should be solved by libdevampper, we need some reliable way on older systems to properly report "busy" error instead of overloaded "invalid" error. With modified reproducer (see check_concurrent in very compat test), this situation can happen quite often. This patch modifies dm_create_device to return ENODEV only if dm-ioctl also reports no device (ENXIO); following dm status reports ENODEV and also some referenced device is no longer accesible through stat(). In all other cases we return EBUSY. Command line translates EBUSY and EEXIST to the same return vaules, for API users it now returns EBUSY instead of generic EINVAL. IOW, if device activation returns EEXIST or EBUSY, device-mapper cannot create the device because it already exits (EEXIST) or some referenced device is claimed by other subystem (EBUSY) and mapping table cannot be created.
86 KiB
86 KiB