Re: FAT32 or NTFS?
From: cquirke (MVP Win9x) (cquirkenews_at_nospam.mvps.org)
Date: 05/13/04
- Next message: Anthony Procissi [MSFT]: "Re: Microsoft Voice Recognition"
- Previous message: anon: "Vertical scroll bar problem"
- In reply to: Alexander Grigoriev: "Re: FAT32 or NTFS?"
- Next in thread: Alexander Grigoriev: "Re: FAT32 or NTFS?"
- Reply: Alexander Grigoriev: "Re: FAT32 or NTFS?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 13 May 2004 21:55:48 +0200
On Wed, 12 May 2004 04:41:52 GMT, "Alexander Grigoriev"
>Consider expanding a file. Before any data can be written to a file, new
>clusters has to be allocated, free clusters bitmap modified, directory entry
>modified to reflect new extent allocated (although the file length won't be
>written immediately to the directory entry). Only after that you will be
>able to write new data to a file.
>You're more likely to have a file with garbage data, than to get valid data
>truncated. I'd say the latter case is close to impossible.
Just thinking of prior experience with FATxx where files-in-progress
are so often recoverable as lost cluster chains (where dir entry has
either been deleted or not yet created) and length mis-matches (where
cluster chaining implies a length at odds with dir entry).
As I understand it, the dir entry is created when the file is opened,
but only when the file is closed, is the length set to correct value.
In between these events, data is indeed written to the cluster chain,
and FAT updates happen at this time.
Presumably a similar sequence of events occurs with NTFS; dir entry
created if it does not yet exist, data is written to the current data
run in the data stream, free cluster bitmap hopefully updated; then
when done, dir entry length value is updated.
I take it that NTFS's transaction logging starts when the file is
opened and ends (and commits) when the file is closed.
Good programming practice may prefer to hold "real" files open for as
short a time as possible. The longer the file is held open, the more
likely it is to get messed up, and it also acts as a sand-bar or
skip-file for defrag, backup, etc.
But as opening and closing files are slow, hoggy tasks, you want to do
multiple small updates as a single operation rather than have to open
and close the file each the time. The solution may be to hold a
temporary file open just for the bits you are working on, and then
commit these into the "real" file when saved.
In between opening the file and saving it, the "real" file may be left
closed, though some checks must be done to resolve situations where
something else has modified the file.
>From what I see, it's mainly log files and System Restore stuff that
commonly gets broken on bad exits from XP. Presumably these file are
held open, but (in the case of log files) flushed frequently?
>If you want your data consistent, you have to implement your own transaction
>system for your application files. You can use FILE_FLAG_NO_BUFFERING, or,
>for special cases, FILE_FLAG_WRITE_THROUGH.
It's been a long while since I worked at that level ;-)
>------------ ----- ---- --- -- - - - -
Our senses are our UI to reality
>------------ ----- ---- --- -- - - - -
- Next message: Anthony Procissi [MSFT]: "Re: Microsoft Voice Recognition"
- Previous message: anon: "Vertical scroll bar problem"
- In reply to: Alexander Grigoriev: "Re: FAT32 or NTFS?"
- Next in thread: Alexander Grigoriev: "Re: FAT32 or NTFS?"
- Reply: Alexander Grigoriev: "Re: FAT32 or NTFS?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|