how to create file in IRP_MJ_WRITE?

It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
a file in IRP_MJ_WRITE then?

thanks,

AFei

Yes, you should not be trying to create files in operations like
IRP_MJ_READ or IRP_MJ_WRITE. You certainly can not call ZwCreateFile if
you are at APC level or are doing a paging IO. You can also severely
degrade system performance if you slow these operations down
significantly.

If at all possible it is best not to call ZwCreateFile from filters
because it generates recursive IO which causes lots of other problems
(kernel stack overflows, deadlocks with other filters, etc). You should
use IoCreateFileSpecifyDeviceObjectHint if at all possible. Another
option if you need to run your filter on W2K is using shadow device
objects as described by OSR.

Perhaps you should describe what you are trying to accomplish so you can
get some suggestions on how to do it.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Friday, July 23, 2004 11:39 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] how to create file in IRP_MJ_WRITE?

It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
a file in IRP_MJ_WRITE then?

thanks,

AFei


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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

Generally speaking, you can simply use a workitem, which guarantee you
run at PASSIVE_LEVEL. But, there’s still the problem of reentrancy.
So as Neal said, search for “shadow device object” on OSR for a better
solution. There should be an article on how to implement
IoCreateFileSpecifyDeviceObjectHint on w2k.

Regards,
Valerio

Neal Christiansen wrote:

Yes, you should not be trying to create files in operations like
IRP_MJ_READ or IRP_MJ_WRITE. You certainly can not call ZwCreateFile if
you are at APC level or are doing a paging IO. You can also severely
degrade system performance if you slow these operations down
significantly.

If at all possible it is best not to call ZwCreateFile from filters
because it generates recursive IO which causes lots of other problems
(kernel stack overflows, deadlocks with other filters, etc). You should
use IoCreateFileSpecifyDeviceObjectHint if at all possible. Another
option if you need to run your filter on W2K is using shadow device
objects as described by OSR.

Perhaps you should describe what you are trying to accomplish so you can
get some suggestions on how to do it.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Friday, July 23, 2004 11:39 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] how to create file in IRP_MJ_WRITE?

It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
a file in IRP_MJ_WRITE then?

thanks,

AFei


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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

Using ExQueueWorkItem I think.

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

----- Original Message -----
From: “AFei”
Newsgroups: ntfsd
To: “Windows File Systems Devs Interest List”
Sent: Friday, July 23, 2004 10:39 PM
Subject: [ntfsd] how to create file in IRP_MJ_WRITE?

> It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
> the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
> a file in IRP_MJ_WRITE then?
>
> thanks,
>
> AFei
>
>
>
> —
> Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Yes, I have solved the re-entry problems by shadow devices.
What I’m trying to do is basically a copy-on-write filter, once I got the
IRP_MJ_WRITE, I’ll backup this file to another place. At first step I
did this in IRP_MJ_CREATE when “open for write” happens, it
works good but too noisy. So a better way is to “copy on write” files,
that means created files in IRP_MJ_WRITE, any suggestions?

Another problem is, sometimes I got the error 0xc0000128
(STATUS_FILE_CLOSED) in IRP_MJ_WRITE if I generate
and send a new WRITE Irp to replace the original one. From the
traces, it’s real that a CLOSE irp was got before this WRITE irp,
but without my WRITE Irps, everything works smoothly. Did I
miss anything or do something wrong caused this problem?

Thanks a lot,

AFei

“Neal Christiansen” wrote in message
news:xxxxx@ntfsd…
Yes, you should not be trying to create files in operations like
IRP_MJ_READ or IRP_MJ_WRITE. You certainly can not call ZwCreateFile if
you are at APC level or are doing a paging IO. You can also severely
degrade system performance if you slow these operations down
significantly.

If at all possible it is best not to call ZwCreateFile from filters
because it generates recursive IO which causes lots of other problems
(kernel stack overflows, deadlocks with other filters, etc). You should
use IoCreateFileSpecifyDeviceObjectHint if at all possible. Another
option if you need to run your filter on W2K is using shadow device
objects as described by OSR.

