Problem in using the Synchronization Event!

Hi All,

Iam writing a filesystem filter driver where in i need to synchronize
IRP_MJ_READ for some files.

I do that by having a Synchronization event.

case IRP_MJ_READ:

if(it is a file XXXXXXXX)
{
KeWaitForSingleObject(MYReadEvent,Executive,KernelMode,FALSE,NULL);

/////// Here i call my function that will create a irp and send it to lower
level and get me data/////////////////////

KeSetEvent(MYReadEvent,(KPRIORITY) 0,FALSE);


}
break;

When i get the first read, My function to create irp and send to lower is
called and but while doing that it got the second read irp for the same
file.

So,The second IRP comes and waits in KeWaitForSingleObject.

The first IRP stops at the point it got interupted by the Second IRP and it
doesnot continue.

Why waiting in KeWaitForSingleObject for Second IRP hangs the serviceing of
the first IRP?

Is it because KeWaitForSingleObject block the current thread??

If so, what is the solution by which i can make the second read IRP to wait
until first one is serviced?

With Regards,
A.Ilamparithi.

First this is really more appropriate for the ntfsd group. But you need to
understand how the filesystem works, your call to the lower level can result
in a request by the file system to the cache manager to get the data, which
can in the end turn around and call your READ function again! I’m not sure
this is what is happening, but it is the case that your read can result in
another read of the file.

I would highly recomend that you take the OSR file system course.


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“A.Ilamparithi” wrote in message news:xxxxx@ntdev…
> Hi All,
>
> Iam writing a filesystem filter driver where in i need to synchronize
> IRP_MJ_READ for some files.
>
> I do that by having a Synchronization event.
>
> case IRP_MJ_READ:
>
> if(it is a file XXXXXXXX)
> {
> KeWaitForSingleObject(MYReadEvent,Executive,KernelMode,FALSE,NULL);
>
> /////// Here i call my function that will create a irp and send it to
lower
> level and get me data/////////////////////
>
> KeSetEvent(MYReadEvent,(KPRIORITY) 0,FALSE);
>
> …
>
> …
>
> …
> }
> break;
>
> When i get the first read, My function to create irp and send to lower is
> called and but while doing that it got the second read irp for the same
> file.
>
> So,The second IRP comes and waits in KeWaitForSingleObject.
>
> The first IRP stops at the point it got interupted by the Second IRP and
it
> doesnot continue.
>
> Why waiting in KeWaitForSingleObject for Second IRP hangs the serviceing
of
> the first IRP?
>
> Is it because KeWaitForSingleObject block the current thread??
>
> If so, what is the solution by which i can make the second read IRP to
wait
> until first one is serviced?
>
> With Regards,
> A.Ilamparithi.
>
>
>
>
>
>
>
>

Hi,

Okay. I will post it in ntfsd group.

Iam using IoBuildSynchronousFsdRequest and IOcalldriver to create the IRPs
and send it to the lower level.

I sure that they are not reentering, as it is serviced by lower level.

The problem now i have is how to synchronize these reads.

With Thanks,
A.Ilamparihi.

“Don Burn” wrote in message news:xxxxx@ntdev…
> First this is really more appropriate for the ntfsd group. But you need
to
> understand how the filesystem works, your call to the lower level can
result
> in a request by the file system to the cache manager to get the data,
which
> can in the end turn around and call your READ function again! I’m not
sure
> this is what is happening, but it is the case that your read can result in
> another read of the file.
>
> I would highly recomend that you take the OSR file system course.
>
>
> –
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
> “A.Ilamparithi” wrote in message news:xxxxx@ntdev…
> > Hi All,
> >
> > Iam writing a filesystem filter driver where in i need to synchronize
> > IRP_MJ_READ for some files.
> >
> > I do that by having a Synchronization event.
> >
> > case IRP_MJ_READ:
> >
> > if(it is a file XXXXXXXX)
> > {
> > KeWaitForSingleObject(MYReadEvent,Executive,KernelMode,FALSE,NULL);
> >
> > /////// Here i call my function that will create a irp and send it to
> lower
> > level and get me data/////////////////////
> >
> > KeSetEvent(MYReadEvent,(KPRIORITY) 0,FALSE);
> >
> > …
> >
> > …
> >
> > …
> > }
> > break;
> >
> > When i get the first read, My function to create irp and send to lower
is
> > called and but while doing that it got the second read irp for the same
> > file.
> >
> > So,The second IRP comes and waits in KeWaitForSingleObject.
> >
> > The first IRP stops at the point it got interupted by the Second IRP and
> it
> > doesnot continue.
> >
> > Why waiting in KeWaitForSingleObject for Second IRP hangs the serviceing
> of
> > the first IRP?
> >
> > Is it because KeWaitForSingleObject block the current thread??
> >
> > If so, what is the solution by which i can make the second read IRP to
> wait
> > until first one is serviced?
> >
> > With Regards,
> > A.Ilamparithi.
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>

Queue the requests rather than blocking threads in your dispatch routine.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of A.Ilamparithi
Sent: Wednesday, August 25, 2004 2:09 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Problem in using the Synchronization Event!

