Midtown Computer Systems Enterprise

Convenient web based access to our favorite computer related Usenet groups.
MCSE.MS is not affiliated with Microsoft corporation, Cisco corporation, Oracle, CompTIA or any other vendor.
Check our Computer Hardware forum | Cell Phones reviews

Go Back  MCSE > Microsoft software reviews > Windows 2000 review > Windows 2000 File system
This is Interesting: Free Computer Magazines Now Free shipping to

Windows 2000 File system microsoft.public.win2000.file_system

 
 
Thread Tools Display Modes
  #1  
Old 02-27-05, 02:12 AM
Pat [MSFT]
Re: NTFS block allocation policy (how does it work?)
NTFS zeros the file whenever you extend it.  If you just use WriteFile() to
extend the file, the same zero'ing occurs. This is for C2 security
requirements, to prevent folks from extending their files over other peoples
files and taking control of the data.

If you extend a file a little at a time, then for every extension:
Seek to cluster location
Zero out enough space for the addition
Seek back to the start of the write
Write the file data

(so, 2 seeks for the write)

Also, if something else has written to the adjoining cluster in the interim
since the last write, then the file will fragment. This happens all the
time in logging applications.

So, if you pre-allocate the file, you only pay for the zeroing 1 time. This
will prevent any other files from intruding on your nicely sequential
allocation and optimize write speeds. If you only pay the price once, then
the the runtime performance is the same as bypassing the zeroing. The
clusters do not get zero'd until you call SetEndOfFile(). So the order is:

CreateFile
SetFilePointer (size of file you intend to create)
SetEndOfFile (commit the file)
SetFilePointer(beginning)
start writing

No more zeroing will occur unless you overrun the file size allocated.
Also, fragmentation will be minimized. The zeroing happens very, very fast
b/c there is no seeking. A single seek to the start of the file, then
sequential writes so the writes occur at the disk speed.

You can bypass the zeroing of files by using the SetFileValidData(). This
requires an elevated privilege to run (SE_MANAGE_VOLUME_NAME), so depending
on the security context of your application you may have problems; also that
is only available on WinXP and later so if you are targeting Win2k systems
it won't work. Whereas the SetFilePointer can be executed by any user
context that has access to the file. Since (from your description) the
process creates the file as well, this won't be a problem.

Pat


"George M. Garner Jr." <gmgarner@newsgroup.nospam> wrote in message
news:eU9bWe9GFHA.3484@TK2MSFTNGP12.phx.gbl...
> Pat,
>
>
> Could you be more specific as to how to allocate the file. I see the
> function SetFileValidData. But that assumes that you already have
> allocated the file. Elsewhere I have read that one should not use
> SetFilePointer(Ex) because of the added overhead of writing zeros to the
> file. Is there a way to allocate the file without incurring the overhead
> of immediately zeroing out the clusters. I know the pagefile does this
> but I do not see an api that permits it.
>
> Regards,
>
> George.
>



 


Popular forums
A+ (A Plus) Windows 2000 Active directory Exchange 2000 information store
Network+ Windows XP Security Exchange 2000 server administration
MCSE .NET Web services SQL Server
Cisco certification ASP .NET SQL 2000 Programming
Windows 2000 Registry .NET XML Viruses


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:26 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright MCSE braindumps 2003-2006