Perhaps you should describe what you are trying to accomplish so you can
get some suggestions on how to do it.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Friday, July 23, 2004 11:39 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] how to create file in IRP_MJ_WRITE?

It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
a file in IRP_MJ_WRITE then?

thanks,

AFei


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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

Thanks for the response, looks like the workitem is for queuing a routing
to be run at PASSIVE_LEVEL, right? should it fit on the “copy on write”
use cases? please refer to my last post to Neal.

“valerino” wrote in message news:xxxxx@ntfsd…
> Generally speaking, you can simply use a workitem, which guarantee you
> run at PASSIVE_LEVEL. But, there’s still the problem of reentrancy.
> So as Neal said, search for “shadow device object” on OSR for a better
> solution. There should be an article on how to implement
> IoCreateFileSpecifyDeviceObjectHint on w2k.
>
> Regards,
> Valerio
>
> Neal Christiansen wrote:
>
> > Yes, you should not be trying to create files in operations like
> > IRP_MJ_READ or IRP_MJ_WRITE. You certainly can not call ZwCreateFile if
> > you are at APC level or are doing a paging IO. You can also severely
> > degrade system performance if you slow these operations down
> > significantly.
> >
> > If at all possible it is best not to call ZwCreateFile from filters
> > because it generates recursive IO which causes lots of other problems
> > (kernel stack overflows, deadlocks with other filters, etc). You should
> > use IoCreateFileSpecifyDeviceObjectHint if at all possible. Another
> > option if you need to run your filter on W2K is using shadow device
> > objects as described by OSR.
> >
> > Perhaps you should describe what you are trying to accomplish so you can
> > get some suggestions on how to do it.
> >
> > Neal Christiansen
> > Microsoft File System Filter Group Lead
> > This posting is provided “AS IS” with no warranties, and confers no
> > rights.
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of AFei
> > Sent: Friday, July 23, 2004 11:39 AM
> > To: Windows File Systems Devs Interest List
> > Subject: [ntfsd] how to create file in IRP_MJ_WRITE?
> >
> > It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
> > the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
> > a file in IRP_MJ_WRITE then?
> >
> > thanks,
> >
> > AFei
> >
> >
> >
> > —
> > Questions? First check the IFS FAQ at
> > https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@windows.microsoft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>

Will give it a try, thanks Maxim. /AFei

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntfsd…
> Using ExQueueWorkItem I think.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
> ----- Original Message -----
> From: “AFei”
> Newsgroups: ntfsd
> To: “Windows File Systems Devs Interest List”
> Sent: Friday, July 23, 2004 10:39 PM
> Subject: [ntfsd] how to create file in IRP_MJ_WRITE?
>
>
> > It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
> > the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
> > a file in IRP_MJ_WRITE then?
> >
> > thanks,
> >
> > AFei
> >
> >
> >
> > —
> > Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

File system rejects IRP_MJ_WRITE without IRP_PAGING_IO flag after the hadle
was closed.
Apparently the original IRP is PagingIo and you created an regular
IRP_MJ_WRITE

Alexei.

-----Original Message-----
From: AFei [mailto:xxxxx@hotmail.com]
Sent: Monday, July 26, 2004 10:27 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] how to create file in IRP_MJ_WRITE?

Yes, I have solved the re-entry problems by shadow devices.
What I’m trying to do is basically a copy-on-write filter, once I got the
IRP_MJ_WRITE, I’ll backup this file to another place. At first step I
did this in IRP_MJ_CREATE when “open for write” happens, it
works good but too noisy. So a better way is to “copy on write” files,
that means created files in IRP_MJ_WRITE, any suggestions?