Hi,

Okay. I will post it in ntfsd group.

Iam using IoBuildSynchronousFsdRequest and IOcalldriver to
create the IRPs and send it to the lower level.

I sure that they are not reentering, as it is serviced by lower level.

The problem now i have is how to synchronize these reads.

With Thanks,
A.Ilamparihi.

“Don Burn” wrote in message news:xxxxx@ntdev…
> > First this is really more appropriate for the ntfsd group. But you
> > need
> to
> > understand how the filesystem works, your call to the lower
> level can
> result
> > in a request by the file system to the cache manager to get
> the data,
> which
> > can in the end turn around and call your READ function
> again! I’m not
> sure
> > this is what is happening, but it is the case that your read can
> > result in another read of the file.
> >
> > I would highly recomend that you take the OSR file system course.
> >
> >
> > –
> > Don Burn (MVP, Windows DDK)
> > Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam
> > from the email to reply
> >
> > “A.Ilamparithi” wrote in message
> news:xxxxx@ntdev…
> > > Hi All,
> > >
> > > Iam writing a filesystem filter driver where in i need to
> > > synchronize IRP_MJ_READ for some files.
> > >
> > > I do that by having a Synchronization event.
> > >
> > > case IRP_MJ_READ:
> > >
> > > if(it is a file XXXXXXXX)
> > > {
> > >
> KeWaitForSingleObject(MYReadEvent,Executive,KernelMode,FALSE,NULL);
> > >
> > > /////// Here i call my function that will create a irp
> and send it
> > > to
> > lower
> > > level and get me data/////////////////////
> > >
> > > KeSetEvent(MYReadEvent,(KPRIORITY) 0,FALSE);
> > >
> > > …
> > >
> > > …
> > >
> > > …
> > > }
> > > break;
> > >
> > > When i get the first read, My function to create irp and send to
> > > lower
> is
> > > called and but while doing that it got the second read
> irp for the
> > > same file.
> > >
> > > So,The second IRP comes and waits in KeWaitForSingleObject.
> > >
> > > The first IRP stops at the point it got interupted by the
> Second IRP
> > > and
> > it
> > > doesnot continue.
> > >
> > > Why waiting in KeWaitForSingleObject for Second IRP hangs the
> > > serviceing
> > of
> > > the first IRP?
> > >
> > > Is it because KeWaitForSingleObject block the current thread??
> > >
> > > If so, what is the solution by which i can make the
> second read IRP
> > > to
> > wait
> > > until first one is serviced?
> > >
> > > With Regards,
> > > A.Ilamparithi.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@hollistech.com To unsubscribe send a blank email to
> xxxxx@lists.osr.com
>

Should i queue using StartIo Routine,IoStartPacket and IoStartNextPacket?

With Thanks,
A.Ilamparithi.

“Mark Roddy” wrote in message news:xxxxx@ntdev…
> Queue the requests rather than blocking threads in your dispatch routine.
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of A.Ilamparithi
> > Sent: Wednesday, August 25, 2004 2:09 PM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] Problem in using the Synchronization Event!
> >
> > Hi,
> >
> > Okay. I will post it in ntfsd group.
> >
> > Iam using IoBuildSynchronousFsdRequest and IOcalldriver to
> > create the IRPs and send it to the lower level.
> >
> > I sure that they are not reentering, as it is serviced by lower level.
> >
> > The problem now i have is how to synchronize these reads.
> >
> > With Thanks,
> > A.Ilamparihi.
> >
> > “Don Burn” wrote in message news:xxxxx@ntdev…
> > > First this is really more appropriate for the ntfsd group. But you
> > > need
> > to
> > > understand how the filesystem works, your call to the lower
> > level can
> > result
> > > in a request by the file system to the cache manager to get
> > the data,
> > which
> > > can in the end turn around and call your READ function
> > again! I’m not
> > sure
> > > this is what is happening, but it is the case that your read can
> > > result in another read of the file.
> > >
> > > I would highly recomend that you take the OSR file system course.
> > >
> > >
> > > –
> > > Don Burn (MVP, Windows DDK)
> > > Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam
> > > from the email to reply
> > >
> > > “A.Ilamparithi” wrote in message
> > news:xxxxx@ntdev…
> > > > Hi All,
> > > >
> > > > Iam writing a filesystem filter driver where in i need to
> > > > synchronize IRP_MJ_READ for some files.
> > > >
> > > > I do that by having a Synchronization event.
> > > >
> > > > case IRP_MJ_READ:
> > > >
> > > > if(it is a file XXXXXXXX)
> > > > {
> > > >
> > KeWaitForSingleObject(MYReadEvent,Executive,KernelMode,FALSE,NULL);
> > > >
> > > > /////// Here i call my function that will create a irp
> > and send it
> > > > to
> > > lower
> > > > level and get me data/////////////////////
> > > >
> > > > KeSetEvent(MYReadEvent,(KPRIORITY) 0,FALSE);
> > > >
> > > > …
> > > >
> > > > …
> > > >
> > > > …
> > > > }
> > > > break;
> > > >
> > > > When i get the first read, My function to create irp and send to
> > > > lower
> > is
> > > > called and but while doing that it got the second read
> > irp for the
> > > > same file.
> > > >
> > > > So,The second IRP comes and waits in KeWaitForSingleObject.
> > > >
> > > > The first IRP stops at the point it got interupted by the
> > Second IRP
> > > > and
> > > it
> > > > doesnot continue.
> > > >
> > > > Why waiting in KeWaitForSingleObject for Second IRP hangs the
> > > > serviceing
> > > of
> > > > the first IRP?
> > > >
> > > > Is it because KeWaitForSingleObject block the current thread??
> > > >
> > > > If so, what is the solution by which i can make the
> > second read IRP
> > > > to
> > > wait
> > > > until first one is serviced?
> > > >
> > > > With Regards,
> > > > A.Ilamparithi.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> > xxxxx@hollistech.com To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> >
>
>
>
>

