RE: Filter Manager Stream Context vs XP/W2K2 Per Stream C ontext

My question is specially about Stream Contexts (not Instance) in that, Can
they be made to work like PerStreamContext in the following why:

I attach a PSC to a FSContext and then wait until the callback routine is
called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I eventually
get a callback when the Stream is torn down or will it be held indefinitely
until I call FltReleaseContext one more time?

Ken

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

Ken,

Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.

If you are not seeing the delete in one of these cases it is because you
are not properly dereferencing the context.

I want to make this clear for everyone. It is very rare for a filter to
need to call FltReferenceContext(). The system does all the proper
referencing for you when you “get” a context. This was only added for
completeness.

As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.

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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.

When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added. When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted. At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released. Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time. If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.

Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext(). Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.

You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system. It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext
structure was being deleted to indicate time to delete/cleanup the PSC.

With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.

Ken


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

If you do a FltAllocateContext followed by a FltSetStreamContext and one
FltReleaseContext, you will get your context cleanup callback when the
stream is torn down. The reference added by FltSetStreamContext is
removed by the Filter Manager on your behalf when the file system tears
down the stream. If you have other references on the context caused by
other calls to FltGetStreamContext, your context cleanup routine will
not be called until all those references are released.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

My question is specially about Stream Contexts (not Instance) in that,
Can they be made to work like PerStreamContext in the following why:

I attach a PSC to a FSContext and then wait until the callback routine
is called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I
eventually get a callback when the Stream is torn down or will it be
held indefinitely until I call FltReleaseContext one more time?

Ken

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

Ken,

Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.

If you are not seeing the delete in one of these cases it is because you

are not properly dereferencing the context.

I want to make this clear for everyone. It is very rare for a filter to

need to call FltReferenceContext(). The system does all the proper
referencing for you when you “get” a context. This was only added for
completeness.

As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.

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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream

Context

The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.

When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added. When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted. At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released. Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time. If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.

Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext(). Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.

You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system. It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext

structure was being deleted to indicate time to delete/cleanup the PSC.

With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.

Ken


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@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@legato.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

Just to make sure this is clear (and to answer your first question); by
default contexts in filter manager work the same as PerStreamContexts in
the legacy model.

The only difference is, if you happen to have your own reference on a
context (by calling FltGetContext or FltReferenceContext) you will not
get the cleanup callback until you remove any extra references you have
added.

If you use contexts such that you get them on each operation and release
them when you are done processing that operation (either in the pre- or
post-Operation callback or when you complete a pended operation) then it
will function exactly like the PerStreamContext model. If you use them
this way there is no reason to ever call the FltDeleteXxxContext
routines because the filter manager does proper lifetime management.

In case this has not been stated clearly; if your filter is unloaded the
filter manager will automatically cleanup all outstanding contexts your
filter has created. You do not need to track them and delete them
yourself. We have made this very simple and straightforward to use.

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 Molly Brown
Sent: Thursday, March 11, 2004 1:05 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

If you do a FltAllocateContext followed by a FltSetStreamContext and one
FltReleaseContext, you will get your context cleanup callback when the
stream is torn down. The reference added by FltSetStreamContext is
removed by the Filter Manager on your behalf when the file system tears
down the stream. If you have other references on the context caused by
other calls to FltGetStreamContext, your context cleanup routine will
not be called until all those references are released.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

My question is specially about Stream Contexts (not Instance) in that,
Can they be made to work like PerStreamContext in the following why:

I attach a PSC to a FSContext and then wait until the callback routine
is called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I
eventually get a callback when the Stream is torn down or will it be
held indefinitely until I call FltReleaseContext one more time?

Ken

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

Ken,

Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.

If you are not seeing the delete in one of these cases it is because you

are not properly dereferencing the context.

I want to make this clear for everyone. It is very rare for a filter to

need to call FltReferenceContext(). The system does all the proper
referencing for you when you “get” a context. This was only added for
completeness.

As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.

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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream

Context

The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.

When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added. When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted. At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released. Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time. If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.

Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext(). Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.

