Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable
fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start
writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data.
So, I would
like to either disable LW or force it to do it dirty work before I start
writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir

Is it possible to disable Lazy Writer?CcSetAdditionalCacheAttributtes can be used to disable write behind for a certain file object. This function must be called on a file object for which caching was previously enabled, or it will cause an access violation. Take care, for this function will not flush the cache, so you may have to explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data. So, I would
like to either disable LW or force it to do it dirty work before I start writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write
to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a
certain file object. This function must be called on a file object for which
caching was previously enabled, or it will cause an access violation. Take
care, for this function will not flush the cache, so you may have to
explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable
fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start
writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data.
So, I would
like to either disable LW or force it to do it dirty work before I start
writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%</mailto:xxxxx></mailto:xxxxx>

Is it possible to disable Lazy Writer?The lazy writter activity is either initated periodically from a timer DPC owned by cache manager, every X seconds, or the cache manager explicitly makes a request for scanning for dirty pages and flush them down to secondary storage.

The most important data structure involved is the shared cache map, a structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are linked toghether, finding those of them ehich has dirty pages and for which write behind functionality is enabled. If such a shared cache map is found, a work item is posted to a worker thread which will carry out the requested opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data structure. The actual IO operation is peformed synchronous by OS, through IoSynchronousPageWrite routine. The IO is considered as beeing paging IO, and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a certain file object. This function must be called on a file object for which caching was previously enabled, or it will cause an access violation. Take care, for this function will not flush the cache, so you may have to explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data. So, I would
like to either disable LW or force it to do it dirty work before I start writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

What is interesting is that in such special case (set file size) there is no
DataSectionObject in the FileObject. Which suggests that there is no cache
created
for that file. Which is reasonable: since file must be zeroed all the way
there is no need to waste virtual memory+fill it with zeroes. But absence of
DataSectionObject and ImageSectionObject pointers in the FileObject suggests
that this FileObject will be completely closed after ZwClose is called on
its handle. That’s why
I was wandering where LW takes FileObject to which write should be
performed.

Regards,

Vladimir

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 9:22 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

The lazy writter activity is either initated periodically from a timer DPC
owned by cache manager, every X seconds, or the cache manager explicitly
makes a request for scanning for dirty pages and flush them down to
secondary storage.

The most important data structure involved is the shared cache map, a
structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for
each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are
linked toghether, finding those of them ehich has dirty pages and for which
write behind functionality is enabled. If such a shared cache map is found,
a work item is posted to a worker thread which will carry out the requested
opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data
structure. The actual IO operation is peformed synchronous by OS, through
IoSynchronousPageWrite routine. The IO is considered as beeing paging IO,
and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----

From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write
to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a
certain file object. This function must be called on a file object for which
caching was previously enabled, or it will cause an access violation. Take
care, for this function will not flush the cache, so you may have to
explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable
fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start
writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data.
So, I would
like to either disable LW or force it to do it dirty work before I start
writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>

Is it possible to disable Lazy Writer?Yes, the file object specified in CcInitializeCacheMap.

Max

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 7:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a certain file object. This function must be called on a file object for which caching was previously enabled, or it will cause an access violation. Take care, for this function will not flush the cache, so you may have to explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data. So, I would
like to either disable LW or force it to do it dirty work before I start writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
To unsubscribe send a blank email to %%email.unsub%%

Is it possible to disable Lazy Writer?Vladimir,

To determine if a file is cached or not, use FileObject->PrivateCacheMap. (Or SharedCacheMap is SectionPointers , for that matter.)As far as I know, current file systems in NT will initailze by themsleves caching for such a request if the SharedCahceMap == NULL && DataSectionObject != NULL && Irp is not IRP_PAGING_IO, as you sugeested. But the caching can be initiated prior to this, are you sure that you have no caching inited on the file ? Can you describe the exact scenario ? You say Open / SetFileInformation / Close, then “start writting on it”. using what ? you reference the handle, reopen the closed file or how ?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 7:42 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

What is interesting is that in such special case (set file size) there is no DataSectionObject in the FileObject. Which suggests that there is no cache created
for that file. Which is reasonable: since file must be zeroed all the way there is no need to waste virtual memory+fill it with zeroes. But absence of DataSectionObject and ImageSectionObject pointers in the FileObject suggests that this FileObject will be completely closed after ZwClose is called on its handle. That’s why
I was wandering where LW takes FileObject to which write should be performed.

