Comment 19 for bug 1729145

Revision history for this message
Ryan Harper (raharper) wrote : Re: [Bug 1729145] Re: /dev/bcache/by-uuid links not created after reboot

It looks like there is some ordering issues:

This is a grep through /run/udev/links ; these are checked by udev-dev

# find . -name 'b250*'
./\x2fdisk\x2fby-uuid\x2f0a270acb-56b8-4498-8bad-b3bb149fe869/b250:1
./\x2fdisk\x2fby-uuid\x2f92b0868d-7e56-4956-8e55-2c90ebee4a72/b250:0
./\x2fbcache\x2fby-uuid\x2f92d882d8-38cd-4537-847b-6f9c40ba67b4/b250:1
./\x2fbcache\x2fby-uuid\x2f57e009b1-6bf4-42ea-abe0-334b10941a0b/b250:0

So both /dev/bcache/by-uuid and /dev/disk/by-uuid both point to the bcache
device (b250:0)

udevd shows this:

Nov 30 23:39:10.738290 ubuntu systemd-udevd[465]: LINK
'disk/by-uuid/0a270acb-56b8-4498-8bad-b3bb149fe869'
/lib/udev/rules.d/60-persistent-storage.rules:79
Nov 30 23:39:10.738304 ubuntu systemd-udevd[465]: update old name,
'/dev/bcache/by-uuid/92d882d8-38cd-4537-847b-6f9c40ba67b4' no longer
belonging to '/devices/virtual/block/bcache1'
Nov 30 23:39:10.738321 ubuntu systemd-udevd[465]: no reference left, remove
'/dev/bcache/by-uuid/92d882d8-38cd-4537-847b-6f9c40ba67b4'
Nov 30 23:39:10.738361 ubuntu systemd-udevd[465]: found 'b250:1' claiming
'/run/udev/links/\x2fdisk\x2fby-uuid\x2f0a270acb-56b8-4498-8bad-b3bb149fe869'
Nov 30 23:39:10.738370 ubuntu systemd-udevd[465]: creating link
'/dev/disk/by-uuid/0a270acb-56b8-4498-8bad-b3bb149fe869' to '/dev/bcache1'
Nov 30 23:39:10.738380 ubuntu systemd-udevd[465]: preserve already existing
symlink '/dev/disk/by-uuid/0a270acb-56b8-4498-8bad-b3bb149fe869' to
'../../bcache1'
Nov 30 23:39:10.743215 ubuntu systemd-udevd[487]: LINK
'disk/by-uuid/92b0868d-7e56-4956-8e55-2c90ebee4a72'
/lib/udev/rules.d/60-persistent-storage.rules:79
Nov 30 23:39:10.743228 ubuntu systemd-udevd[487]: update old name,
'/dev/bcache/by-uuid/57e009b1-6bf4-42ea-abe0-334b10941a0b' no longer
belonging to '/devices/virtual/block/bcache0'
Nov 30 23:39:10.743247 ubuntu systemd-udevd[487]: no reference left, remove
'/dev/bcache/by-uuid/57e009b1-6bf4-42ea-abe0-334b10941a0b'
Nov 30 23:39:10.743291 ubuntu systemd-udevd[487]: found 'b250:0' claiming
'/run/udev/links/\x2fdisk\x2fby-uuid\x2f92b0868d-7e56-4956-8e55-2c90ebee4a72'
Nov 30 23:39:10.743302 ubuntu systemd-udevd[487]: creating link
'/dev/disk/by-uuid/92b0868d-7e56-4956-8e55-2c90ebee4a72' to '/dev/bcache0'
Nov 30 23:39:10.743312 ubuntu systemd-udevd[487]: preserve already existing
symlink '/dev/disk/by-uuid/92b0868d-7e56-4956-8e55-2c90ebee4a72' to
'../../bcache0'

It would seem that the 'no longer belonging to ...bcache1' is the trigger
for the removal
however, 250:1 is indeed bcache1 device.

# ls -al /dev/bcache1
brw-rw---- 1 root disk 250, 1 Nov 30 23:39 /dev/bcache1

Looking at the systemd/udev/udev-event.c it appears that for entries in
the current udev database that don't have a new event associated with them
get the call to remove the old link

void udev_event_execute_rules()
  ...
  if (major(udev_device_get_devnum(dev)) > 0) {
                        bool apply;

                        /* remove/update possible left-over symlinks from
old database entry */
                        if (event->dev_db != NULL)
                                udev_node_update_old_links(dev,
event->dev_db);

Will need to crawl through the db to see what the the event->dev_db entry
is and where that get's set.

On Thu, Nov 30, 2017 at 2:41 PM, Dmitrii Shcherbakov <
<email address hidden>> wrote:

> Looks like masking systemd-udevd removes this behavior. Need to figure
> out where it actually clears everything out.
>
> ubuntu@maas-xenial4:~$ sudo systemctl mask systemd-udevd
> 11:32 PM Created symlink from /etc/systemd/system/systemd-udevd.service
> to /dev/null.
>
> # reboot
>
> ubuntu@maas-xenial4:~$ ls /dev/bcache/by-uuid/
> 2963855b-3d2b-4387-abd1-3ae788919de4 727212eb-0f0b-4d20-9191-f0577a38454e
> 835afacf-6213-48a9-864c-43733822668b aa04ab39-a42c-446f-aff5-addbd9c80e06
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1729145
>
> Title:
> /dev/bcache/by-uuid links not created after reboot
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/ubuntu/+source/linux/+bug/
> 1729145/+subscriptions
>