IoBuildSynchronousFsdRequest and file size question

Hello,

I’m trying to implement a write-protected virtual mirror disk
for an NTFS volume. My driver is stacked on top of the
block device driver. When a request arrives, I’ll build new
IRPs

Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_READ,
BlockDeviceObject,
Buffer,
Length,
Offset,
&Event,
pIoStatus
);
// Using IoBuildAsynchronousFsdRequest produce the same error

Then pass it down to the lower device

Status = IoCallDriver(BlockDeviceObject, Irp);

if(Status == STATUS_PENDING)
{
KeWaitForSingleObject(
&Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = pIoStatus->Status;
}

This approach works fine for small files (< 2 KBytes). But
when reading/copying a large file, the process will fail near the
2 KBytes mark with this error
“MM MODWRITE: failing all io, controlarea 82119B38 status c00000a2”
where c00000a2 is “STATUS_MEDIA_WRITE_PROTECTED”
I dont understand why the file size make a different. The
buffer size of an individual IRP will always be 64 KBytes or
less regardless of the size of the file. Besides, if I use the original IRP
instead of building a new one, there will be no error.
Anyone knows what I am doing wrong here?

TIA,
Chu Bun

Please read “2MBytes” instead of “2KBytes”

“ChuBun” wrote in message news:xxxxx@ntfsd…
>
> Hello,
>
> I’m trying to implement a write-protected virtual mirror disk
> for an NTFS volume. My driver is stacked on top of the
> block device driver. When a request arrives, I’ll build new
> IRPs
>
> Irp = IoBuildSynchronousFsdRequest(
> IRP_MJ_READ,
> BlockDeviceObject,
> Buffer,
> Length,
> Offset,
> &Event,
> pIoStatus
> );
> // Using IoBuildAsynchronousFsdRequest produce the same error
>
> Then pass it down to the lower device
>
> Status = IoCallDriver(BlockDeviceObject, Irp);
>
> if(Status == STATUS_PENDING)
> {
> KeWaitForSingleObject(
> &Event,
> Executive,
> KernelMode,
> FALSE,
> NULL
> );
> Status = pIoStatus->Status;
> }
>
> This approach works fine for small files (< 2 KBytes). But
> when reading/copying a large file, the process will fail near the
> 2 KBytes mark with this error
> “MM MODWRITE: failing all io, controlarea 82119B38 status c00000a2”
> where c00000a2 is “STATUS_MEDIA_WRITE_PROTECTED”
> I dont understand why the file size make a different. The
> buffer size of an individual IRP will always be 64 KBytes or
> less regardless of the size of the file. Besides, if I use the original
IRP
> instead of building a new one, there will be no error.
> Anyone knows what I am doing wrong here?
>
> TIA,
> Chu Bun
>
>
>
>
>

You can not wait in the read dispatch handler because you can be called
at a raised IRQL.

Jamey

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ChuBun
Sent: Thursday, July 31, 2003 4:10 PM
To: File Systems Developers
Subject: [ntfsd] IoBuildSynchronousFsdRequest and file size question

Hello,

I’m trying to implement a write-protected virtual mirror disk
for an NTFS volume. My driver is stacked on top of the
block device driver. When a request arrives, I’ll build new
IRPs

Irp = IoBuildSynchronousFsdRequest(
IRP_MJ_READ,
BlockDeviceObject,
Buffer,
Length,
Offset,
&Event,
pIoStatus
);
// Using IoBuildAsynchronousFsdRequest produce the same error

Then pass it down to the lower device

Status = IoCallDriver(BlockDeviceObject, Irp);

if(Status == STATUS_PENDING)
{
KeWaitForSingleObject(
&Event,
Executive,
KernelMode,
FALSE,
NULL
);
Status = pIoStatus->Status;
}

This approach works fine for small files (< 2 KBytes). But
when reading/copying a large file, the process will fail near the
2 KBytes mark with this error
“MM MODWRITE: failing all io, controlarea 82119B38 status c00000a2”
where c00000a2 is “STATUS_MEDIA_WRITE_PROTECTED”
I dont understand why the file size make a different. The
buffer size of an individual IRP will always be 64 KBytes or
less regardless of the size of the file. Besides, if I use the original
IRP
instead of building a new one, there will be no error.
Anyone knows what I am doing wrong here?

TIA,
Chu Bun


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

I forgot to say that the driver queues the IRPs and process them in a system
thread.
I searched online for hours for “MM MODWRITE” error but could
not find much. I found this but didnt really understand what it said and
how
to avoid them:

“Caused by pagingIo writes when mapping MDL for read operations”

“MDLs for PageRead operation are built in very special way.
Not by IoAllocateMdl(), certainly. MDL with fixed-size tail
is allocated as part of the structure called “inpage support block”
which is allocated from the list.
The MDL tail is 15 ULONGs - maximum cluster size for clustered inpage
operations.”

Is there any relationship between “15 ULONGs” and 2 MBytes?

“Jamey Kirby” wrote in message news:xxxxx@ntfsd…
>
> You can not wait in the read dispatch handler because you can be called
> at a raised IRQL.
>
> Jamey
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of ChuBun
> Sent: Thursday, July 31, 2003 4:10 PM
> To: File Systems Developers
> Subject: [ntfsd] IoBuildSynchronousFsdRequest and file size question
>
> Hello,
>
> I’m trying to implement a write-protected virtual mirror disk
> for an NTFS volume. My driver is stacked on top of the
> block device driver. When a request arrives, I’ll build new
> IRPs
>
> Irp = IoBuildSynchronousFsdRequest(
> IRP_MJ_READ,
> BlockDeviceObject,
> Buffer,
> Length,
> Offset,
> &Event,
> pIoStatus
> );
> // Using IoBuildAsynchronousFsdRequest produce the same error
>
> Then pass it down to the lower device
>
> Status = IoCallDriver(BlockDeviceObject, Irp);
>
> if(Status == STATUS_PENDING)
> {
> KeWaitForSingleObject(
> &Event,
> Executive,
> KernelMode,
> FALSE,
> NULL
> );
> Status = pIoStatus->Status;
> }
>
> This approach works fine for small files (< 2 KBytes). But
> when reading/copying a large file, the process will fail near the
> 2 KBytes mark with this error
> “MM MODWRITE: failing all io, controlarea 82119B38 status c00000a2”
> where c00000a2 is “STATUS_MEDIA_WRITE_PROTECTED”
> I dont understand why the file size make a different. The
> buffer size of an individual IRP will always be 64 KBytes or
> less regardless of the size of the file. Besides, if I use the original
> IRP
> instead of building a new one, there will be no error.
> Anyone knows what I am doing wrong here?
>
> TIA,
> Chu Bun
>
>
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>

I’m kind of figure out where the error comes from, but dont understand why.
I’ll appreciate if someone can explain it to me.

The Buffer used in IoBuildSynchronousFsdRequest() is from

Buffer = MmGetSystemAddressForMdlSafe
(Irp->MdlAddress, NormalPagePriority); // thus MDL errors

If I alloc and use a temporary buffer, and then copy its content back to the
system buffer, everything works fine.

Chu Bun

“ChuBun” wrote in message news:xxxxx@ntfsd…
>
> I forgot to say that the driver queues the IRPs and process them in a
system
> thread.
> I searched online for hours for “MM MODWRITE” error but could
> not find much. I found this but didnt really understand what it said and
> how
> to avoid them:
>
> “Caused by pagingIo writes when mapping MDL for read operations”
>
> “MDLs for PageRead operation are built in very special way.
> Not by IoAllocateMdl(), certainly. MDL with fixed-size tail
> is allocated as part of the structure called “inpage support block”
> which is allocated from the list.
> The MDL tail is 15 ULONGs - maximum cluster size for clustered inpage
> operations.”
>
> Is there any relationship between “15 ULONGs” and 2 MBytes?
>
>
>
> “Jamey Kirby” wrote in message
news:xxxxx@ntfsd…
> >
> > You can not wait in the read dispatch handler because you can be called
> > at a raised IRQL.
> >
> > Jamey
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of ChuBun
> > Sent: Thursday, July 31, 2003 4:10 PM
> > To: File Systems Developers
> > Subject: [ntfsd] IoBuildSynchronousFsdRequest and file size question
> >
> > Hello,
> >
> > I’m trying to implement a write-protected virtual mirror disk
> > for an NTFS volume. My driver is stacked on top of the
> > block device driver. When a request arrives, I’ll build new
> > IRPs
> >
> > Irp = IoBuildSynchronousFsdRequest(
> > IRP_MJ_READ,
> > BlockDeviceObject,
> > Buffer,
> > Length,
> > Offset,
> > &Event,
> > pIoStatus
> > );
> > // Using IoBuildAsynchronousFsdRequest produce the same error
> >
> > Then pass it down to the lower device
> >
> > Status = IoCallDriver(BlockDeviceObject, Irp);
> >
> > if(Status == STATUS_PENDING)
> > {
> > KeWaitForSingleObject(
> > &Event,
> > Executive,
> > KernelMode,
> > FALSE,
> > NULL
> > );
> > Status = pIoStatus->Status;
> > }
> >
> > This approach works fine for small files (< 2 KBytes). But
> > when reading/copying a large file, the process will fail near the
> > 2 KBytes mark with this error
> > “MM MODWRITE: failing all io, controlarea 82119B38 status c00000a2”
> > where c00000a2 is “STATUS_MEDIA_WRITE_PROTECTED”
> > I dont understand why the file size make a different. The
> > buffer size of an individual IRP will always be 64 KBytes or
> > less regardless of the size of the file. Besides, if I use the original
> > IRP
> > instead of building a new one, there will be no error.
> > Anyone knows what I am doing wrong here?
> >
> > TIA,
> > Chu Bun
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
>
>
>
>

> Is there any relationship between “15 ULONGs” and 2 MBytes?

No. It is 64KB.

Max