Show NBD devices above a numbering gap in vitastor-nbd ls #193

Closed
koolkhel wants to merge 1 commits from koolkhel/vitastor:nbd-ls-gap into master
Contributor

Description

vitastor-nbd ls counted /sys/block/nbd0, nbd1, ... and stopped at the first missing number. netlink-map can create a device above nbds_max (netlink-map /dev/nbd1234 ...), and a device mapped with --nbd_destroy_on_disconnect disappears on unmap, so every device after such a gap was missing from ls. Now ls reads the nbd entries of /sys/block.

It is independent of #155: this PR changes which devices ls looks at, #155 changes how the server of a revived device is found. The two merge cleanly in either order.

Found: while writing a test that maps a high device number, ls did not list a working netlink-mapped /dev/nbd25978 (kernel 6.8, nbds_max 16). Reproduced on master 884727af.

Tested: new tests/test_nbd_ls.sh (added to run_tests.sh, test.yml regenerated with tests-to-yaml.pl) fails on master with "ls doesn't show /dev/nbdN" and passes with the fix (VM, kernel 6.8).

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description `vitastor-nbd ls` counted `/sys/block/nbd0`, `nbd1`, ... and stopped at the first missing number. `netlink-map` can create a device above `nbds_max` (`netlink-map /dev/nbd1234 ...`), and a device mapped with `--nbd_destroy_on_disconnect` disappears on unmap, so every device after such a gap was missing from `ls`. Now `ls` reads the nbd entries of `/sys/block`. It is independent of #155: this PR changes which devices `ls` looks at, #155 changes how the server of a revived device is found. The two merge cleanly in either order. Found: while writing a test that maps a high device number, `ls` did not list a working netlink-mapped `/dev/nbd25978` (kernel 6.8, `nbds_max` 16). Reproduced on master 884727af. Tested: new `tests/test_nbd_ls.sh` (added to `run_tests.sh`, `test.yml` regenerated with `tests-to-yaml.pl`) fails on master with "ls doesn't show /dev/nbdN" and passes with the fix (VM, kernel 6.8). ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-26 08:52:46 +03:00
ls counted /sys/block/nbd0, nbd1, ... and stopped at the first missing
number. netlink-map can create a device above nbds_max, and a device
mapped with --nbd_destroy_on_disconnect disappears on unmap, so devices
after such a gap were never listed. Read the nbd entries of /sys/block
instead.
Owner

Замержил без теста

Замержил без теста
vitalif closed this pull request 2026-11-27 19:02:41 +03:00

Pull request closed

Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#193
No description provided.