You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system. It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext

structure was being deleted to indicate time to delete/cleanup the PSC.

With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.

Ken


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@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@legato.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


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

The reason for my confusion is the FltAllocateContext also puts a reference
on the context. i.e. If I call FltAllocateContext and then FltReleaseContext
the context will get cleaned up. If I call FltAllocateContext and FltSet and
two Releases the Context gets cleaned up. If I call FltAllocateContext and
FltSet and don’t do any Releases I don’t get a callback when I unload. If I
do one Release I do. So in that case as far as I’m concerned I still have a
reference (from the FltAllocate) and it also should not get cleaned up
during the unloaded. But it does, so the rule seems to be if there is one
reference it will get cleaned up during unload?

I have it working by the way. It has just taken a while understand the
referencing as described above, for me is hasn’t been that simple and
straight forward.

Thanks for hanging in on the explanations.

Ken

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, March 11, 2004 10:21 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

Just to make sure this is clear (and to answer your first question); by
default contexts in filter manager work the same as PerStreamContexts in
the legacy model.

The only difference is, if you happen to have your own reference on a
context (by calling FltGetContext or FltReferenceContext) you will not
get the cleanup callback until you remove any extra references you have
added.

If you use contexts such that you get them on each operation and release
them when you are done processing that operation (either in the pre- or
post-Operation callback or when you complete a pended operation) then it
will function exactly like the PerStreamContext model. If you use them
this way there is no reason to ever call the FltDeleteXxxContext
routines because the filter manager does proper lifetime management.

In case this has not been stated clearly; if your filter is unloaded the
filter manager will automatically cleanup all outstanding contexts your
filter has created. You do not need to track them and delete them
yourself. We have made this very simple and straightforward to use.

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 Molly Brown
Sent: Thursday, March 11, 2004 1:05 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

If you do a FltAllocateContext followed by a FltSetStreamContext and one
FltReleaseContext, you will get your context cleanup callback when the
stream is torn down. The reference added by FltSetStreamContext is
removed by the Filter Manager on your behalf when the file system tears
down the stream. If you have other references on the context caused by
other calls to FltGetStreamContext, your context cleanup routine will
not be called until all those references are released.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

My question is specially about Stream Contexts (not Instance) in that,
Can they be made to work like PerStreamContext in the following why:

I attach a PSC to a FSContext and then wait until the callback routine
is called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I
eventually get a callback when the Stream is torn down or will it be
held indefinitely until I call FltReleaseContext one more time?

Ken

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

Ken,

Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.

If you are not seeing the delete in one of these cases it is because you

are not properly dereferencing the context.

I want to make this clear for everyone. It is very rare for a filter to

need to call FltReferenceContext(). The system does all the proper
referencing for you when you “get” a context. This was only added for
completeness.

As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.

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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream

Context

The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.

When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added. When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted. At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released. Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time. If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.

Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext(). Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.

You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system. It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.

Molly Brown
Microsoft Corporation

This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext

structure was being deleted to indicate time to delete/cleanup the PSC.

With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.

Ken


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@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@legato.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


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

Ken,

I believe you are trying to make it harder then it actually is.

Yes, a reference is added when you allocate a context. Yes a second reference is added when you set the context but that is the “residual” reference that filter manager uses to keep the context around until the file system tells us the file is going away, or your filter unloads, or your filter explicitly delete it. If you look at the samples you will see they all do allocate,set,release. This then leaves the “resididial” count if the set succeeded or deletes the context if the set failed.

When I was writing this I originally was not putting a count when allocating the context but then needed a separate routine to free the allocated context if the set failed. By doing it this way the release properly handles freeing a context that does not get properly set.

If you were running with a CHKd version of filter manager (which I would recommend) and did the allocate,set,release,release you would asserted on the 2nd release because you are not allowed to remove the residual count through release.

If the documentation is not clear enough please let me know and I will have it beefed up.

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


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 12, 2004 9:07 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C ontext

