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

/dev/disk/by-id enumeration and duplicate IDs #2

Open
tbzatek opened this issue Apr 24, 2023 · 2 comments
Open

/dev/disk/by-id enumeration and duplicate IDs #2

tbzatek opened this issue Apr 24, 2023 · 2 comments

Comments

@tbzatek
Copy link

tbzatek commented Apr 24, 2023

There's a known design shortcoming related to udev and symlinks where symlinks get randomly overwritten in case of duplicate identifiers. This for example concerns /dev/disk/by-XXX that is heavily used by lsscsi for enumeration. As a result identifiers may be missing in its output for some devices.

The test case for example is as follows:

# modprobe scsi_debug add_host=3 num_tgts=4
# lsscsi -i
[6:0:0:0]    disk    Linux    scsi_debug       0191  /dev/sda   333333330000036b0
[6:0:1:0]    disk    Linux    scsi_debug       0191  /dev/sdb   33333333000003a98
[6:0:2:0]    disk    Linux    scsi_debug       0191  /dev/sdc   -
[6:0:3:0]    disk    Linux    scsi_debug       0191  /dev/sde   33333333000004268
[7:0:0:0]    disk    Linux    scsi_debug       0191  /dev/sdd   33333333000003e80
[7:0:1:0]    disk    Linux    scsi_debug       0191  /dev/sdf   -
[7:0:2:0]    disk    Linux    scsi_debug       0191  /dev/sdg   -
[7:0:3:0]    disk    Linux    scsi_debug       0191  /dev/sdh   -
[8:0:0:0]    disk    Linux    scsi_debug       0191  /dev/sdi   33333333000004650
[8:0:1:0]    disk    Linux    scsi_debug       0191  /dev/sdj   33333333000004a38
[8:0:2:0]    disk    Linux    scsi_debug       0191  /dev/sdk   33333333000004e20
[8:0:3:0]    disk    Linux    scsi_debug       0191  /dev/sdl   33333333000005208

Running udevadm trigger will regenerate the symlinks in different (random) order, resulting in the same number of missing identifiers on different devices each time.

Any suggestion for a workaround avoiding drastic changes to the lsscsi enumeration code?

@doug-gilbert
Copy link
Owner

Hard to know where to start with this one. Is fixing udev out of the question??
From the lsscsi perspective, after a long pause, there is finally work going on. The impetus for this is to add JSON output support but I am trying to clean up the code as I go. So drastic changes could be made. Perhaps if the documented procedure for the "-i" option fails (i.e. is about to output "-") then a fallback procedure could be undertaken.
Anyway, just committed and pushed my working version to this mirror.

@tbzatek
Copy link
Author

tbzatek commented Apr 25, 2023

I'm not sure how to handle this issue. This is certainly a corner case and of low importance I guess.

Fixing udev is unrealistic and there's far too many users of /dev/disk/by-id that rely on similar way of enumeration to match the device<->identifier pair. Since lsscsi depends on udev already (and related udev rules), it might make sense to use udev db (through bindings) directly. That's quite a bit of work though.

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