Regards,

Vladimir
-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 9:22 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

The lazy writter activity is either initated periodically from a timer DPC owned by cache manager, every X seconds, or the cache manager explicitly makes a request for scanning for dirty pages and flush them down to secondary storage.

The most important data structure involved is the shared cache map, a structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are linked toghether, finding those of them ehich has dirty pages and for which write behind functionality is enabled. If such a shared cache map is found, a work item is posted to a worker thread which will carry out the requested opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data structure. The actual IO operation is peformed synchronous by OS, through IoSynchronousPageWrite routine. The IO is considered as beeing paging IO, and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a certain file object. This function must be called on a file object for which caching was previously enabled, or it will cause an access violation. Take care, for this function will not flush the cache, so you may have to explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data. So, I would
like to either disable LW or force it to do it dirty work before I start writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

Is the filesystem calling CcZeroData in this scenario? Are you writing a filesystem or a filter? Is FASTFAT the underlying filesystem?

-----Original Message-----
From: Vladimir Chtchetkine [mailto:xxxxx@starbase.com]
Sent: Wednesday, June 26, 2002 11:42 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

What is interesting is that in such special case (set file size) there is no DataSectionObject in the FileObject. Which suggests that there is no cache created
for that file. Which is reasonable: since file must be zeroed all the way there is no need to waste virtual memory+fill it with zeroes. But absence of DataSectionObject and ImageSectionObject pointers in the FileObject suggests that this FileObject will be completely closed after ZwClose is called on its handle. That’s why
I was wandering where LW takes FileObject to which write should be performed.

Regards,

Vladimir

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 9:22 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

The lazy writter activity is either initated periodically from a timer DPC owned by cache manager, every X seconds, or the cache manager explicitly makes a request for scanning for dirty pages and flush them down to secondary storage.

The most important data structure involved is the shared cache map, a structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are linked toghether, finding those of them ehich has dirty pages and for which write behind functionality is enabled. If such a shared cache map is found, a work item is posted to a worker thread which will carry out the requested opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data structure. The actual IO operation is peformed synchronous by OS, through IoSynchronousPageWrite routine. The IO is considered as beeing paging IO, and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----

From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a certain file object. This function must be called on a file object for which caching was previously enabled, or it will cause an access violation. Take care, for this function will not flush the cache, so you may have to explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir mailto:xxxxx Chtchetkine
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data. So, I would
like to either disable LW or force it to do it dirty work before I start writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@inin.com
To unsubscribe send a blank email to %%email.unsub%%</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>

When I first create file I use ZwCreate with FILE_NO_INTERMEDIATE_BUFFERING
flag set. Then I get FileObject for the handle then I call
ZwSetInformationFile/EndOfFile
then I check DataSectionObject, mageSectionObject and PrivateCacheMap verify
that they are NULL (I think that SectionObjectPointer is null also). Then I
close file.
When I needed to write to the file I open it again (on the condition that
all handles to the file are closed) and again with
FILE_NO_INTERMEDIATE_BUFFERING flag set and write to it rolling my own
IRP_MJ_WRITE. I guess, my mistake was that I specify IRP_NOCACHE |
IRP_PAGING_IO in write IRP to force data being written directly to the disk.
So, in this way I have broke the coherency between the cache and disk
content. That’s a long story why I’ve chosen this approach (those IRP flags)
but fortunatelly there was a way around. But still it’s unclear for me, how
LW gets to the file in the given scenario.

Regards,

Vladimir

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 10:39 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

Vladimir,

To determine if a file is cached or not, use FileObject->PrivateCacheMap.
(Or SharedCacheMap is SectionPointers , for that matter.)As far as I know,
current file systems in NT will initailze by themsleves caching for such a
request if the SharedCahceMap == NULL && DataSectionObject != NULL && Irp
is not IRP_PAGING_IO, as you sugeested. But the caching can be initiated
prior to this, are you sure that you have no caching inited on the file ?
Can you describe the exact scenario ? You say Open / SetFileInformation /
Close, then “start writting on it”. using what ? you reference the handle,
reopen the closed file or how ?

