I am writing a virtual disk driver which uses a file as a virtual disk.

The disk file can be mounted with a drive letter and normally used.
Internally,
ZwReadFile and ZwWriteFile in the dispatch routine for IRP_MJ_READ and
IRP_MJ_WRITE do
the job to write on and read from "disk". As far, everything works
fine.

In this ,after mounting in explorer window if i make any file copy
operation,IRP_MJ_WRITE was called.

Also,IRP_MJ_WRITE was called many times after i copied a single file.So my
question is,
How many IRPs will be sent for file copy operation.How the IRPs are formed
by IO manager.
How i can trace start and end of copy operation.

since,in IRP_MJ_WRITE ,I am writing into a file.Also this file is shared
between two driver instances.

Looking forward to get reply.

Thanks ,
ND

Re: Number of IRPS by Don

Don
Tue May 06 05:21:38 CDT 2008

You have no way of knowing about copy operations, all you can know is that
something is being read or written. Even if you figured out for the shell
what the copy rules were, they would be different for CMD.EXE and then for
any other program.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



"ND" <ND@discussions.microsoft.com> wrote in message
news:1BCB184F-5028-40A1-8B73-885DDF98B0BE@microsoft.com...
>
> I am writing a virtual disk driver which uses a file as a virtual disk.
>
> The disk file can be mounted with a drive letter and normally used.
> Internally,
> ZwReadFile and ZwWriteFile in the dispatch routine for IRP_MJ_READ and
> IRP_MJ_WRITE do
> the job to write on and read from "disk". As far, everything works
> fine.
>
> In this ,after mounting in explorer window if i make any file copy
> operation,IRP_MJ_WRITE was called.
>
> Also,IRP_MJ_WRITE was called many times after i copied a single file.So my
> question is,
> How many IRPs will be sent for file copy operation.How the IRPs are formed
> by IO manager.
> How i can trace start and end of copy operation.
>
> since,in IRP_MJ_WRITE ,I am writing into a file.Also this file is shared
> between two driver instances.
>
> Looking forward to get reply.
>
> Thanks ,
> ND
>
>



Re: Number of IRPS by ND

ND
Tue May 06 07:44:07 CDT 2008

Hi,

I found following reply.

Yes i can know through IRP_MJ_WRITE..But how to pre-determine number of
IRP_MJ_WRITE requests .Since ,I need to lock a file when write operation
starts and need to free at end of write operation.

Simply,I need to lock a file until copy or write operation ends.Otherwise
how to avoid dispatch routine to be called many times for single copy
operation.

Looking forward to hear from you.

Thanks
ND

"Don Burn" wrote:

> You have no way of knowing about copy operations, all you can know is that
> something is being read or written. Even if you figured out for the shell
> what the copy rules were, they would be different for CMD.EXE and then for
> any other program.
>
>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Website: http://www.windrvr.com
> Blog: http://msmvps.com/blogs/WinDrvr
> Remove StopSpam to reply
>
>
>
> "ND" <ND@discussions.microsoft.com> wrote in message
> news:1BCB184F-5028-40A1-8B73-885DDF98B0BE@microsoft.com...
> >
> > I am writing a virtual disk driver which uses a file as a virtual disk.
> >
> > The disk file can be mounted with a drive letter and normally used.
> > Internally,
> > ZwReadFile and ZwWriteFile in the dispatch routine for IRP_MJ_READ and
> > IRP_MJ_WRITE do
> > the job to write on and read from "disk". As far, everything works
> > fine.
> >
> > In this ,after mounting in explorer window if i make any file copy
> > operation,IRP_MJ_WRITE was called.
> >
> > Also,IRP_MJ_WRITE was called many times after i copied a single file.So my
> > question is,
> > How many IRPs will be sent for file copy operation.How the IRPs are formed
> > by IO manager.
> > How i can trace start and end of copy operation.
> >
> > since,in IRP_MJ_WRITE ,I am writing into a file.Also this file is shared
> > between two driver instances.
> >
> > Looking forward to get reply.
> >
> > Thanks ,
> > ND
> >
> >
>
>
>

Re: Number of IRPS by Maxim

Maxim
Tue May 06 13:24:05 CDT 2008

> How many IRPs will be sent for file copy operation.

Nobody knows for sure, this depends, for instance, on what way was used for
file copying.

> How i can trace start and end of copy operation.

