From 7541e0390bb3708bb83484028d9284895c2fa3b3 Mon Sep 17 00:00:00 2001 From: Yury Luneff Date: Mon, 23 Nov 2026 13:43:08 +0300 Subject: [PATCH] Open the device read-only in vitastor-nbd unmap vitastor-nbd unmap opened the NBD device read-write only to send NBD_DISCONNECT. Closing a writable descriptor makes udev open the device, and after the disconnect request the kernel then rereads the partition table. If vitastor-nbd does not answer at that moment, for example because it is stopped, udevd hangs in that read with the device's open lock held, and the close in unmap waits for the same lock. NBD_DISCONNECT needs no write access. --- src/client/nbd_proxy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/nbd_proxy.cpp b/src/client/nbd_proxy.cpp index 26b6c6f9..cd247cbe 100644 --- a/src/client/nbd_proxy.cpp +++ b/src/client/nbd_proxy.cpp @@ -505,7 +505,8 @@ help: } // Run unmap snprintf(path, sizeof(path), "/dev/nbd%d", dev_num); - int r, nbd = open(path, O_RDWR); + // Not O_RDWR: closing a writable descriptor makes udev rescan the device + int r, nbd = open(path, O_RDONLY); if (nbd < 0) { perror("open"); -- 2.47.3