Skip to content

Commit

Permalink
Kernel/Library - Fix ALLOW_IPC_BATCHING flag unset in kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Liryna committed Feb 18, 2024
1 parent 5c25310 commit aef92bc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dokan/dokan.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,10 @@ int DOKANAPI DokanCreateFileSystem(_In_ PDOKAN_OPTIONS DokanOptions,
DokanOptions->Options |= DOKAN_OPTION_ALLOW_IPC_BATCHING;
mainPullThreadCount = DOKAN_MAIN_PULL_THREAD_COUNT_MAX;
}
DbgPrintW(L"Dokan: Using %d main pull threads\n", mainPullThreadCount);
BOOLEAN allowIpcBatching =
(BOOLEAN)(DokanOptions->Options & DOKAN_OPTION_ALLOW_IPC_BATCHING);
DbgPrintW(L"Dokan: Using %d main pull threads with ipc batching: %d\n",
mainPullThreadCount, allowIpcBatching);
for (DWORD x = 0; x < mainPullThreadCount; ++x) {
PDOKAN_IO_EVENT ioEvent = PopIoEventBuffer();
if (!ioEvent) {
Expand All @@ -818,7 +821,7 @@ int DOKANAPI DokanCreateFileSystem(_In_ PDOKAN_OPTIONS DokanOptions,
return DOKAN_MOUNT_ERROR;
}
ioEvent->DokanInstance = dokanInstance;
QueueIoEvent(ioEvent, DokanOptions->Options & DOKAN_OPTION_ALLOW_IPC_BATCHING
QueueIoEvent(ioEvent, allowIpcBatching
? DispatchBatchIoCallback
: DispatchDedicatedIoCallback);
}
Expand Down Expand Up @@ -1109,6 +1112,9 @@ int DokanStart(_In_ PDOKAN_INSTANCE DokanInstance) {
if (DokanInstance->DokanOptions->Options & DOKAN_OPTION_DISPATCH_DRIVER_LOGS) {
eventStart.Flags |= DOKAN_EVENT_DISPATCH_DRIVER_LOGS;
}
if (DokanInstance->DokanOptions->Options & DOKAN_OPTION_ALLOW_IPC_BATCHING) {
eventStart.Flags |= DOKAN_EVENT_ALLOW_IPC_BATCHING;
}
if (driverLetter && mountManager &&
!CheckDriveLetterAvailability(DokanInstance->MountPoint[0])) {
eventStart.Flags |= DOKAN_EVENT_DRIVE_LETTER_IN_USE;
Expand Down
4 changes: 4 additions & 0 deletions samples/dokan_mirror/mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,7 @@ void ShowUsage() {
" /r RootDirectory (ex. /r c:\\test)\t\t Directory source to mirror.\n"
" /l MountPoint (ex. /l m)\t\t\t Mount point. Can be M:\\ (drive letter) or empty NTFS folder C:\\mount\\dokan .\n"
" /t Single thread\t\t\t\t Only use a single thread to process events.\n\t\t\t\t\t\t This is highly not recommended as can easily create a bottleneck.\n"
" /g IPC Batching\t\t\t\t Pull batches of events from the driver instead of a single one and execute them parallelly.\n\t\t\t\t\t\t Only recommended for slow (remote) mirrored device.\n"
" /d (enable debug output)\t\t\t Enable debug output to an attached debugger.\n"
" /s (use stderr for output)\t\t\t Enable debug output to stderr.\n"
" /m (use removable drive)\t\t\t Show device as removable media.\n"
Expand Down Expand Up @@ -1607,6 +1608,9 @@ int __cdecl wmain(ULONG argc, PWCHAR argv[]) {
case L'e':
dokanOptions.Options |= DOKAN_OPTION_DISPATCH_DRIVER_LOGS;
break;
case L'g':
dokanOptions.Options |= DOKAN_OPTION_ALLOW_IPC_BATCHING;
break;
case L'b':
// Only work when mirroring a folder with setCaseSensitiveInfo option enabled on win10
dokanOptions.Options |= DOKAN_OPTION_CASE_SENSITIVE;
Expand Down
5 changes: 5 additions & 0 deletions samples/mirror_test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ $Configs = @(
"Destination" = "$($DokanDriverLetter):";
"Name" = "driveRemovable";
},
@{
"MirrorArguments" = "/l $DokanDriverLetter /g";
"Destination" = "$($DokanDriverLetter):";
"Name" = "ipcBatching";
},
@{
"MirrorArguments" = "/l $DokanDriverLetter /o";
"Destination" = "$($DokanDriverLetter):";
Expand Down

0 comments on commit aef92bc

Please sign in to comment.