Dan

----- Original Message -----
From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 7:42 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

What is interesting is that in such special case (set file size) there is no
DataSectionObject in the FileObject. Which suggests that there is no cache
created
for that file. Which is reasonable: since file must be zeroed all the way
there is no need to waste virtual memory+fill it with zeroes. But absence of
DataSectionObject and ImageSectionObject pointers in the FileObject suggests
that this FileObject will be completely closed after ZwClose is called on
its handle. That’s why
I was wandering where LW takes FileObject to which write should be
performed.

Regards,

Vladimir

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 9:22 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

The lazy writter activity is either initated periodically from a timer DPC
owned by cache manager, every X seconds, or the cache manager explicitly
makes a request for scanning for dirty pages and flush them down to
secondary storage.

The most important data structure involved is the shared cache map, a
structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for
each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are
linked toghether, finding those of them ehich has dirty pages and for which
write behind functionality is enabled. If such a shared cache map is found,
a work item is posted to a worker thread which will carry out the requested
opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data
structure. The actual IO operation is peformed synchronous by OS, through
IoSynchronousPageWrite routine. The IO is considered as beeing paging IO,
and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----

From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write
to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a
certain file object. This function must be called on a file object for which
caching was previously enabled, or it will cause an access violation. Take
care, for this function will not flush the cache, so you may have to
explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir mailto:xxxxx Chtchetkine
To: File mailto:xxxxx Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable
fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start
writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data.
So, I would
like to either disable LW or force it to do it dirty work before I start
writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>

I think, CcZeroData is what FS does in this case.
I’m writing a filter driver.
The underlying FS is NTFS.

Regards,

Vladimir

-----Original Message-----
From: Fuller, Rob [mailto:xxxxx@inin.com]
Sent: Wednesday, June 26, 2002 11:16 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

Is the filesystem calling CcZeroData in this scenario? Are you writing a
filesystem or a filter? Is FASTFAT the underlying filesystem?

-----Original Message-----
From: Vladimir Chtchetkine [mailto:xxxxx@starbase.com]
Sent: Wednesday, June 26, 2002 11:42 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

What is interesting is that in such special case (set file size) there is no
DataSectionObject in the FileObject. Which suggests that there is no cache
created
for that file. Which is reasonable: since file must be zeroed all the way
there is no need to waste virtual memory+fill it with zeroes. But absence of
DataSectionObject and ImageSectionObject pointers in the FileObject suggests
that this FileObject will be completely closed after ZwClose is called on
its handle. That’s why
I was wandering where LW takes FileObject to which write should be
performed.

Regards,

Vladimir

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 9:22 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

The lazy writter activity is either initated periodically from a timer DPC
owned by cache manager, every X seconds, or the cache manager explicitly
makes a request for scanning for dirty pages and flush them down to
secondary storage.

The most important data structure involved is the shared cache map, a
structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for
each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are
linked toghether, finding those of them ehich has dirty pages and for which
write behind functionality is enabled. If such a shared cache map is found,
a work item is posted to a worker thread which will carry out the requested
opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data
structure. The actual IO operation is peformed synchronous by OS, through
IoSynchronousPageWrite routine. The IO is considered as beeing paging IO,
and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----

From: Vladimir Chtchetkine mailto:xxxxx
To: File Systems Developers mailto:xxxxx
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write
to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a
certain file object. This function must be called on a file object for which
caching was previously enabled, or it will cause an access violation. Take
care, for this function will not flush the cache, so you may have to
explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir mailto:xxxxx Chtchetkine
To: File mailto:xxxxx Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable
fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start
writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data.
So, I would
like to either disable LW or force it to do it dirty work before I start
writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@inin.com
To unsubscribe send a blank email to %%email.unsub%%


You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%</mailto:xxxxx></mailto:xxxxx></mailto:xxxxx></mailto:xxxxx>

Is it possible to disable Lazy Writer?Vladimir, the only way Cc gets the file object for lazy writes is from the SharedCacheMap. No other way arround.

Regards, Dan
----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 9:27 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

