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

Move nbd to userspace #122

Merged
merged 3 commits into from
May 22, 2023

Conversation

petrutlucian94
Copy link
Member

@petrutlucian94 petrutlucian94 commented May 16, 2023

Right now, WNBD provides two IO transmission channels:

  • nbd - initial implementation
  • DeviceIoControl based API - used by rbd-wnbd

rbd-wnbd no longer uses NBD, however we'll continue to offer the NBD client functionality for the following reasons:

  • one of the very few Windows NBD clients out there, pretty well received by the community
  • allows connecting to a variety of NBD servers, including qemu-nbd
  • useful for testing purposes

We'll move the NBD client to userspace (libwnbd.dll), leveraging the DeviceIoControl API for driver communication. Main benefits:

  • simplifies the driver and allows us to drop the ksocket dependency
  • 20% perf improvement (WSK is quite slow, especially on older Windows versions)
  • reduces the risk of crashes or security issues
  • easier to maintain

The only potential downside to be aware of is that the wnbd-client map command becomes blocking. We might add an option to run the daemon in a separate process, however it would be killed when the session ends (i.e. winrm or ssh session). To avoid this, Ceph daemons are spawned by a centralized Windows service, however we aren't going to add such a service for NBD, at least for now. Other workarounds include NSSM or spawning the process using the Win32_Process WMI class.

While at it, we're bumping the c++ version to c++20, which is supported by VS 2019. Among other things, it simplifies structure
initialization.

Signed-off-by: Lucian Petrut lpetrut@cloudbasesolutions.com

wnbd-client/cmd.cpp Outdated Show resolved Hide resolved
@petrutlucian94 petrutlucian94 force-pushed the move_nbd_to_userspace branch 2 times, most recently from 017405f to a8b6a14 Compare May 18, 2023 13:37
We're updating the default console logger to include timestamps
in the printed messages.

Note that rbd-wnbd already provides its own logger function that
includes timestamps.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
@petrutlucian94 petrutlucian94 force-pushed the move_nbd_to_userspace branch 2 times, most recently from c115d72 to 49db209 Compare May 19, 2023 12:59
Right now, WNBD provides two IO transmission channels:

* nbd - initial implementation
* DeviceIoControl based API - used by rbd-wnbd

rbd-wnbd no longer uses NBD, however we'll continue to offer
the NBD client functionality for the following reasons:

* one of the very few Windows NBD clients out there, pretty well
  received by the community
* allows connecting to a variety of NBD servers, including qemu-nbd
* useful for testing purposes

We'll move the NBD client to userspace (libwnbd.dll), leveraging
the DeviceIoControl API for driver communication. Main benefits:

* simplifies the driver and allows us to drop the ksocket dependency
* reduces the risk of crashes or security issues
* easier to maintain

While at it, we're bumping the c++ version to c++20, which is
supported by VS 2019. Among other things, it simplifies structure
initialization.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
Now that the nbd client implementation has been moved to libwnbd,
we can drop it from the driver.

We're keeping the WNBD_PROPERTIES structure mostly the same for
backwards compatibility reasons, except for a small change:
we're adding a separate flag to advertise the userspace nbd client
in order to avoid incorrect behavior with older driver versions
(e.g. having both libwnbd and the driver attempt to initiate
NBD connections).

The WNBD tests and CLI client are updated to use the libwnbd NBD
client implementation. One thing to note here is that the
"wnbd-client map" now becomes a blocking command, running the
daemon in background.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
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