Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libdevmapper: Unlink the symlinks under /dev/mapper before destroying a device #66

Closed
DemiMarie opened this issue Feb 6, 2022 · 1 comment

Comments

@DemiMarie
Copy link

Before destroying a device-mapper device, libdevmapper should delete the symlink for that device under /dev/mapper. This avoids race conditions by ensuring that opening /dev/mapper/somedevice always returns the correct device if it succeeds, even if the major and minor number of the block device are later reused. Relying on udev for this is racy, since udev will not delete the symlink until after the device has been destroyed.

@zkabelac
Copy link
Contributor

zkabelac commented Feb 6, 2022

lvm2 has nothing to do (nowadays) with content of /dev directory. It's fully managed by udev.
When device is 'destroyed' - the event is processed first by kernel (so /dev/dm-XXX is removed) and later processed by userspace chain with its udev rules - and at this point any symlinks are being removed.

And yes - relying on udev IS racy by design - user needs to use other synchronization methods - aka in term of Lvm2 usage - open devices after they are activated and do not try to access them before you deactivate them (you cannot deactivate device in use).

Close as this is currently compliant with existing design.

@zkabelac zkabelac closed this as completed Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants