completion of pending create doesn't wake up caller

Hi,
I’m trying to implement a network FS FSD. Since create involves network
communication, I am marking the requesting Irp as pending and returning
STATUS_PENDING from the create dispatch routine. I use driver queueing
(keep a queue of requests), and when the response comes back I find the
appropriate Irp and mark it as complete. Using printfs all this seems to be
working correctly, but the user program that invoked the create never wakes
up. Any hints as to what I should look at to figure out what I’m doing wrong?

Relevant code to mark Irp pending:
IoSetCancelRoutine(Irp, MyCancel);
IoMarkIrpPending(Irp);
return STATUS_PENDING;

(cancel is never called. by the way, how can I force a cancel? killing the
program doesn’t seem to work – in fact it doesn’t kill the program)

Relevant code to waking the irp up again:
irp->IoStatus.Status = STATUS_SUCCESS;
irp->IoStatus.Information = FILE_OPENED;
IoSetCancelRoutine(irp, NULL);
IoCompleteRequest(irp, IO_NO_INCREMENT);

Both sections of code should be running at PASSIVE and shouldn’t be holding
any locks.

thanks,

david

Okay, I learned something (thanks in part to Jamey): Pending should only be used for operations that can be run asynchronously wrt the application thread that invoked them. A quick look at the Win32 API indicates that CreateFile isn’t one of them. So the answer to my question is that I should put the thread to sleep on a dispatcher object.

I have 2 related questions:

  1. It seems to me that any request should be allowed to be marked as Pending, as that simply forces the I/OMgr to handle synchronization. Since there fields in the FileObject that I suppose I’m not supposed to use (is the FileObject opaque to FSDs?), it seems reasonable that the I/OMgr would be able to handle pending creates.

  2. I setup a KEVENT, cause the user thread to wait, and wake it up when the create has completed. This works if my user (console) program is running by itself, but if it runs under the VC++ debugger the CreateFile never returns. Any ideas why this might be the case?
    (I sleep via KeWaitForSingleObject(MyEvent, UserRequest, UserMode, TRUE, 0)
    and wake it up via (KeSetState(MyEvent, 0, TRUE); )

any help appreciated,

thanks

david.

At 11:50 AM 4/19/00 -0700, David C. Steere wrote:

Hi,
I’m trying to implement a network FS FSD. Since create involves network communication, I am marking the requesting Irp as pending and returning STATUS_PENDING from the create dispatch routine. I use driver queueing (keep a queue of requests), and when the response comes back I find the appropriate Irp and mark it as complete. Using printfs all this seems to be working correctly, but the user program that invoked the create never wakes up. Any hints as to what I should look at to figure out what I’m doing wrong?

Relevant code to mark Irp pending:
IoSetCancelRoutine(Irp, MyCancel);
IoMarkIrpPending(Irp);
return STATUS_PENDING;

(cancel is never called. by the way, how can I force a cancel? killing the program doesn’t seem to work – in fact it doesn’t kill the program)

Relevant code to waking the irp up again:
irp->IoStatus.Status = STATUS_SUCCESS;
irp->IoStatus.Information = FILE_OPENED;
IoSetCancelRoutine(irp, NULL);
IoCompleteRequest(irp, IO_NO_INCREMENT);

Both sections of code should be running at PASSIVE and shouldn’t be holding any locks.

thanks,

david


You are currently subscribed to ntfsd as: xxxxx@cse.ogi.edu
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

Hello !!

According to the Rajeev Nagar’s book (File System Internals) the
create(open)/close requests are inherently always synchronous.

Martin