Skip to contentSkip to conversation

VFAT truncate performance

DISCUSSION Bodo Eggert 1 participant 1 message Sep 5, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 8 lines · Mattias Rönnblom

extending files by ftruncate(2) runs very slow on VFAT file systems. On my USB harddisk w/ VFAT, it takes 14 seconds to extend an empty file to 1 GB. On a memory stick, it takes well over 4 minutes.

My question is: is this problem on the conceptual level (ie there is no way of extending files on FAT that doesn't involve many disk operations) or is the current Linux fs driver suboptimal in this respect?

Linux needs to zero files it truncate-extends because of security guarantees.

You could temporarily ignore the truncate after create if it's followed by writing the file (defer untill first non-write), but it will be a BAD hack. It might work.

Default: open(O_WRITE|O_CREAT|O_TRUNC) -> do it, goto State 1

         otherwise -> just do it

State 1: ftruncate -> remember offset instead of executing ftruncate,
goto State 2
otherwise -> goto Default

State 2: write -> do it, stay in State 2 unless file size increases

                      beyond fake size, then goto Default
         stat      -> return fake size
         otherwise -> really do ftruncate, goto Default

It might cause some operations to be slow you'd expect to be fast, and I'm not sure how it has to deal with concurrent access.

Signature · 4 lines
Ich danke GMX dafür, die Verwendung meiner Adressen mittels per SPF
verbreiteten Lügen zu sabotieren.

http://david.woodhou.se/why-not-spf.html