You cannot. Reading the source and writing the destination are 2 absolutely
unrelated processes to the kernel, the kernel does not know this is a copy.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com


Re: Number of IRPS by ND

ND
Wed May 07 01:46:00 CDT 2008


Hi Maxim Shantskih,

Thanks for your reply.

We are creating virtual disk within a file and mounts it as a real disk.

Normaly only one user can mount that file as disk, and use it. But now we
want multiple user can mount this file in network, as real disk in there
own PC, and use it.Like NFS.

We did this by giving FILE_SHARE_WRITE access to file ,while file creation
using ZwCreateFile.
With this multiple user(multiple pcs) can mount this file as virtual
disk.And when user updates this virtual volume,the disk file is updated.
Now problem is ,when mutiple users trying to update from different pcs I
could not maintain offset of the diskfile.So the data lost.

I could know user operation through IRP_MJ_XXX.But how i can share this file
among driver instances.


we planned to lock this file for synchronization.or is there any other way
to achieve this.

Waiting for your reply.
Thanks

"Maxim S. Shatskih" wrote:

> > How many IRPs will be sent for file copy operation.
>
> Nobody knows for sure, this depends, for instance, on what way was used for
> file copying.
>
> > How i can trace start and end of copy operation.
>
> You cannot. Reading the source and writing the destination are 2 absolutely
> unrelated processes to the kernel, the kernel does not know this is a copy.
>
> --
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> maxim@storagecraft.com
> http://www.storagecraft.com
>
>

Re: Number of IRPS by Alexander

Alexander
Wed May 07 09:11:46 CDT 2008

Bad idea. You cannot share the same filesystem image safely. It will get
corrupted very fast.

"ND" <ND@discussions.microsoft.com> wrote in message
news:1AFDEA00-7E8C-4CB6-A9C2-0C33B3A2F5EE@microsoft.com...
>
> Hi Maxim Shantskih,
>
> Thanks for your reply.
>
> We are creating virtual disk within a file and mounts it as a real disk.
>
> Normaly only one user can mount that file as disk, and use it. But now we
> want multiple user can mount this file in network, as real disk in there
> own PC, and use it.Like NFS.
>
> We did this by giving FILE_SHARE_WRITE access to file ,while file creation
> using ZwCreateFile.
> With this multiple user(multiple pcs) can mount this file as virtual
> disk.And when user updates this virtual volume,the disk file is updated.
> Now problem is ,when mutiple users trying to update from different pcs I
> could not maintain offset of the diskfile.So the data lost.
>
> I could know user operation through IRP_MJ_XXX.But how i can share this
> file
> among driver instances.
>
>
> we planned to lock this file for synchronization.or is there any other way
> to achieve this.
>
> Waiting for your reply.
> Thanks
>
> "Maxim S. Shatskih" wrote:
>
>> > How many IRPs will be sent for file copy operation.
>>
>> Nobody knows for sure, this depends, for instance, on what way was used
>> for
>> file copying.
>>
>> > How i can trace start and end of copy operation.
>>
>> You cannot. Reading the source and writing the destination are 2
>> absolutely
>> unrelated processes to the kernel, the kernel does not know this is a
>> copy.
>>
>> --
>> Maxim Shatskih, Windows DDK MVP
>> StorageCraft Corporation
>> maxim@storagecraft.com
>> http://www.storagecraft.com
>>
>>



Re: Number of IRPS by Maxim

Maxim
Wed May 07 09:18:29 CDT 2008

> We did this by giving FILE_SHARE_WRITE access to file ,while file creation
> using ZwCreateFile.
> With this multiple user(multiple pcs) can mount this file as virtual
> disk.And when user updates this virtual volume,the disk file is updated.

No need in this. The disk device is global for all users, and is only
initialized once in Windows. This is also true for your virtual disk, there
will be no per-user initialization of it.

If you really want to have the disk device (file-disk or any other) updatable
simultaneously from several network nodes each running its own filesystem, then
sorry, you need a cluster filesystem for this, NTFS cannot do this.

So, such a product would shift from block-device-sharing paradigm, with FSD
running on each client node, to file-sharing paradigm, with FSD running near to
the device.

Block-device-sharing technologies like iSCSI really do suffer a lot from
inability of simultaneously mounting the same LUN on different nodes with
non-clustered commodity FS like NTFS.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com