Report netlink-map failures in its exit status #121

Merged
vitalif merged 1 commits from koolkhel/vitastor:nbd-netlink-map-status into master 2026-11-20 19:04:14 +03:00
Contributor

Description

netlink-map and netlink-revive forked before configuring the device, and the parent exited 0 at once. So a failed configuration (a busy device, no permission, no nbd netlink family) still returned 0, and the command could return before the device was set up.

Both map modes now fork once, before setting up the device, the way vitastor-ublk does. daemonize_fork(int *notifyfd) keeps the parent until the daemon sends the device number. The parent then prints /dev/nbdN and exits 0, or exits 1 if the daemon dies first. daemonize() is gone. In the ioctl map, the setup child no longer forks on its own, because the daemon is already detached. Failed tries on busy devices are reaped, and map /dev/nbdN now prints the device too.

Tested as root against a local 3-OSD cluster (tests/run_3osds.sh):

  • map (auto and explicit), map --foreground and netlink-map exit 0, print the device, and I/O works. A resize reaches the ioctl devices.
  • map and netlink-map onto a busy device exit 1 with the error and print nothing, and so does netlink-map --foreground. Before the change, netlink-map onto a busy device exited 0.
  • After unmap or netlink-unmap, the daemon exits within a second.

tests/test_img_online_resize.sh now checks that netlink-map onto its busy nbd device doesn't exit 0. That check fails without this change.

Contributor Name

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

CLA

### Description `netlink-map` and `netlink-revive` forked before configuring the device, and the parent exited 0 at once. So a failed configuration (a busy device, no permission, no nbd netlink family) still returned 0, and the command could return before the device was set up. Both map modes now fork once, before setting up the device, the way `vitastor-ublk` does. `daemonize_fork(int *notifyfd)` keeps the parent until the daemon sends the device number. The parent then prints `/dev/nbdN` and exits 0, or exits 1 if the daemon dies first. `daemonize()` is gone. In the ioctl `map`, the setup child no longer forks on its own, because the daemon is already detached. Failed tries on busy devices are reaped, and `map /dev/nbdN` now prints the device too. Tested as root against a local 3-OSD cluster (`tests/run_3osds.sh`): - `map` (auto and explicit), `map --foreground` and `netlink-map` exit 0, print the device, and I/O works. A resize reaches the ioctl devices. - `map` and `netlink-map` onto a busy device exit 1 with the error and print nothing, and so does `netlink-map --foreground`. Before the change, `netlink-map` onto a busy device exited 0. - After `unmap` or `netlink-unmap`, the daemon exits within a second. `tests/test_img_online_resize.sh` now checks that `netlink-map` onto its busy nbd device doesn't exit 0. That check fails without this change. ### 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-16 22:16:56 +03:00
netlink-map and netlink-revive forked before configuring the device, and
the parent exited 0 at once. So a failed configuration (a busy device,
no permission, no nbd netlink family) still returned 0, and the command
could return before the device was set up. Keep the parent until the
daemon sends the device number, and exit 1 if the daemon dies first.
vitalif reviewed 2026-11-17 10:33:20 +03:00
@@ -825,6 +829,41 @@ help:
exit(0);
}
// Like daemonize_fork(), but the parent prints the device and exits 0 only
Owner

Если хочется такое сделать, нужно скопипастить с ublk_server, там по идее такая же штука реализована уже, не нужно чтобы в двух файлах было 2 разных реализации примерно одного и того же, и также не надо чтобы было аж 4 функции - daemonize_fork, daemonize_reopen_stdio, daemonize_begin, daemonize_end

Если хочется такое сделать, нужно скопипастить с ublk_server, там по идее такая же штука реализована уже, не нужно чтобы в двух файлах было 2 разных реализации примерно одного и того же, и также не надо чтобы было аж 4 функции - daemonize_fork, daemonize_reopen_stdio, daemonize_begin, daemonize_end
koolkhel force-pushed nbd-netlink-map-status from d17688e154 to ca6aee9d77 2026-11-19 21:27:34 +03:00 Compare
vitalif merged commit 2fc65145fb into master 2026-11-20 19:04:14 +03:00
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#121
No description provided.