This article is an update on the LINBIT® team’s WinDRBD development work, particularly the WinDRBD 1.2 branch, since I first wrote this article in September, 2023. In brief, development work on the 1.2 branch was delayed because the team spent time (around 10 months) and effort getting WinDRBD 1.1 rock solid stable. The time and effort were worth it though and the positive results are backed up by our own internal testing, and the testing and feedback of WinDRBD users, including one customer with a deployment of more than 1000 nodes in production.
After achieving a “rock solid” status for the 1.1 branch, development work on WinDRBD 1.2 has progressed at a fast pace.
This article summarizes some of the highlights of this work and improvements the team has brought to the WinDRBD 1.2 branch.
Improving the Linux build system
The team improved the new Linux based build system of WinDRBD and related projects (such as drbd-utils
). Because of this work, building a complete WinDRBD .exe
installer package is now a matter of simply copying and pasting a 1-line command:
make pull-docker && make package-in-docker
By specifying the DRBD
directory you can build against drbd-9.1
rather than DRBD 9.0.
make DRBD=drbd-9.1
Currently you can build against either DRBD 9.0 or 9.1. Building against DRBD 9.2 is an upcoming feature.
Reworking the patch system
During the WinDRBD 1.2 branch improvement work, the team reworked the patch system. This consists of two steps.
Maintaining manual patches
The first step in reworking the patch system involves maintaining manual patches on a separate branch named something such as jt/windrbd-1.2-drbd-9.0
in the DRBD repository itself. The team reduced the number of these patches to only the absolutely necessary ones. This makes it so that less than 1% of the total DRBD® source code is manually patched. Here is the current diffstat
for the DRBD 9.0 branch:
13 files changed, 255 insertions(+), 124 deletions(-)
đź“ť NOTE: For some context, DRBD consists of over 50,000 lines of code.
Maintaining automatically applied patches
The second step of the patching system is a very small but powerful set of Coccinelle spatch
scripts that patch semantic differences to the DRBD source code. The build process automatically applies these patches.
The following list summarizes the Coccinelle patch scripts:
001-rcu_read_lock.cocci
:This script patches read locks in the DRBD code. In Windows, read locks might change the Interrupt Request Level (IRQL) of the machine so a patch that allows remembrance of the old state is required.002-spin_lock_irqrestore.cocci
:This patches DRBD code related to spinlocks. Certain variants of the Linux kernel spinlock API used in the DRBD code to support parallelism cannot be matched on the Windows platform. This patch takes care of that difference.003-ULONG_PTR.cocci
:This patch replaces all uses ofÂunsigned long
 by the WindowsÂĂ™LONG_PTR
 type. This happens because on Windows theÂunsigned long
 (andÂlong
) data types are always 32-bit, even on 64-bit platforms. Linux expects this to matchÂsizeof(void*)
 which is why WinDRBD needs this patch.- Additionally, the patch system imports many of the latest headers from ReactOS into the WinDRBD source code. Because the MinGW-w64 port of GNU tools to Windows only partially supports kernel development work, the LINBIT team had to take the ReactOS headers which support more features of the Windows kernel API than the headers included with MinGW-w64.
- ReactOS is fully supported as a target platform of WinDRBD. Because the Microsoft WinDbg debugger does not support reading symbols created with MinGW-w64 (aÂ
gcc
 variant) the team decided to support ReactOS as a development platform. By doing this, the team can debug WinDRBD with the GNU debugger (gdb
) at a source level. Even better, this also makes it possible to debug into the ReactOS kernel sources themselves. This sometimes helps the team understand how to best implement a certain API in the WinDRBD code. - From the Linux kernel, several headers and also C source code components have been imported. Here, the team tried to find a good point at which to use features required by DRBD and get them from the Linux kernel. This means that Linux kernel headers are partially imported into the WinDRBD repository but a patch removes unneeded symbols and inline functions so as to minimize dependencies. This also showed us that one day we might want to have the WinDRBD layer inside the Linux kernel tree. If WinDRBD was inside the Linux kernel tree, there would not be a need to import the headers.
- Many simpleÂ
drbdadm
 tests such asÂup
,Âdown
,Âprimary
,Âsecondary
,Âconnect
, andÂdisconnect
, already work well for the DRBD 9.0 based builds. Some others also work for the DRBD 9.1 based builds. The team is currently working on getting WinDRBD 1.2 with DRBD 9.0 and DRBD 9.1 as stable and feature complete as the WinDRBD 1.1 branch. However, this work might take several more months.
Conclusion
The LINBIT team spent much time getting the WinDRBD 1.1 branch as rock solid as possible. Numerous internal tests and user deployments have confirmed its stability. For this reason, the 1.1 branch is still the recommended WinDRBD branch to use in production deployments for high availability of Windows services and data.
Reaching production level stability on the 1.1 branch has freed up significant resources on the development side that allows work on the 1.2 branch to progress quickly. Also, you can now build WinDRBD 1.2 on Linux with a simple command (as opposed to building 1.1 which required a complex setup). Because WinDRBD 1.2 is easier to build, the LINBIT team considers the WinDRBD 1.2 branch more of a community project (at least more than the 1.1 branch was). With that in mind, the LINBIT team highly appreciates any form of contribution, be it a patch, a bug report, or simply testing the build process and providing feedback. You can find WinDRBD source code at the project’s GitHub page..
In my role as the WinDRBD lead developer, I will continue to keep you updated on the progress the LINBIT team and I make on WinDRBD development. The drbd-announce
email list or the release announcements category within the LINBIT Community Forum are also great ways that you can stay informed about new WinDRBD releases.