Show netlink-revived devices in vitastor-nbd ls #209

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

Description

ls listed a device only when /sys/block/nbdN/pid was a running map or netlink-map process. The kernel sets that pid on CONNECT and keeps it on RECONFIGURE. So after netlink-revive it names the dead process, and the netlink-revive command wasn't accepted anyway: ls showed nothing for a working device. Now such a device is looked up among the running netlink-revive processes in /proc.

The help and docs said netlink devices never show up in ls. They now say that the sysfs pid of a revived device stays the old one.

This change was the second commit of #155, on top of the backend identifier change. It does not depend on that change, so it comes here on its own and doesn't wait for #155. #155 will be rebased on this PR.

New tests/test_nbd_netlink_revive.sh (run_tests.sh, and a test.yml job generated with tests-to-yaml.pl): netlink-map, kill -9 of the daemon, netlink-revive, read the data back, then ls must show a live server other than the killed one. The test finds the daemon by its command line, not by /sys/block/nbdN/pid, which is a pid of the kernel's pid namespace. So it also works in a container with its own pid namespace. #155 adds its other-image and snapshot steps to this test.

Found: seen in a test run (kernel 6.8). After netlink-map, kill -9 of the daemon and netlink-revive, the device served I/O, but ls printed nothing.

Tested: tests/test_nbd_netlink_revive.sh in a VM (Ubuntu 24.04, kernel 6.8). It fails on master 54b8d2c0 with "ls doesn't show the revived /dev/nbd0" and passes with this commit. The same holds in a pid namespace of its own (unshare --pid --fork --mount-proc).

Contributor Name

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

CLA

### Description `ls` listed a device only when `/sys/block/nbdN/pid` was a running `map` or `netlink-map` process. The kernel sets that pid on CONNECT and keeps it on RECONFIGURE. So after `netlink-revive` it names the dead process, and the `netlink-revive` command wasn't accepted anyway: `ls` showed nothing for a working device. Now such a device is looked up among the running `netlink-revive` processes in `/proc`. The help and docs said netlink devices never show up in `ls`. They now say that the sysfs pid of a revived device stays the old one. This change was the second commit of #155, on top of the backend identifier change. It does not depend on that change, so it comes here on its own and doesn't wait for #155. **#155 will be rebased on this PR.** New `tests/test_nbd_netlink_revive.sh` (`run_tests.sh`, and a `test.yml` job generated with `tests-to-yaml.pl`): `netlink-map`, `kill -9` of the daemon, `netlink-revive`, read the data back, then `ls` must show a live server other than the killed one. The test finds the daemon by its command line, not by `/sys/block/nbdN/pid`, which is a pid of the kernel's pid namespace. So it also works in a container with its own pid namespace. #155 adds its other-image and snapshot steps to this test. Found: seen in a test run (kernel 6.8). After `netlink-map`, `kill -9` of the daemon and `netlink-revive`, the device served I/O, but `ls` printed nothing. Tested: `tests/test_nbd_netlink_revive.sh` in a VM (Ubuntu 24.04, kernel 6.8). It fails on master 54b8d2c0 with "ls doesn't show the revived /dev/nbd0" and passes with this commit. The same holds in a pid namespace of its own (`unshare --pid --fork --mount-proc`). ### 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-29 22:15:54 +03:00
ls listed a device only when /sys/block/nbdN/pid was a running map or
netlink-map process. The kernel sets that pid on CONNECT and keeps it on
RECONFIGURE, so after netlink-revive it names the dead process, and the
netlink-revive command wasn't accepted anyway: ls showed nothing for a
working device. Look such a device up among the running netlink-revive
processes in /proc.

The help and docs said netlink devices never show up in ls; say instead
that the sysfs pid of a revived device stays the old one.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u nbd-ls-revive:koolkhel-nbd-ls-revive
git checkout koolkhel-nbd-ls-revive
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#209
No description provided.