Queue any way you want, just don’t block in your dispatch routine. But
really you ought to take this over to ntfsd, and you ought to examine the
IFS kit samples for some basic clues.

=====================
Mark Roddy

-----Original Message-----
From: A.Ilamparithi [mailto:xxxxx@msn.com]
Sent: Thursday, August 26, 2004 12:12 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Problem in using the Synchronization Event!

Should i queue using StartIo Routine,IoStartPacket and IoStartNextPacket?

With Thanks,
A.Ilamparithi.

“Mark Roddy” wrote in message news:xxxxx@ntdev…
> Queue the requests rather than blocking threads in your dispatch routine.
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of A.Ilamparithi
> > Sent: Wednesday, August 25, 2004 2:09 PM
> > To: Windows System Software Devs Interest List
> > Subject: Re:[ntdev] Problem in using the Synchronization Event!
> >
> > Hi,
> >
> > Okay. I will post it in ntfsd group.
> >
> > Iam using IoBuildSynchronousFsdRequest and IOcalldriver to create
> > the IRPs and send it to the lower level.
> >
> > I sure that they are not reentering, as it is serviced by lower level.
> >
> > The problem now i have is how to synchronize these reads.
> >
> > With Thanks,
> > A.Ilamparihi.
> >
> > “Don Burn” wrote in message news:xxxxx@ntdev…
> > > First this is really more appropriate for the ntfsd group. But
> > > you need
> > to
> > > understand how the filesystem works, your call to the lower
> > level can
> > result
> > > in a request by the file system to the cache manager to get
> > the data,
> > which
> > > can in the end turn around and call your READ function
> > again! I’m not
> > sure
> > > this is what is happening, but it is the case that your read can
> > > result in another read of the file.
> > >
> > > I would highly recomend that you take the OSR file system course.
> > >
> > >
> > > –
> > > Don Burn (MVP, Windows DDK)
> > > Windows 2k/XP/2k3 Filesystem and Driver Consulting Remove StopSpam
> > > from the email to reply
> > >
> > > “A.Ilamparithi” wrote in message
> > news:xxxxx@ntdev…
> > > > Hi All,
> > > >
> > > > Iam writing a filesystem filter driver where in i need to
> > > > synchronize IRP_MJ_READ for some files.
> > > >
> > > > I do that by having a Synchronization event.
> > > >
> > > > case IRP_MJ_READ:
> > > >
> > > > if(it is a file XXXXXXXX)
> > > > {
> > > >
> > KeWaitForSingleObject(MYReadEvent,Executive,KernelMode,FALSE,NULL);
> > > >
> > > > /////// Here i call my function that will create a irp
> > and send it
> > > > to
> > > lower
> > > > level and get me data/////////////////////
> > > >
> > > > KeSetEvent(MYReadEvent,(KPRIORITY) 0,FALSE);
> > > >
> > > > …
> > > >
> > > > …
> > > >
> > > > …
> > > > }
> > > > break;
> > > >
> > > > When i get the first read, My function to create irp and send to
> > > > lower
> > is
> > > > called and but while doing that it got the second read
> > irp for the
> > > > same file.
> > > >
> > > > So,The second IRP comes and waits in KeWaitForSingleObject.
> > > >
> > > > The first IRP stops at the point it got interupted by the
> > Second IRP
> > > > and
> > > it
> > > > doesnot continue.
> > > >
> > > > Why waiting in KeWaitForSingleObject for Second IRP hangs the
> > > > serviceing
> > > of
> > > > the first IRP?
> > > >
> > > > Is it because KeWaitForSingleObject block the current thread??
> > > >
> > > > If so, what is the solution by which i can make the
> > second read IRP
> > > > to
> > > wait
> > > > until first one is serviced?
> > > >
> > > > With Regards,
> > > > A.Ilamparithi.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as:
> > xxxxx@hollistech.com To unsubscribe send a blank email to
> > xxxxx@lists.osr.com
> >
>
>
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

It is better to use IoCsqXxx.

“A.Ilamparithi” wrote in message
news:…
> Should i queue using StartIo Routine,IoStartPacket and IoStartNextPacket?
>
> With Thanks,
> A.Ilamparithi.