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
udev: skip disk/by-uuid for bcache devices #16317
Conversation
blkid reports bcache superblock dev.uuid as a filesystem UUID but it actually is not a filesystem, it's the UUID of the backing device, which is maintained at /dev/bcache/by-uuid instead of /dev/disk/by-uuid. Fixes: https://launchpad.net/bugs/1861941
|
Hmm, isn't this a bug in liblklid then? i.e. it probably should report this UUID as file system UUID if it actually isn't. @karelzak what's your take on this? |
|
How can not creating links in The real problem is that current (upstream) bcache rules rely on and kernel block layer sends At which point Another possible fix (although it depends on exact sequence of events) is to use
This is not a problem here. Changing udev property name will break unknown number of programs. blkid returns enough information to clearly identify bcache as bcache if needed ( |
Analysis here: https://bugs.launchpad.net/ubuntu/+source/linux-signed/+bug/1861941/comments/27 But the short of it is: creating a bcache device on top of an empty disk will create a by-uuid symlink pointing to bcache backing device as blkid reports FS_UUID with the bcache dev.uuid value which is not a filesystem uuid. This causes two separate block devices to use the same UUID and when we create a filesystem, the FS_UUID Of the fs will remove the original /dev/bcache/by-uuid symlink when it should not. Then when after running mkfs.ext4 on bcache0 blkid will then report the ext4 FS_UUID instead of the dev.uuid update the symlink to the filesystem UUID and point to bcache0; and udev will claim that nothing owns the /dev/bcache/by-uuid symlink any more and remove /dev/bcache/by-uuid/<dev.uuid> link since it had two devices (vdb and bcache0) using the same UUID. IMO, blkid should not report an FS_UUID for devices with a bcache header using the dev.uuid field of bcache; that's a device id, not related to the content it is caching.
Indeed it does, but the persistent storage rules will create a /dev/disk/by-uuid symlink for ID_FS_USAGE=other and if ID_FS_UUID_ENC non-empty. The attached patch skips this for bcache backing devices only. The alternative to changing the rules file is to see if blkid should not emit FS_UUID_ENC for bcache backing devices which do not have a filesystem on them. I suspect to do that, blkid would need to detect the bcache device type (sb.version) and then seek past the bcache header to check for any fs magic present. |
Yes. The changes to the bcache udev rules work around this kernel issue; it's certainly going to be more reliable in the face of different kernel versions. We still need either blkid to not report ID_FS_UUID_ENC on bcache backing devices, or these changes to the rules to skip over attempting to provide by-uuid symlinks for bcache backing devices. When I tested with just the bcache rule changes, I would still get broken/missing /dev/disk/by-uuid links due to the UUID change on probing of the backing device (with and without a fileystem on the backing device). |
So the problem of missing
I do not understand what you mean. Here is what I get on openSUSE Timbleweed which has reasonably current versions of software: So content of If the above is wrong from your point of view, please explain why and what problem does it cause. If you see something different, show what you actually see and explain why you think it is upstream systemd/udev issue. |
The missing symlink is a persistent pointer to the bcache0 device that can be used directly. The /dev/bcache/by-uuid symlink is precisely the symlink we need which uses the backing device's dev.uuid (3266200b*) to point to the current usable block device (bcache0). While the probe change to the bcache rules is needed to consistently create the /dev/bcache/by-uuid symlink, the persistent-storage.rules is in conflict with the bcache rules, namely, if 60-persistent-storage.rules creates a content-based symlink (ext4 fs) to bcache0; then the 69-bcache.rules cannot create a different UUID (dev.uuid) symlink to bcache0. I don't fully understand (yet) why we cannot always have both, but I've not been successful in getting udev to provide both links like so consistently: /dev/bcache/by-uuid/3266200b-e093-41c0-b124-3721a9c8dec6 -> ../../bcache0 In openSUSE 15.1, I noticed that the 69-bcache.rules does not use bcache-probe and does not attempt to create any /dev/bcache/by-uuid symlinks. I added my changes for the 69-bcache.rules from the PR mentioned earlier, and leaving the 60-persistent-storage.rules as they result in correctly creating the /dev/bcache/by-uuid symlink, however the /dev/disk/by-uuid link to bcache0 (content based) is not present, and a simple trigger on bcache0 will then add the disk/by-uuid content link, but remove the /dev/bcache/by-uuid (dev.uuid) symlink. However everything can come up alright, such as after a reboot, but if one runs the rules against bcache0 then W.r.t to the provided patch, the /dev/bcache/by-uuid link stability is the primary goal and the patch is what I thought was the best way to achieve that. I'm happy to pursue other paths if there is an alternative that ensures /dev/bcache/by-uuid symlinks remain persistent. |
Anyway, there is no way how link on one device may prevent creation of link on another device unless rules for another device gets confused by it. As these rules are not part of systemd, I would say this should be closed here. |
I think there is a really strong argument that /dev/disk/by-uuid is meant for filesystem UUIDs. The the UUID reported for backing/caching devices aren't filesystems; To what end are we creating a FS UUID link to backing/caching devices then?
Indeed; with the full path the bcache-super-show; the trigger on bcache0 does not remove the link. Thanks!
I'd like to get a comment on whether the FS_UUID from blkid is correct for bcache backing/caching devices. |
This is what libblkid returns for bcache: See the "USAGE", the supported values are libblkid does not return information about filesystems only, it returns information about all on-disk formats. We use ID_FS_ prefix for historical reasons (think about it as about a namespace), but the tag
In some cases, we return more UUIDs -- for example for BTRFS or ZFS it returns Anyway, the current libblkid output is correct and provides a way how to identify the bcache. |
|
My understanding now is things are OK with udev and the rules provided with udev, but that the rules provides with bcache itself don't work as expected and |
For bcache there are at least two devices (backing, bcache) and optionally the Neither of these devices are accessed directly, and the superblock data When the backing device is registered in the bcache driver, it allocates the This is what the /dev/bcache/by-uuid/ rule/symlink is about; associating I don't feel the /dev/disk/by-uuid links to the backing/caching devices are
That would be useful. It is possible for the backing device to be empty; but that's not the common case;
The bcache header on the backing device is by default at 16 sectors (but controllable via make-bcache parameter); The other really interesting bit of info to extract (which isn't available |
Yeah. I had requested some feedback on the blkid export of bcache backing/caching devices UUIDs in /dev/disk/by-uuid which is ongoing.
This is correct; the upstream rules for bcache rely on the CACHED_UUID change event; however that's not always sent from the kernel. There's a PR, https://github.com/g2p/bcache-tools/pull/29/files which fixes (it needs an update to use the full-path to bcache-super-show.) It would be nice if we could drop the 69-bcache upstream rules altogether and have blkid export enough information to create the same persistent symlinks that 69-bcache rules intended to do. |
|
I am not sure I follow here entirely, not knowing bcache, but do I understand correctly that the remaining issues are between libblkid and bcache upstream, and that we thus can close this PR? Or what's the state of this? |
|
@raharper please, if you have something we need to improve in libblkid then report it again https://github.com/karelzak/util-linux/issues. I guess we can add more from The current prober code is pretty basic : https://github.com/karelzak/util-linux/blob/master/libblkid/src/superblocks/bcache.c |
|
Let's close this. As I understand what remains to be done is between blkid and bcache, and udev/systemd are all good. If I misunderstood things, let me know/reopen please. |
blkid reports bcache superblock dev.uuid as a filesystem UUID but it
actually is not a filesystem, it's the UUID of the backing device, which
is maintained at /dev/bcache/by-uuid instead of /dev/disk/by-uuid.
Fixes: https://launchpad.net/bugs/1861941