IRQL for IRP_MJ_DEVICE_CONTROL

We are having a volume filter driver. At what IRQL , IRP_MJ_DEVICE_CONTROL will be called.

thanks,
Ravindra

Reson why i have asked this question is that :
In DeviceIOControlPath we are :

  1. Waiting for semaphore to acquire.
  2. Using the ZwWriteFile function to write into some file.
  3. Releasing semaphore.

From the document what i read that it should be called at PASSIVE_LEVEL.Invocation is as follows :

Status = ZwWriteFile(
hdl,
NULL,
NULL,
NULL,
&IoStatus,
buf,
len,
NULL,
NULL
);
Does it have any issuses???

thanks in advance,
Ravindra

Waiting in dispatch paths is bad idea, since it breaks overlapped IO.

One of the ways of getting rid of this is like the FASTFAT/RDBSS FSDs do:

  1. semaphore wait must have nonblocking TryToAcquire semantics, not Acquire
  2. if acquire was OK - do the operation inline and then release the lock.
  3. otherwise, offload the IRP to the worker thread from the pool (“FSP thread”) which will do the same as the above, but Acquire and not TryToAcquire.
  4. complete the request in the pool’s thread in this case.

Also, all of this should be done only if the FO from which the request was sent is really opened in overlapped mode (IoIsOperationSynchronous aka CanFsdWait is the call to check for this).

So, the logic is like:

NTSTATUS IrpExecute(…BOOLEAN CanWeBlock,…)
{
BOOLEAN WasLockAcquired;
if( CanWeBlock )
{
Acquire(lock);
WasLockAcquired = TRUE;
}
else
WasLockAcquired = TryToAcquire(Lock);
if( !WasLockAcquired )
{
IoMarkIrpPending();
offload to a work item
return STATUS_PENDING;
}
execute the operation
Release(Lock);
complete the IRP;
return real completion status;
}

Then the dispatch path does:

return IrpExecute(…IoIsOperationSynchronous(…),…)

and the work item does:

IrpExecute(…TRUE,…)


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Reson why i have asked this question is that :
> In DeviceIOControlPath we are :
>
> 1. Waiting for semaphore to acquire.
> 2. Using the ZwWriteFile function to write into some file.
> 3. Releasing semaphore.
>
> From the document what i read that it should be called at PASSIVE_LEVEL.Invocation is as follows :
>
> Status = ZwWriteFile(
> hdl,
> NULL,
> NULL,
> NULL,
> &IoStatus,
> buf,
> len,
> NULL,
> NULL
> );
> Does it have any issuses???
>
> thanks in advance,
> Ravindra
>

Thanks for your reply. You mean that in volume filter driver, DeviceIoControl can be called at IRQL > PASSIVE_LEVEL (that is invoked by our custom application).

> Thanks for your reply. You mean that in volume filter driver,

DeviceIoControl can be called at IRQL > PASSIVE_LEVEL (that is invoked by
our custom application).

Any top-level dispatch routine can be called at DISPATCH_LEVEL except for
the top-level dispatch routine. The places where you can assume
PASSIVE_LEVEL are more the exception than the standard.
joe


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

The ioctls an all sends will always be at passive level. You cannot make that assumption about other ioctls you see in the stack

d

Bent from my phone


From: xxxxx@rediffmail.commailto:xxxxx
Sent: ?7/?15/?2013 10:44 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] IRQL for IRP_MJ_DEVICE_CONTROL

Thanks for your reply. You mean that in volume filter driver, DeviceIoControl can be called at IRQL > PASSIVE_LEVEL (that is invoked by our custom application).


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

Thanks

> Any top-level dispatch routine can be called at DISPATCH_LEVEL

What about MJ_CREATE? :slight_smile:


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com