The reason for my confusion is the FltAllocateContext also puts a reference on the context. i.e. If I call FltAllocateContext and then FltReleaseContext the context will get cleaned up. If I call FltAllocateContext and FltSet and two Releases the Context gets cleaned up. If I call FltAllocateContext and FltSet and don’t do any Releases I don’t get a callback when I unload. If I do one Release I do. So in that case as far as I’m concerned I still have a reference (from the FltAllocate) and it also should not get cleaned up during the unloaded. But it does, so the rule seems to be if there is one reference it will get cleaned up during unload?
I have it working by the way. It has just taken a while understand the referencing as described above, for me is hasn’t been that simple and straight forward.
Thanks for hanging in on the explanations.
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, March 11, 2004 10:21 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C ontext
Just to make sure this is clear (and to answer your first question); by
default contexts in filter manager work the same as PerStreamContexts in
the legacy model.?
The only difference is, if you happen to have your own reference on a
context (by calling FltGetContext or FltReferenceContext) you will not
get the cleanup callback until you remove any extra references you have
added.?
If you use contexts such that you get them on each operation and release
them when you are done processing that operation (either in the pre- or
post-Operation callback or when you complete a pended operation) then it
will function exactly like the PerStreamContext model.? If you use them
this way there is no reason to ever call the FltDeleteXxxContext
routines because the filter manager does proper lifetime management.
In case this has not been stated clearly; if your filter is unloaded the
filter manager will automatically cleanup all outstanding contexts your
filter has created.? You do not need to track them and delete them
yourself. We have made this very simple and straightforward to use.
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 Molly Brown
Sent: Thursday, March 11, 2004 1:05 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext
If you do a FltAllocateContext followed by a FltSetStreamContext and one
FltReleaseContext, you will get your context cleanup callback when the
stream is torn down.? The reference added by FltSetStreamContext is
removed by the Filter Manager on your behalf when the file system tears
down the stream.? If you have other references on the context caused by
other calls to FltGetStreamContext, your context cleanup routine will
not be called until all those references are released.
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

My question is specially about Stream Contexts (not Instance) in that,
Can they be made to work like PerStreamContext in the following why:
I attach a PSC to a FSContext and then wait until the callback routine
is called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I
eventually get a callback when the Stream is torn down or will it be
held indefinitely until I call FltReleaseContext one more time?
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context
Ken,
Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.
If you are not seeing the delete in one of these cases it is because you
are not properly dereferencing the context.
I want to make this clear for everyone.? It is very rare for a filter to
need to call FltReferenceContext().? The system does all the proper
referencing for you when you “get” a context.? This was only added for
completeness.
As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.
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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context
The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.
?
When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added.? When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted.? At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released.? Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time.? If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.
Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext().? Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.
?
You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system.? It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.
?
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext
structure was being deleted to indicate time to delete/cleanup the PSC.
With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.
Ken

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@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@legato.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

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@legato.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

Neal, et. al. -

It looks like Ken and I have had the same misconceptions about context ref
counts. I’d venture a guess that the documentation DOES need to be beefed up
in this area.

One thing that might help is a simple Stream & StreamHandle context tracking
example where one keeps these contexts from CREATE to Post-CLOSE. This is
what we have been struggling with and now, thanks to your explanations, we
have it working. Nowhere in the current set of examples is
FltSetStreamContext() used.

/ted

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Friday, March 12, 2004 12:58 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

Ken,

I believe you are trying to make it harder then it actually is.

Yes, a reference is added when you allocate a context. Yes a second
reference is added when you set the context but that is the “residual”
reference that filter manager uses to keep the context around until the file
system tells us the file is going away, or your filter unloads, or your
filter explicitly delete it. If you look at the samples you will see they
all do allocate,set,release. This then leaves the “resididial” count if the
set succeeded or deletes the context if the set failed.

When I was writing this I originally was not putting a count when allocating
the context but then needed a separate routine to free the allocated context
if the set failed. By doing it this way the release properly handles
freeing a context that does not get properly set.

