Everhart, Glenn From: Simon Graham [graham@mango.com] Sent: Tuesday, November 10, 1998 9:13 AM To: 'Rob Green'; ntdev@atria.com Subject: RE: [ntdev] NT writing back to file it is reading You need to build a Mdl for the new request out of the one in the original Irp (using IoBuildPartialMdl); you are receiving paging reads from above and the Mdl in the original Irp has flags set indicating this fact (and MmUnlockPages knows not to make the pages dirty). If you just build your own Irp the way you are, the driver you call to do the read will end up building a new Mdl that does NOT have these flags set and you end up making the pages dirty in memory even for paging reads (actually, I found when I had this bug that I would end up with loads of pages on the Modified-No-Write list which NEVER got cleaned). What you should do is either pass the original Mdl through (if you do not need to break up the original request into smaller reads to the physical disk) or allocate a new one and use IoBuildPartialMdl() to build Mdls that describe each portion of the original request. Simon Graham Mango -----Original Message----- From: Rob Green [mailto:robg@sundial.net] Sent: Monday, November 09, 1998 10:55 PM To: ntdev@atria.com Subject: [ntdev] NT writing back to file it is reading Hello, I've come across a rather odd problem. I have a disk driver that NTFS calls to read data. So far so good, i read the request data from another device (that isn't in control by any other driver) , and alls well. as a test i started copying a 100MB file (using copy file /b nul) after about 10 MB i start getting writes to the file that is being copied! I have even opened the file in read only mode and it still does it. I have tracked it done to my call to read the data from the raw hard drive. (not a fdisk format) I use IoBuildSyncRequest to create the irp to send to the driver. from the pseudo code below you can see that i call MmGetSystemAddressForMdl then call IoBuildSync on the resulting buffer. I think this is where the problem is, as IoBuildSync is going to generate another Mdl for the buffer, so now i have 2 mdls(the one from the Irp, and the newly created one) and 2 systems addresses (the users buffer, and the system buffer) Am i right in that this could be my problem? I tried creating an irp using the original Irp, but it always BugChecks in KiInsertDeviceQueueAPC (or something similar) I have check the Irp APC fields and they are all null. i used IoAllocateIrp with a completion routine(bugcheck), and allocing my own with a completion routine. The completion routine is executed, but after it returns my main code is never restarted. (yes i return STATUS_MORE_PROCESSING_REQUIRED) If i check to see what file is being read, and don't call the ReadDataFromDrive routine on it, no writes occur to the file. Thanks ReadDataFromDrive() { Irp = IoBuildSynchronousRequest(...); if(Irp) { IoCallDriver(DeviceObject,Irp); } } DriverEntry(DeviceObject,Irp) { Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); ntStatus = ReadDataFromDrive( DevExt, &ByteOffset, Stack->Parameters.Read.Length, Buffer); ntStatus = DoPostProcessingOnData( DevExt, &ByteOffset, Stack->Parameters.Read.Length, Buffer); Irp->IoStatus.Status = ntStatus; Irp->IoStatus.Information = Stack->Parameters.Read.Length; IoCompleteRequest(Irp,IO_DISK_INCREMENT); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]