3 ms·
vdev_disk.c spawns a thread to get around that IoCompletionRoutine is called in a different context, to sleep until signalled. Is there a better way to do async
by barrkel 9y ago
vdev_disk.c spawns a thread to get around that IoCompletionRoutine is called in a different context, to sleep until signalled. Is there a better way to do async in Windows?
Instead of creating a thread and blocking until being signalled in the continuation of an IO, enqueue a work item to continue work at PASSIVE_LEVEL (i.e. schedule a continuation).
Async means continuations, otherwise you're blocking.
https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/guidelines-for-writing-dpc-routines https://docs.microsoft.com/en-us/windows-hardware/drivers/ke...
- Filligree 9y agoI'm not ZFSin's creator, and there's no guarantee they're reading this. If you want to inform him, you should probably file an issue.
- takeda 9y agoLooks like the author is here and already responded to his comments.
- exikyut 9y agoThis would be perfect to dump into a new issue
- lundman 9y agoI tried that way first, but because it called the callback at different level, and ZFS grabs a mutex, it just died. Which why I changed it to spawn a taskq to wait for the callback to come back, then tell ZFS about it. So it is async right now, I'm just not happy it has to create yet another taskq to handle it, for each IO request.
- barrkel 9y agoI'm far from expert at NT kernel programming, but I do know that there's not much you can do in the callbacks from interrupts, which is why you use a deferred procedure call (using Io/ExQueueWorkItem) to continue at a level where you can do more things, like potentially blocking calls. The work item execution of the DPC proceeds on a system worker thread, rather than a thread you had to spawn yourself. But perhaps that's what you did. If you're still stuck, I suggest you email Larry Osterman (Firstname.Lastname@microsoft.com) for a clue; Larry has worked on the NTFS driver and he's responded to my emails in the past. For an improved probability of a useful response, I'd send him a link to a Stack Overflow question, so that other people benefit from the reply also. (This is a general rule for emailing people for developer help, you'd be surprised how many random people email system / compiler developers for coding assistance.)
- lundman 9y agoAh that looks interesting. I will research that once I leave SF
- j_s 9y agoAnother expert to contact: Trent Nelson from http://pyparallel.org/ http://pyparallel.org/ a few years back. He pops up here occasionally to defend Windows unique I/O subsystem¹, and monitors Twitter². ¹ https://hn.algolia.com/?query=author:trentnelson&sort=byDate&type=comment https://hn.algolia.com/?query=author:trentnelson&sort=byDate... ² http://twitter.com/trentnelson http://twitter.com/trentnelson
- lundman 9y agoAlas, didn't quite work. Turns out DPC's are not allowed to wait, so the first condvar we hit in zio makes us die :)
- tinus_hn 9y agoThese are called Deferred Procedure Calls, the purpose is not to delay but to run in a more relaxed context.
- kyberias 9y agoYes, but I'm pretty sure in the past they have also been called Delayed Function Calls in Microsoft documentation. It doesn't change the semantics, of course. Same goes for the old Symbian OS.