If you were running with a CHKd version of filter manager (which I would
recommend) and did the allocate,set,release,release you would asserted on
the 2nd release because you are not allowed to remove the residual count
through release.

If the documentation is not clear enough please let me know and I will have
it beefed up.

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


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 12, 2004 9:07 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

The reason for my confusion is the FltAllocateContext also puts a reference
on the context. i.e. If I call FltAllocateContext and then FltReleaseContext
the context will get cleaned up. If I call FltAllocateContext and FltSet and
two Releases the Context gets cleaned up. If I call FltAllocateContext and
FltSet and don’t do any Releases I don’t get a callback when I unload. If I
do one Release I do. So in that case as far as I’m concerned I still have a
reference (from the FltAllocate) and it also should not get cleaned up
during the unloaded. But it does, so the rule seems to be if there is one
reference it will get cleaned up during unload? I have it working by the
way. It has just taken a while understand the referencing as described
above, for me is hasn’t been that simple and straight forward. Thanks for
hanging in on the explanations.
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, March 11, 2004 10:21 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext
Just to make sure this is clear (and to answer your first question); by
default contexts in filter manager work the same as PerStreamContexts in
the legacy model.?
The only difference is, if you happen to have your own reference on a
context (by calling FltGetContext or FltReferenceContext) you will not
get the cleanup callback until you remove any extra references you have
added.?
If you use contexts such that you get them on each operation and release
them when you are done processing that operation (either in the pre- or
post-Operation callback or when you complete a pended operation) then it
will function exactly like the PerStreamContext model.? If you use them
this way there is no reason to ever call the FltDeleteXxxContext
routines because the filter manager does proper lifetime management.
In case this has not been stated clearly; if your filter is unloaded the
filter manager will automatically cleanup all outstanding contexts your
filter has created.? You do not need to track them and delete them
yourself. We have made this very simple and straightforward to use.
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 Molly Brown
Sent: Thursday, March 11, 2004 1:05 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext
If you do a FltAllocateContext followed by a FltSetStreamContext and one
FltReleaseContext, you will get your context cleanup callback when the
stream is torn down.? The reference added by FltSetStreamContext is
removed by the Filter Manager on your behalf when the file system tears
down the stream.? If you have other references on the context caused by
other calls to FltGetStreamContext, your context cleanup routine will
not be called until all those references are released.
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

My question is specially about Stream Contexts (not Instance) in that,
Can they be made to work like PerStreamContext in the following why:
I attach a PSC to a FSContext and then wait until the callback routine
is called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I
eventually get a callback when the Stream is torn down or will it be
held indefinitely until I call FltReleaseContext one more time?
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context
Ken,
Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.
If you are not seeing the delete in one of these cases it is because you
are not properly dereferencing the context.
I want to make this clear for everyone.? It is very rare for a filter to
need to call FltReferenceContext().? The system does all the proper
referencing for you when you “get” a context.? This was only added for
completeness.
As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.
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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context
The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.
?
When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added.? When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted.? At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released.? Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time.? If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.
Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext().? Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.
?
You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system.? It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.
?
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext
structure was being deleted to indicate time to delete/cleanup the PSC.
With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.
Ken

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@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@legato.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

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@legato.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


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

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

Ted,

We did have a sample that showed how to use contexts and I had forgotten that we removed it for other reasons. We will get a sample that shows how to use contexts in the next IFSKit update.

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 Ted Hess
Sent: Friday, March 12, 2004 11:56 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C ontext

Neal, et. al. -

It looks like Ken and I have had the same misconceptions about context ref
counts. I’d venture a guess that the documentation DOES need to be beefed up
in this area.

One thing that might help is a simple Stream & StreamHandle context tracking
example where one keeps these contexts from CREATE to Post-CLOSE. This is
what we have been struggling with and now, thanks to your explanations, we
have it working. Nowhere in the current set of examples is
FltSetStreamContext() used.

/ted

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Friday, March 12, 2004 12:58 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

Ken,

I believe you are trying to make it harder then it actually is.

