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

zfs create -V should wait for udev #7875

Closed
behlendorf opened this issue Sep 7, 2018 · 5 comments
Closed

zfs create -V should wait for udev #7875

behlendorf opened this issue Sep 7, 2018 · 5 comments
Labels
Component: ZVOL ZFS Volumes good first issue Indicates a good issue for first-time contributors Status: Stale No recent activity for issue

Comments

@behlendorf
Copy link
Contributor

behlendorf commented Sep 7, 2018

System information

Type Version/Name
Distribution Name any
Distribution Version any
Linux Kernel any
Architecture any
ZFS Version master
SPL Version master

Describe the problem you're observing

Creation of the /dev/ device file for a volume is handled asynchronously on Linux by udev. This means that it's possible for the zfs create -V to return before udev has populated /dev/ with the required entry. This behavior complicates scripting since the caller is responsible for waiting on udev.

The proposed solution is to update zfs create -V to use libudev to block until udev has completed and created the entry. This should be the default behavior, and we should provide a way to request the asynchronous behavior for callers which can take advantage of it.

Describe how to reproduce the problem

zfs create -V 10G tank/volume

See issue #7863

@behlendorf behlendorf added good first issue Indicates a good issue for first-time contributors Component: ZVOL ZFS Volumes labels Sep 7, 2018
@bprotopopov
Copy link
Contributor

bprotopopov commented Sep 8, 2018

There are a few cases in addition to zfs create that could result in interaction with udev and creation of device nodes, e.g. zfs recv and zpool import. It would also be nice to address similar issues with destruction of device nodes that occurs as a result of zfs destroy and zpool export.

@jgallag88
Copy link
Contributor

It looks like only root can listen for udev events. Does ZoL support, or plan on someday supporting, delegating the ability to create volumes? If non-root users can create volumes, that would make using libudev trickier.

@loli10K
Copy link
Contributor

loli10K commented Sep 12, 2018

@jgallag88 #7381 "[WIP] Permit ZVOL creation by unprivileged users"

@behlendorf
Copy link
Contributor Author

That's definitely a possibility as @loli10K mentioned.

It looks like only root can listen for udev events.

@jgallag88 I'm pretty sure that isn't the case, at least on CentOS 7. You can see this for yourself by running udevadm monitor in a second terminal when creating a new volume.

$ sudo zfs create -V 10G tank/vol
$ udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent
...
KERNEL[126.605833] add      /devices/virtual/bdi/230:0 (bdi)
UDEV  [126.608094] add      /devices/virtual/bdi/230:0 (bdi)
KERNEL[126.626682] add      /devices/virtual/block/zd0 (block)
UDEV  [126.646514] add      /devices/virtual/block/zd0 (block)

@stale
Copy link

stale bot commented Aug 25, 2020

This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale No recent activity for issue label Aug 25, 2020
@stale stale bot closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ZVOL ZFS Volumes good first issue Indicates a good issue for first-time contributors Status: Stale No recent activity for issue
Projects
None yet
Development

No branches or pull requests

4 participants