RE: How check if there is dirty data in the cache after IRP_MJ_CLEANUP

Well what you can do is ENSURE there is no dirty data for a file in your
cleanup handler, and then do whatever post-processing is necessary. To
do this, take both FCB resources exclusive and then flush the NT cache
for the file using CcFlushCache/MmFlushImageSection/CcPurgeCacheSection.
Now it’s been guaranteed that all modified pages have been flushed to
disk. Then perform your post-processing before releasing the FCB
resources.

  • Nicholas Ryan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-ntfsd-
xxxxx@lists.osr.com] On Behalf Of Robin
Sent: Tuesday, February 19, 2002 4:00 AM
To: File Systems Developers
Subject: [ntfsd] How check if there is dirty data in the cache after
IRP_MJ_CLEANUP

Hello all,

I am monitoring file modifications (specially IRP_MJ_WRITE) from a
filter
driver and need to do something when all handles to a monitored file
are
closed and there is no more dirty data in the cache for this file. The
problem is how can I determine if there is still dirty data in the
cache
for this file and when the last dirty page for this file is flushed
out to
the disk using a paging IO through IRP_MJ_WRITE? I want to check this
in
the completion routine of both IRP_MJ_CLEANUP and IRP_MJ_WRITE (for
paging
IO only).

Is there something like “CcIsThereDirtyData” for the FileObject? I
have
tried “CcGetLsnForFileObject”, but it is always returning zero.

Any idea on how to solve this problem (on NT/2K/XP) will be highly
appreciated. Thanks in advance.

Regards,
Robin


You are currently subscribed to ntfsd as: xxxxx@secretseal.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

If I understand the memory manager correctly, this guarantee breaks if the file is memory mapped.

-----Original Message-----
From: Nicholas Ryan [mailto:xxxxx@secretseal.com]
Sent: Tuesday, February 19, 2002 1:13 PM
To: File Systems Developers
Subject: [ntfsd] RE: How check if there is dirty data in the cache after
IRP_MJ_CLEANUP

Well what you can do is ENSURE there is no dirty data for a file in your
cleanup handler, and then do whatever post-processing is necessary. To
do this, take both FCB resources exclusive and then flush the NT cache
for the file using CcFlushCache/MmFlushImageSection/CcPurgeCacheSection.
Now it’s been guaranteed that all modified pages have been flushed to
disk. Then perform your post-processing before releasing the FCB
resources.

  • Nicholas Ryan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-ntfsd-
xxxxx@lists.osr.com] On Behalf Of Robin
Sent: Tuesday, February 19, 2002 4:00 AM
To: File Systems Developers
Subject: [ntfsd] How check if there is dirty data in the cache after
IRP_MJ_CLEANUP

Hello all,

I am monitoring file modifications (specially IRP_MJ_WRITE) from a
filter
driver and need to do something when all handles to a monitored file
are
closed and there is no more dirty data in the cache for this file. The
problem is how can I determine if there is still dirty data in the
cache
for this file and when the last dirty page for this file is flushed
out to
the disk using a paging IO through IRP_MJ_WRITE? I want to check this
in
the completion routine of both IRP_MJ_CLEANUP and IRP_MJ_WRITE (for
paging
IO only).

Is there something like “CcIsThereDirtyData” for the FileObject? I
have
tried “CcGetLsnForFileObject”, but it is always returning zero.

Any idea on how to solve this problem (on NT/2K/XP) will be highly
appreciated. Thanks in advance.

Regards,
Robin


You are currently subscribed to ntfsd as: xxxxx@secretseal.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@inin.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Well, it’s certainly impossible to PURGE memory-mapped cache pages, but
there is no restriction against forcing a modified memory map to flush
to disk. The poster may run into problems if he is doing something like
in-place encryption of data in the cache while it’s still memory-mapped,
so if he is doing something that may conflict with a user simultaneously
writing to the mapped cache pages, he should check for the
FSRTL_FLAG_USER_MAPPED_FILE flag and not perform the post-processing.

I shouldn’t have even mentioned the CcPurgeCacheSection call below, it’s
not necessary if all you want to do is flush dirty data (as opposed to
blowing away the entire cache).

  • Nicholas Ryan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-ntfsd-
xxxxx@lists.osr.com] On Behalf Of Fuller, Rob
Sent: Tuesday, February 19, 2002 10:36 AM
To: File Systems Developers
Subject: [ntfsd] RE: How check if there is dirty data in the cache
after
IRP_MJ_CLEANUP

If I understand the memory manager correctly, this guarantee breaks if
the
file is memory mapped.

-----Original Message-----
From: Nicholas Ryan [mailto:xxxxx@secretseal.com]
Sent: Tuesday, February 19, 2002 1:13 PM
To: File Systems Developers
Subject: [ntfsd] RE: How check if there is dirty data in the cache
after
IRP_MJ_CLEANUP

Well what you can do is ENSURE there is no dirty data for a file in
your
cleanup handler, and then do whatever post-processing is necessary. To
do this, take both FCB resources exclusive and then flush the NT cache
for the file using
CcFlushCache/MmFlushImageSection/CcPurgeCacheSection.
Now it’s been guaranteed that all modified pages have been flushed to
disk. Then perform your post-processing before releasing the FCB
resources.

  • Nicholas Ryan

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-ntfsd-
> xxxxx@lists.osr.com] On Behalf Of Robin
> Sent: Tuesday, February 19, 2002 4:00 AM
> To: File Systems Developers
> Subject: [ntfsd] How check if there is dirty data in the cache after
> IRP_MJ_CLEANUP
>
> Hello all,
>
> I am monitoring file modifications (specially IRP_MJ_WRITE) from a
filter
> driver and need to do something when all handles to a monitored file
are
> closed and there is no more dirty data in the cache for this file.
The
> problem is how can I determine if there is still dirty data in the
cache
> for this file and when the last dirty page for this file is flushed
out to
> the disk using a paging IO through IRP_MJ_WRITE? I want to check
this
in
> the completion routine of both IRP_MJ_CLEANUP and IRP_MJ_WRITE (for
paging
> IO only).
>
> Is there something like “CcIsThereDirtyData” for the FileObject? I
have
> tried “CcGetLsnForFileObject”, but it is always returning zero.
>
> Any idea on how to solve this problem (on NT/2K/XP) will be highly
> appreciated. Thanks in advance.
>
> Regards,
> Robin
>
>
> —
> You are currently subscribed to ntfsd as: xxxxx@secretseal.com
> To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@inin.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: xxxxx@secretseal.com
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntfsd as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntfsd-$subst(‘Recip.MemberIDChar’)@lists.osr.com