Yes, a reference is added when you allocate a context. Yes a second
reference is added when you set the context but that is the “residual”
reference that filter manager uses to keep the context around until the file
system tells us the file is going away, or your filter unloads, or your
filter explicitly delete it. If you look at the samples you will see they
all do allocate,set,release. This then leaves the “resididial” count if the
set succeeded or deletes the context if the set failed.

When I was writing this I originally was not putting a count when allocating
the context but then needed a separate routine to free the allocated context
if the set failed. By doing it this way the release properly handles
freeing a context that does not get properly set.

If you were running with a CHKd version of filter manager (which I would
recommend) and did the allocate,set,release,release you would asserted on
the 2nd release because you are not allowed to remove the residual count
through release.

If the documentation is not clear enough please let me know and I will have
it beefed up.

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


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 12, 2004 9:07 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

The reason for my confusion is the FltAllocateContext also puts a reference
on the context. i.e. If I call FltAllocateContext and then FltReleaseContext
the context will get cleaned up. If I call FltAllocateContext and FltSet and
two Releases the Context gets cleaned up. If I call FltAllocateContext and
FltSet and don’t do any Releases I don’t get a callback when I unload. If I
do one Release I do. So in that case as far as I’m concerned I still have a
reference (from the FltAllocate) and it also should not get cleaned up
during the unloaded. But it does, so the rule seems to be if there is one
reference it will get cleaned up during unload? I have it working by the
way. It has just taken a while understand the referencing as described
above, for me is hasn’t been that simple and straight forward. Thanks for
hanging in on the explanations.
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, March 11, 2004 10:21 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext
Just to make sure this is clear (and to answer your first question); by
default contexts in filter manager work the same as PerStreamContexts in
the legacy model.?
The only difference is, if you happen to have your own reference on a
context (by calling FltGetContext or FltReferenceContext) you will not
get the cleanup callback until you remove any extra references you have
added.?
If you use contexts such that you get them on each operation and release
them when you are done processing that operation (either in the pre- or
post-Operation callback or when you complete a pended operation) then it
will function exactly like the PerStreamContext model.? If you use them
this way there is no reason to ever call the FltDeleteXxxContext
routines because the filter manager does proper lifetime management.
In case this has not been stated clearly; if your filter is unloaded the
filter manager will automatically cleanup all outstanding contexts your
filter has created.? You do not need to track them and delete them
yourself. We have made this very simple and straightforward to use.
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 Molly Brown
Sent: Thursday, March 11, 2004 1:05 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext
If you do a FltAllocateContext followed by a FltSetStreamContext and one
FltReleaseContext, you will get your context cleanup callback when the
stream is torn down.? The reference added by FltSetStreamContext is
removed by the Filter Manager on your behalf when the file system tears
down the stream.? If you have other references on the context caused by
other calls to FltGetStreamContext, your context cleanup routine will
not be called until all those references are released.
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
C ontext

My question is specially about Stream Contexts (not Instance) in that,
Can they be made to work like PerStreamContext in the following why:
I attach a PSC to a FSContext and then wait until the callback routine
is called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I
eventually get a callback when the Stream is torn down or will it be
held indefinitely until I call FltReleaseContext one more time?
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context
Ken,
Instance contexts will not get deleted unless you’re your filter is
unloaded, the volume is dismounted, or a specific request is made to
detach your filter from the given volume.
If you are not seeing the delete in one of these cases it is because you
are not properly dereferencing the context.
I want to make this clear for everyone.? It is very rare for a filter to
need to call FltReferenceContext().? The system does all the proper
referencing for you when you “get” a context.? This was only added for
completeness.
As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.
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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context
The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.
?
When your StreamContext is associate with a stream
(FltSetStreamContext()), a reference is added.? When the file system is
ready to teardown its stream data structures, it calls the Filter
Manager to say it is being deleted.? At this point, the Filter Manager
will remove the reference on your StreamContext (as it is now unlinked
from the stream object), but Filter Manager will not call your
registered context delete routine until all the references to your
StreamContext are released.? Typically, this reference is the last
reference on your stream context, so you will receive your context
teardown at this time.? If you do some sort of asynchronous processing
of your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed
until all those references are released.
Getting to the point where the reference count on your StreamContext is
0 should not require you to call FltDeleteContext().? Just make sure
that for every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.
?
You only need to call FltDeleteContext() when you need to remove the
link between your context and the object *before* the object’s lifetime
is ended by the system.? It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness
sake rather than to address a common functional need.
?
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no
rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context

