Kernel generating request for the same offset.

Hello All,

I am badly stuck in a problem. The problem is that we take one kernel WRITE request and try to handle it ourselves. The problem is that once we get OS Request we first do some calculations on the original request. After these calculations we create our own IRPs and try to complete the original OS IRP using partial MDLs.

The problem is that once we call IoCallDriver on our own IRPs and before the completion of these IRPs (in which we can also complete the Original Request), the kernel generates WRITE requests for the same offset.

Consider this example:

We are handling OS Request of 1024 bytes (2 sectors) at offset 512. Before the completion of our IRPs and after the IoCallDriver, the kernel will generate two requests of its own

One for offset 512 and length 512 and
the other of offset (512 + 512) and length 512.

What is the reason for this behavior.

xxxxx@yahoo.com wrote:

Hello All,

I am badly stuck in a problem. The problem is that we take one kernel WRITE request and try to handle it ourselves. The problem is that once we get OS Request we first do some calculations on the original request. After these calculations we create our own IRPs and try to complete the original OS IRP using partial MDLs.

The problem is that once we call IoCallDriver on our own IRPs and before the completion of these IRPs (in which we can also complete the Original Request), the kernel generates WRITE requests for the same offset.

Consider this example:

We are handling OS Request of 1024 bytes (2 sectors) at offset 512. Before the completion of our IRPs and after the IoCallDriver, the kernel will generate two requests of its own

One for offset 512 and length 512 and
the other of offset (512 + 512) and length 512.

What is the reason for this behavior.

Are you accidentally passing IoCallDriver a driver which is not below
you in the stack? Because then you might be indirectly calling yourself!


Jakob Bøhm, M.Sc.Eng. * xxxxx@danware.dk * direct tel:+45-45-90-25-33
Danware Data A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax tel:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right

What sort of driver is this? Where are you located in the storage stack?

Did you mark the original IRP pending and return status pending?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-284566-
xxxxx@lists.osr.com] On Behalf Of xxxxx@yahoo.com
Sent: Wednesday, April 25, 2007 7:51 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Kernel generating request for the same offset.

Hello All,

I am badly stuck in a problem. The problem is that we take one kernel
WRITE request and try to handle it ourselves. The problem is that once
we get OS Request we first do some calculations on the original
request. After these calculations we create our own IRPs and try to
complete the original OS IRP using partial MDLs.

The problem is that once we call IoCallDriver on our own IRPs and
before the completion of these IRPs (in which we can also complete the
Original Request), the kernel generates WRITE requests for the same
offset.

Consider this example:

We are handling OS Request of 1024 bytes (2 sectors) at offset 512.
Before the completion of our IRPs and after the IoCallDriver, the
kernel will generate two requests of its own

One for offset 512 and length 512 and
the other of offset (512 + 512) and length 512.

What is the reason for this behavior.


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

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

That’s a good question.

Another would be - what makes you assume that you will only ever get one write to a sector at a time?

If two processes have a file open and each issues a write to the first block at the same time you will very likely see two writes come down at one time in the storage stack. You can also see interleaved reads and writes.

As long as you avoid tearing (i.e. if app A and B write to sector 1 and 2 at the exact same time you should end up with 1a and 2a or 1b and 2b, not 1a 2b or 1b 2a) you can usually just let these race. However if you have to divide a large operation into small chunks and issue those chunks independently then you need to provide the range-level synchronization to block overlapping operations or have some other trick up your sleeve to ensure the writes occur in order (and I’m not aware of another trick)

-p

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Jakob Bohm
Sent: Wednesday, April 25, 2007 5:04 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] Kernel generating request for the same offset.

xxxxx@yahoo.com wrote:

Hello All,

I am badly stuck in a problem. The problem is that we take one kernel WRITE request and try to handle it ourselves. The problem is that once we get OS Request we first do some calculations on the original request. After these calculations we create our own IRPs and try to complete the original OS IRP using partial MDLs.

The problem is that once we call IoCallDriver on our own IRPs and before the completion of these IRPs (in which we can also complete the Original Request), the kernel generates WRITE requests for the same offset.

Consider this example:

We are handling OS Request of 1024 bytes (2 sectors) at offset 512. Before the completion of our IRPs and after the IoCallDriver, the kernel will generate two requests of its own

One for offset 512 and length 512 and
the other of offset (512 + 512) and length 512.

What is the reason for this behavior.

Are you accidentally passing IoCallDriver a driver which is not below
you in the stack? Because then you might be indirectly calling yourself!


Jakob B?hm, M.Sc.Eng. * xxxxx@danware.dk * direct tel:+45-45-90-25-33
Danware Data A/S * Bregnerodvej 127 * DK-3460 Birkerod * DENMARK
http://www.netop.com * tel:+45-45-90-25-25 * fax tel:+45-45-90-25-26
Information in this mail is hasty, not binding and may not be right


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

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