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

Fix NVMe device path detection #41

Closed
wants to merge 1 commit into from

Conversation

abbaad
Copy link

@abbaad abbaad commented Sep 20, 2024

Under linux (under the persistent naming rules present in most distributions AFAIK), the NVMe device by-id symlinks point to the block device (e.g., /dev/nvme0n1) rather than the controller (/dev/nvme0) as assumed by original code.

This change fixes the NVMe device parsing, but rather than inelegantly trying to twiddle the string (where in principle the "namespace" portion might be more than the 2 characters "n1"), we query the udev database directly, and find the parent device's sysfs path.

Unfortunately, the test file test_00_data.py (which contained the same symlink naming bug) doesn't have a simple fix, so someone will have to patch it more deeply. Another disadvantage is, of course, that we're adding a new dependency on pyudev, which can be another point of failure.

On the other hand, pyudev might ultimately be the way forward, and a deeper refactor might clean up some of the uglier sysfs path munging. It may also make it easier to solve AMD autodetection.

Under linux (under the persistent naming rules present in most distributions AFAIK), the NVMe device by-id symlinks point to the block device (e.g., `/dev/nvme0n1`) rather than the controller (`/dev/nvme0`) as assumed by original code.

This change fixes the NVMe device parsing, but rather than inelegantly trying to twiddle the string (where in principle the "namespace" portion might be more than the 2 characters "n1"), we query the udev database directly, and find the parent device's sysfs path.

Unfortunately, the test file `test_00_data.py` (which contained the same symlink naming bug) doesn't have a simple fix, so someone will have to patch it more deeply. Another disadvantage is, of course, that we're adding a new dependency on pyudev, which can be another point of failure.

On the other hand, pyudev might ultimately be the way forward, and a deeper refactor might clean up some of the uglier sysfs path munging. It may also make it easier to solve  AMD autodetection.
@abbaad
Copy link
Author

abbaad commented Sep 20, 2024

If pyudev is not desired as a dependency, then of course the string parsing could work if you assume a two-character namespace (it's probably "n1" in 99% of cases).

@abbaad abbaad marked this pull request as draft September 22, 2024 01:14
@abbaad
Copy link
Author

abbaad commented Sep 22, 2024

Closing this PR. Please see updated #42.

@abbaad abbaad closed this Sep 22, 2024
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

Successfully merging this pull request may close these issues.

1 participant