XP and W2K3 introduced Per Stream Context to associate a context with a
file stream. With PSC a call back occurred when the underlying FsContext
structure was being deleted to indicate time to delete/cleanup the PSC.
With the Mini Filter, is there something analogous? Or will the
FsContext (or whatever a PSC is tied to) not be deleted until the mini
filter does a FltReleaseContext or FltDeleteContext. I see there is a
callback for when context are being deleted, but with Instance context
they never get deleted unless I first release or delete them.
Ken

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@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@legato.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

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@legato.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


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

You are currently subscribed to ntfsd as: xxxxx@livevault.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

I think beefing up the docs would be a good idea and/or like Ted says have
some examples.

Personally I think it would have been clearer to have:
FltAllocate with a FltFree (or OS callback)
FltSet (to attach to a Stream) with a FltRemove (to Remove from a stream)
(also having to do a FltRelease is ok, but doing it if it fails is very
strange).
FltGet with a FltRelease

As soon as you say if you hold a reference the context won’t get deleted,
its confusing because the Allocate adds a Reference but not really, That’s
why I think that shouldn’t be called a reference and should have a matching
FltFree.

Ken

-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Friday, March 12, 2004 12:58 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

Ken,

I believe you are trying to make it harder then it actually is.

Yes, a reference is added when you allocate a context. Yes a second
reference is added when you set the context but that is the “residual”
reference that filter manager uses to keep the context around until the file
system tells us the file is going away, or your filter unloads, or your
filter explicitly delete it. If you look at the samples you will see they
all do allocate,set,release. This then leaves the “resididial” count if the
set succeeded or deletes the context if the set failed.

When I was writing this I originally was not putting a count when allocating
the context but then needed a separate routine to free the allocated context
if the set failed. By doing it this way the release properly handles
freeing a context that does not get properly set.

If you were running with a CHKd version of filter manager (which I would
recommend) and did the allocate,set,release,release you would asserted on
the 2nd release because you are not allowed to remove the residual count
through release.

If the documentation is not clear enough please let me know and I will have
it beefed up.

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


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 12, 2004 9:07 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

The reason for my confusion is the FltAllocateContext also puts a reference
on the context. i.e. If I call FltAllocateContext and then FltReleaseContext
the context will get cleaned up. If I call FltAllocateContext and FltSet and
two Releases the Context gets cleaned up. If I call FltAllocateContext and
FltSet and don’t do any Releases I don’t get a callback when I unload. If I
do one Release I do. So in that case as far as I’m concerned I still have a
reference (from the FltAllocate) and it also should not get cleaned up
during the unloaded. But it does, so the rule seems to be if there is one
reference it will get cleaned up during unload?
I have it working by the way. It has just taken a while understand the
referencing as described above, for me is hasn’t been that simple and
straight forward.
Thanks for hanging in on the explanations.
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Thursday, March 11, 2004 10:21 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext Just to make sure this is clear (and to answer your first question);
by default contexts in filter manager work the same as PerStreamContexts in
the legacy model. The only difference is, if you happen to have your own
reference on a context (by calling FltGetContext or FltReferenceContext) you
will not get the cleanup callback until you remove any extra references you
have added. If you use contexts such that you get them on each operation and
release them when you are done processing that operation (either in the pre-
or post-Operation callback or when you complete a pended operation) then it
will function exactly like the PerStreamContext model.? If you use them this
way there is no reason to ever call the FltDeleteXxxContext routines because
the filter manager does proper lifetime management.
In case this has not been stated clearly; if your filter is unloaded the
filter manager will automatically cleanup all outstanding contexts your
filter has created.? You do not need to track them and delete them yourself.
We have made this very simple and straightforward to use.
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 Molly Brown
Sent: Thursday, March 11, 2004 1:05 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext If you do a FltAllocateContext followed by a FltSetStreamContext and
one FltReleaseContext, you will get your context cleanup callback when the
stream is torn down.? The reference added by FltSetStreamContext is removed
by the Filter Manager on your behalf when the file system tears down the
stream.? If you have other references on the context caused by other calls
to FltGetStreamContext, your context cleanup routine will not be called
until all those references are released.
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Thursday, March 11, 2004 12:10 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream C
ontext

