cloudbase / wnbd

Windows Ceph RBD NBD driver
GNU Lesser General Public License v2.1
57 stars 26 forks source link

driver: fix wsk initialization #108

Closed petrutlucian94 closed 1 year ago

petrutlucian94 commented 1 year ago

According to the MS docs, each successful WskRegister call must be followed by exactly one WskDeregister call with the same registration structure. The same applies to WskCaptureProviderNPI and WskReleaseProviderNPI.

The issue is that we're calling the KsInitialize wrapper for every new nbd connection, however there's a single KsDestroy call in the HwFreeAdapterResources hook.

Another issue is that the KsDestroy call will be performed regardless of the previous KsInitialize status. We'd basically be destroying a structure that wasn't properly initialized. This seems to cause crashes on older Windows hosts that do not provide the WSK API that we're using.

This change fixes WSK initialization and cleanup.

Worth mentioning that we're most likely going to move the nbd client to userspace eventually, which will significantly simplify the driver and drop WSK usage (currently limited to NBD).

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