Generate CREATE IRP in IRP_MJ_WRITE?

It was said that the ZwCreateFile() is dangerous in IRP_MJ_WRITE routine
because
the IRQL might be DISPATCH_LEVEL, so how about to directly build and send a
IRP_MJ_CREATE IRP inside the IRP_MJ_WRITE? is this safe?

thanks,

AFei

I presume you are talking about a filesystem filter driver in the context of
this list.

The IRP_MJ_WRITE dispatch ‘should’ not be called at DISPATCH. The completion
routine can be called at DISPATCH.

If you are building an IRP_MJ_CREATE in the completion routine, then you
will be working some late nights getting it to work right. On the dispatch
side, there ‘should’ not be any need to do this.

Pete

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-183369-
xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Tuesday, August 03, 2004 5:58 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Generate CREATE IRP in IRP_MJ_WRITE?

It was said that the ZwCreateFile() is dangerous in IRP_MJ_WRITE routine
because
the IRQL might be DISPATCH_LEVEL, so how about to directly build and send
a
IRP_MJ_CREATE IRP inside the IRP_MJ_WRITE? is this safe?

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@kerneldrivers.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

There are multiple problems with you doing this type of operation
synchronously in write.

  • Peter pointed out the problem in doing this during post-write.

  • Even if you are doing this in the pre-write this can be dangerous.
    You can not do this if you are at APC level (usually during paging
    writes) because you are not allowed to issue a create IRP at APC level.
    Due to how the system works the first write you see on a file is often a
    paging write.

  • Affecting the performance of write IRPS by calling create can
    seriously degrade system performance if you do this often.

  • As has been mentioned many times, calling ZwCreateFile has problem
    because of recursive IO issues.

  • It is very difficult to role your own create IRP because filters don’t
    have the ability to generate the security context parameter.

From what I recall from previous postings you are trying to implement
some sort of copy-on-write filter. Microsoft has such a filter called
SIS (stands for single-instance-store). It was originally released as
part of Windows 2000 Server and is used in conjunction with the Remote
Install (RIS) component.

SIS has never needed to create a file during the write path. You might
want to rethink your architecture so that you can eliminate this kind of
requirement.

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 Peter Scott
Sent: Tuesday, August 03, 2004 9:01 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Generate CREATE IRP in IRP_MJ_WRITE?

I presume you are talking about a filesystem filter driver in the
context of
this list.

The IRP_MJ_WRITE dispatch ‘should’ not be called at DISPATCH. The
completion
routine can be called at DISPATCH.

If you are building an IRP_MJ_CREATE in the completion routine, then you
will be working some late nights getting it to work right. On the
dispatch
side, there ‘should’ not be any need to do this.

Pete

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-183369-
xxxxx@lists.osr.com] On Behalf Of AFei
Sent: Tuesday, August 03, 2004 5:58 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Generate CREATE IRP in IRP_MJ_WRITE?

It was said that the ZwCreateFile() is dangerous in IRP_MJ_WRITE
routine
because
the IRQL might be DISPATCH_LEVEL, so how about to directly build and
send
a
IRP_MJ_CREATE IRP inside the IRP_MJ_WRITE? is this safe?

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@kerneldrivers.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@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Hi Peter & Neal,

Thanks for your reply, it helps me a lot.
Pre-write, post-write, performance, security context are all problems.
Looks like doing CREATE irp in MJ_IRP_WRITE is not a good idea.
Yes, I’m doing the copy-on-write filter driver, so when is the best time to
create the backup file in my case? I’m doing this in MJ_IRP_CREATE now,
but it’s very noisy because lots of files are opened for write actually
didn’t
being written, also, I have to remove those zero bytes files in
MJ_IRP_CLOSE,
from the high level point of the view, it’s best if I can do a real
copy-on-write,

Best regards,

AFei

“Neal Christiansen” wrote in message
news:xxxxx@ntfsd…
There are multiple problems with you doing this type of operation
synchronously in write.

- Peter pointed out the problem in doing this during post-write.

- Even if you are doing this in the pre-write this can be dangerous.
You can not do this if you are at APC level (usually during paging
writes) because you are not allowed to issue a create IRP at APC level.
Due to how the system works the first write you see on a file is often a
paging write.

- Affecting the performance of write IRPS by calling create can
seriously degrade system performance if you do this often.

- As has been mentioned many times, calling ZwCreateFile has problem
because of recursive IO issues.

- It is very difficult to role your own create IRP because filters don’t
have the ability to generate the security context parameter.

From what I recall from previous postings you are trying to implement
some sort of copy-on-write filter. Microsoft has such a filter called
SIS (stands for single-instance-store). It was originally released as
part of Windows 2000 Server and is used in conjunction with the Remote
Install (RIS) component.

SIS has never needed to create a file during the write path. You might
want to rethink your architecture so that you can eliminate this kind of
requirement.

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 Peter Scott
Sent: Tuesday, August 03, 2004 9:01 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Generate CREATE IRP in IRP_MJ_WRITE?

I presume you are talking about a filesystem filter driver in the
context of
this list.

The IRP_MJ_WRITE dispatch ‘should’ not be called at DISPATCH. The
completion
routine can be called at DISPATCH.

If you are building an IRP_MJ_CREATE in the completion routine, then you
will be working some late nights getting it to work right. On the
dispatch
side, there ‘should’ not be any need to do this.

Pete

Peter Scott
xxxxx@KernelDrivers.com
www.KernelDrivers.com

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-183369-
> xxxxx@lists.osr.com] On Behalf Of AFei
> Sent: Tuesday, August 03, 2004 5:58 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] Generate CREATE IRP in IRP_MJ_WRITE?
>
>
> It was said that the ZwCreateFile() is dangerous in IRP_MJ_WRITE
routine
> because
> the IRQL might be DISPATCH_LEVEL, so how about to directly build and
send
> a
> IRP_MJ_CREATE IRP inside the IRP_MJ_WRITE? is this safe?
>
> 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@kerneldrivers.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@windows.microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com