My question is specially about Stream Contexts (not Instance) in that, Can
they be made to work like PerStreamContext in the following why:
I attach a PSC to a FSContext and then wait until the callback routine is
called for me to delete my PSC. How do I get the same behavior using
FLtAllocateContext and FltSetStreamContext. If I do a FltAllocateContext
followed by a FltSetStreamContext and 1 FltReleaseContext, will I eventually
get a callback when the Stream is torn down or will it be held indefinitely
until I call FltReleaseContext one more time?
Ken
-----Original Message-----
From: Neal Christiansen [mailto:xxxxx@windows.microsoft.com]
Sent: Wednesday, March 10, 2004 2:28 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context Ken, Instance contexts will not get deleted unless you’re your
filter is unloaded, the volume is dismounted, or a specific request is made
to detach your filter from the given volume.
If you are not seeing the delete in one of these cases it is because you are
not properly dereferencing the context.
I want to make this clear for everyone.? It is very rare for a filter to
need to call FltReferenceContext().? The system does all the proper
referencing for you when you “get” a context.? This was only added for
completeness.
As Molly has already pointed out, if you used a chk’d version of filter
manager (which I would recommend during development) if you unload your
filter leaked contexts will be reported on the debugger screen.
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 Molly Brown
Sent: Monday, March 08, 2004 11:02 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream
Context The Filter Manager implements the StreamContexts using the
PerStreamContext support which the file systems provide.
?
When your StreamContext is associate with a stream (FltSetStreamContext()),
a reference is added.? When the file system is ready to teardown its stream
data structures, it calls the Filter Manager to say it is being deleted.? At
this point, the Filter Manager will remove the reference on your
StreamContext (as it is now unlinked from the stream object), but Filter
Manager will not call your registered context delete routine until all the
references to your StreamContext are released.? Typically, this reference is
the last reference on your stream context, so you will receive your context
teardown at this time.? If you do some sort of asynchronous processing of
your stream contexts, you may have an outstanding reference on your
StreamContext, therefore the context teardown callback will be delayed until
all those references are released.
Getting to the point where the reference count on your StreamContext is 0
should not require you to call FltDeleteContext().? Just make sure that for
every FltGetStreamContext() your filter calls, you call
FltReleaseContext() to release the reference.
?
You only need to call FltDeleteContext() when you need to remove the link
between your context and the object *before* the object’s lifetime is ended
by the system.? It is very likely that you never need to call
FltDeleteContext() in your filter – it was added more for completeness sake
rather than to address a common functional need.
?
Molly Brown
Microsoft Corporation
?
This posting is provided “AS IS” with no warranties and confers no rights.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Ken Galipeau
Sent: Friday, March 05, 2004 1:47 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] Filter Manager Stream Context vs XP/W2K2 Per Stream Context

XP and W2K3 introduced Per Stream Context to associate a context with a file
stream. With PSC a call back occurred when the underlying FsContext
structure was being deleted to indicate time to delete/cleanup the PSC.
With the Mini Filter, is there something analogous? Or will the FsContext
(or whatever a PSC is tied to) not be deleted until the mini filter does a
FltReleaseContext or FltDeleteContext. I see there is a callback for when
context are being deleted, but with Instance context they never get deleted
unless I first release or delete them.
Ken

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@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@legato.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

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@legato.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


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

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