When I first create file I use ZwCreate with FILE_NO_INTERMEDIATE_BUFFERING flag set. Then I get FileObject for the handle then I call ZwSetInformationFile/EndOfFile
then I check DataSectionObject, mageSectionObject and PrivateCacheMap verify that they are NULL (I think that SectionObjectPointer is null also). Then I close file.
When I needed to write to the file I open it again (on the condition that all handles to the file are closed) and again with FILE_NO_INTERMEDIATE_BUFFERING flag set and write to it rolling my own IRP_MJ_WRITE. I guess, my mistake was that I specify IRP_NOCACHE | IRP_PAGING_IO in write IRP to force data being written directly to the disk. So, in this way I have broke the coherency between the cache and disk content. That’s a long story why I’ve chosen this approach (those IRP flags) but fortunatelly there was a way around. But still it’s unclear for me, how LW gets to the file in the given scenario.

Regards,

Vladimir
-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 10:39 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

Vladimir,

To determine if a file is cached or not, use FileObject->PrivateCacheMap. (Or SharedCacheMap is SectionPointers , for that matter.)As far as I know, current file systems in NT will initailze by themsleves caching for such a request if the SharedCahceMap == NULL && DataSectionObject != NULL && Irp is not IRP_PAGING_IO, as you sugeested. But the caching can be initiated prior to this, are you sure that you have no caching inited on the file ? Can you describe the exact scenario ? You say Open / SetFileInformation / Close, then “start writting on it”. using what ? you reference the handle, reopen the closed file or how ?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 7:42 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

What is interesting is that in such special case (set file size) there is no DataSectionObject in the FileObject. Which suggests that there is no cache created
for that file. Which is reasonable: since file must be zeroed all the way there is no need to waste virtual memory+fill it with zeroes. But absence of DataSectionObject and ImageSectionObject pointers in the FileObject suggests that this FileObject will be completely closed after ZwClose is called on its handle. That’s why
I was wandering where LW takes FileObject to which write should be performed.

Regards,

Vladimir
-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 9:22 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

The lazy writter activity is either initated periodically from a timer DPC owned by cache manager, every X seconds, or the cache manager explicitly makes a request for scanning for dirty pages and flush them down to secondary storage.

The most important data structure involved is the shared cache map, a structure which contains all information required to carry out
Cc operations, and which is maintained internally by the Cache manager, for each file stream for which caching has been initiated.

The lazy writer mechanism will iterate through shared cache maps, which are linked toghether, finding those of them ehich has dirty pages and for which write behind functionality is enabled. If such a shared cache map is found, a work item is posted to a worker thread which will carry out the requested opperation by flushing the specified shared cache map.

The file object is determined by looking into shared cache map data structure. The actual IO operation is peformed synchronous by OS, through IoSynchronousPageWrite routine. The IO is considered as beeing paging IO, and the IRP used has IRP_PAGING_IO
flag set.

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 6:10 PM
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

How do I end in this situation? I’m screwed! :slight_smile:

Can somebody also explain me the mechanizm that is used by the LW to write to the file? I mean, how does it get FileObject?

-----Original Message-----
From: Dan Partelly [mailto:xxxxx@rdsor.ro]
Sent: Wednesday, June 26, 2002 7:40 AM
To: File Systems Developers
Subject: [ntfsd] Re: Is it possible to disable Lazy Writer?

CcSetAdditionalCacheAttributtes can be used to disable write behind for a certain file object. This function must be called on a file object for which caching was previously enabled, or it will cause an access violation. Take care, for this function will not flush the cache, so you may have to explicitly flush it.

But one question, how do you end in this situation?

Dan

----- Original Message -----
From: Vladimir Chtchetkine
To: File Systems Developers
Sent: Wednesday, June 26, 2002 4:25 AM
Subject: [ntfsd] Is it possible to disable Lazy Writer?

… or somehow force it to flush dirty blocks to the disk in a predictable fasion?
What I’m doing is I’m creating a file (create+setsize+close) and then start writing
to it. And sometimes Lazy Writer “wakes up” and starts writing over my data. So, I would
like to either disable LW or force it to do it dirty work before I start writing to my file.
Is it possible (for all variety of OSes NT+ and NTFS/FAT)?

TIA,

Vladimir


You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@Starbase.com
To unsubscribe send a blank email to %%email.unsub%%

You are currently subscribed to ntfsd as: xxxxx@rdsor.ro
To unsubscribe send a blank email to %%email.unsub%%