Another problem is, sometimes I got the error 0xc0000128
(STATUS_FILE_CLOSED) in IRP_MJ_WRITE if I generate
and send a new WRITE Irp to replace the original one. From the
traces, it’s real that a CLOSE irp was got before this WRITE irp,
but without my WRITE Irps, everything works smoothly. Did I
miss anything or do something wrong caused this problem?

Thanks a lot,

AFei

“Neal Christiansen” wrote in message
news:xxxxx@ntfsd…
Yes, you should not be trying to create files in operations like
IRP_MJ_READ or IRP_MJ_WRITE. You certainly can not call ZwCreateFile if
you are at APC level or are doing a paging IO. You can also severely
degrade system performance if you slow these operations down
significantly.

If at all possible it is best not to call ZwCreateFile from filters
because it generates recursive IO which causes lots of other problems
(kernel stack overflows, deadlocks with other filters, etc). You should
use IoCreateFileSpecifyDeviceObjectHint if at all possible. Another
option if you need to run your filter on W2K is using shadow device
objects as described by OSR.

Perhaps you should describe what you are trying to accomplish so you can
get some suggestions on how to do it.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Friday, July 23, 2004 11:39 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] how to create file in IRP_MJ_WRITE?

It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
a file in IRP_MJ_WRITE then?

thanks,

AFei


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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

Just checked, you are right, after the IoBuildSynchronousFsdRequest(…), if
I copy over the original Irp->Flags, won’t see this error anymore, but is it
safe?
I mean simply copy the Flags or only take care the IRP_PAGING_IO flag.
thanks.

“Alexei Jelvis” wrote in message news:xxxxx@ntfsd…
File system rejects IRP_MJ_WRITE without IRP_PAGING_IO flag after the hadle
was closed.
Apparently the original IRP is PagingIo and you created an regular
IRP_MJ_WRITE

Alexei.

-----Original Message-----
From: AFei [mailto:xxxxx@hotmail.com]
Sent: Monday, July 26, 2004 10:27 AM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] how to create file in IRP_MJ_WRITE?

Yes, I have solved the re-entry problems by shadow devices.
What I’m trying to do is basically a copy-on-write filter, once I got the
IRP_MJ_WRITE, I’ll backup this file to another place. At first step I
did this in IRP_MJ_CREATE when “open for write” happens, it
works good but too noisy. So a better way is to “copy on write” files,
that means created files in IRP_MJ_WRITE, any suggestions?

Another problem is, sometimes I got the error 0xc0000128
(STATUS_FILE_CLOSED) in IRP_MJ_WRITE if I generate
and send a new WRITE Irp to replace the original one. From the
traces, it’s real that a CLOSE irp was got before this WRITE irp,
but without my WRITE Irps, everything works smoothly. Did I
miss anything or do something wrong caused this problem?

Thanks a lot,

AFei

“Neal Christiansen” wrote in message
news:xxxxx@ntfsd…
Yes, you should not be trying to create files in operations like
IRP_MJ_READ or IRP_MJ_WRITE. You certainly can not call ZwCreateFile if
you are at APC level or are doing a paging IO. You can also severely
degrade system performance if you slow these operations down
significantly.

If at all possible it is best not to call ZwCreateFile from filters
because it generates recursive IO which causes lots of other problems
(kernel stack overflows, deadlocks with other filters, etc). You should
use IoCreateFileSpecifyDeviceObjectHint if at all possible. Another
option if you need to run your filter on W2K is using shadow device
objects as described by OSR.

Perhaps you should describe what you are trying to accomplish so you can
get some suggestions on how to do it.

Neal Christiansen
Microsoft File System Filter Group Lead
This posting is provided “AS IS” with no warranties, and confers no
rights.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Friday, July 23, 2004 11:39 AM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] how to create file in IRP_MJ_WRITE?

It was said that the “Zw*” APIs were not stable in IRP_MJ_WRITE because
the IRQL may not be PASSIVE_LEVEL, is this correct? how can I create
a file in IRP_MJ_WRITE then?

thanks,

AFei


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

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