VDDK supports concurrent I/O to multiple virtual disks, with certain limitations:
- VixDiskLib_InitEx() should be called once per process, from the main thread.
- On Windows, backup applications should call VixDiskLib_InitEx at the very beginning of the program. As of VDDK 7.0, which introduced some thread local storage, all threads that call VixDiskLib functions must be created and initialized after calling VixDiskLib_InitEx. This is advised but not required for Linux.
- In the VixDiskLib_InitEx() function call, do not specify logging callbacks as NULL. This causes VixDiskLib to provide its default logging functions, which are not thread safe. If you are using VDDK in a multithreaded environment, you must provide your own thread-safe log functions.
- When you call VixDiskLib_Open() and VixDiskLib_Close(), VDDK initializes and uninitializes a number of libraries, some of which do not work if called from multiple threads. For example, this fails:
Thread 1: VixDiskLib_Open ...... VixDiskLib_Close Thread 2: ................................... VixDiskLib_Open ...... VixDiskLib_Close
The workaround is to use one designated thread to do all opens and closes, and to have other worker threads doing reads and writes. This diagram shows concurrent reads on two separate disk handles. Concurrent reads on the same disk handles are not allowed.
Open/Close Thread: VixDiskLib_Open ...... VixDiskLib_Open ...... VixDiskLib_Close ...... VixDiskLib_Close ...... (handle1) (handle2) (handle1) (handle2) I/O Thread 1: (owns handle1) VixDiskLib_Read ... VixDiskLib_Read ... I/O Thread 2: (owns handle2) VixDiskLib_Read ... VixDiskLib_Read ...