LWN: Comments on "Allocating uninitialized file blocks" https://lwn.net/Articles/492959/ This is a special feed containing comments posted to the individual LWN article titled "Allocating uninitialized file blocks". en-us Wed, 15 Oct 2025 09:01:25 +0000 Wed, 15 Oct 2025 09:01:25 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Allocating uninitialized file blocks https://lwn.net/Articles/495389/ https://lwn.net/Articles/495389/ butlerm It sounds like EXT4 and any other modern filesystems with this problem need a more robust form of <a href="http://xfs.org/docs/xfsdocs-xml-dev/XFS_User_Guide/tmp/en-US/html/ch02s07.html">unwritten extent</a> tracking similar to that used by XFS. Tue, 01 May 2012 05:50:18 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493854/ https://lwn.net/Articles/493854/ szaka <div class="FormattedComment"> The flag (with a better name) could be helpful for filesystems which can't fully support uninitialized allocated blocks efficiently. We are supporting several such interoperable filesystems (NTFS, exFAT, FAT) where changing the specification is not possible.<br> <p> There is real user need despite explaining potential security consequences. Typical usage scenarios are using a large file as a container for an application which tracks free/used blocks itself. Windows supports this feature by SetFileValidData() if extra privilege is granted.<br> <p> The performance gain can be huge on embedded using low-end storage and SoC. In one of our cases it took 5 days vs 12 minutes to fully setup a large file for use.<br> <p> </div> Mon, 23 Apr 2012 01:21:10 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493622/ https://lwn.net/Articles/493622/ dlang <div class="FormattedComment"> the fact that it can't be queued is a major performance hit.<br> <p> The SSD does keep a pool of unused pages for new allocations. What trim does is it lets the SSD know that you no longer care about the data on that block, and so it can add the block back to that pool.<br> <p> If the SSD runs out of this pool, writing slows drastically as it must first erase a block before it can write anything. If you are expecting to do a LOT of writing to a SSD, you may want to make sure that you partition it to something less than the advertised size so that that extra space will remain in the pool (this works as long as that extra space has never been written to, or is explicitly relased via a TRIM command)<br> </div> Fri, 20 Apr 2012 21:51:49 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493621/ https://lwn.net/Articles/493621/ Cyberax <div class="FormattedComment"> That depends. TRIM-ing 100Gb of data on my Intel SSD-based RAID takes little more than 2-3 seconds, it's way faster than writing zeros directly and more flash-friendly.<br> <p> However, TRIM command can't be queued. So it probably makes no sense to use it for large allocations and/or to keep a pool of recently-trimmed pages for immediate small allocations.<br> </div> Fri, 20 Apr 2012 21:45:49 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493619/ https://lwn.net/Articles/493619/ dlang <div class="FormattedComment"> unfortunately trim is not a fast command for many drives<br> </div> Fri, 20 Apr 2012 21:39:31 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493616/ https://lwn.net/Articles/493616/ Cyberax <div class="FormattedComment"> <font class="QuotedText">&gt;But then you are depending on your hardware to have correct functionality. </font><br> <p> Its presence is indicated by the 'Deterministic read data after TRIM' capability (you can check it using "hdparm -I"). So it's not like you need to blindly trust your SDD.<br> <p> <font class="QuotedText">&gt;Anyways, I believe TRIM just tells them that the blocks are no longer being used. It's not a order to zero out the blocks. </font><br> <p> With deterministic zeros one can also use it as a way to quickly erase blocks.<br> <p> Besides, overwriting something on SDD in most cases would NOT actually overwrite it in the real hardware flash due to load balancing and remapping.<br> </div> Fri, 20 Apr 2012 21:33:19 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493598/ https://lwn.net/Articles/493598/ dlang <div class="FormattedComment"> trim says that the blocks are not being used. If there is an attempt to read from blocks that are not being used, the SSD returns all 0's (it doesn't actually read the block, because after the trim, that block doesn't actually exist on the flash media anymore)<br> <p> If you were to take apart the drive and bypass the controller to read the flash chips directly, you would have a chance at recovering the data.<br> </div> Fri, 20 Apr 2012 20:17:42 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493593/ https://lwn.net/Articles/493593/ drag <div class="FormattedComment"> But then you are depending on your hardware to have correct functionality. <br> Which is a very very unsafe assumption.<br> <p> Anyways, I believe TRIM just tells them that the blocks are no longer being used. It's not a order to zero out the blocks. Without trim the SSD doesn't know if the file system still expects them to be used or not.<br> </div> Fri, 20 Apr 2012 19:31:26 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493464/ https://lwn.net/Articles/493464/ Cyberax <div class="FormattedComment"> Modern SSDs have TRIM which 'zeroes' the TRIM-ed blocks automatically.<br> </div> Fri, 20 Apr 2012 07:32:08 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493453/ https://lwn.net/Articles/493453/ jzbiciak <P>Well, this new<TT> fallocate() </TT>feature is explicit. It's not like we're suddenly changing the semantics of holes in files. It's really about policy vs. mechanism. We need to ask if this is a useful mechanism, and if so, can user space use it safely if it adopts appropriate polices?</P> <P>The definition of "appropriate policy" depends entirely on the usage scenario and security requirements of the system and application. A DVR disk that has nothing but video files on it won't leak anything interesting, so this<TT> fallocate() </TT>mode may be perfectly suited to it, for example, assuming a bittorent-style scattered download.</P> <P>All that said, this new mode does need to prove its usefulness. If the performance issue is unique to ext4, then it's probably better to just fix ext4.</P> Fri, 20 Apr 2012 05:41:07 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493403/ https://lwn.net/Articles/493403/ Fowl <p>That would be the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa365544">SetFileValidData</a> function, which "is useful in very limited scenarios. "</p> <p>To use it requires the SE_MANAGE_VOLUME_NAME privilege (ie. raw disk access).<blockquote>"Applications should call SetFileValidData only on files that restrict access to those entities that have SE_MANAGE_VOLUME_NAME access. The application must ensure that the unwritten ranges of the file are never exposed, or security issues can result as follows."</blockquote></p> <p><small>[Something about giving just enough rope to hang yourself / trusting programmers to know what they're doing.]</small></p> Thu, 19 Apr 2012 21:22:55 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493396/ https://lwn.net/Articles/493396/ intgr <div class="FormattedComment"> <font class="QuotedText">&gt; that used the equivilant option in Windows</font><br> <p> Are you saying that there's an equivalent to the new proposed FALLOC_FL_NO_HIDE_STALE flag too? I'd be surprised. Can you link to the discussion?<br> <p> (Maybe you're just confused. I'm sure there is a fallocate() equivalent feature in Windows -- but fallocate() doesn't leak any foreign file data, without this new proposed flag)<br> <p> </div> Thu, 19 Apr 2012 20:51:26 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493383/ https://lwn.net/Articles/493383/ nybble41 <div class="FormattedComment"> The problem is that while a root process or one with raw I/O capabilities can see those blocks itself, it wouldn't usually write them out to a file which other users could read. However, if a root process allocates space for a file readable by non-root processes, and that space remains uninitialized, the other processes will have access to the former contents of those blocks.<br> </div> Thu, 19 Apr 2012 19:28:25 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493372/ https://lwn.net/Articles/493372/ slashdot <div class="FormattedComment"> If it's an SSD or a "smart" RAID array, use TRIM instead (if it's not supported, throw the stupid thing away and get a decent one).<br> <p> </div> Thu, 19 Apr 2012 18:40:38 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493337/ https://lwn.net/Articles/493337/ epa <div class="FormattedComment"> Yeah, it's work, my point is that since most systems have idle periods and busy periods, it makes sense to do some of this work during idle periods so that it doesn't have to be done when the system (and the disk) is busy.<br> </div> Thu, 19 Apr 2012 17:01:40 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493328/ https://lwn.net/Articles/493328/ joey <div class="FormattedComment"> I was just reading yesterday about a torrent program that used the equivilant option in Windows. So every partially downloaded torrent file exposes other "deleted" data. Ugh.<br> </div> Thu, 19 Apr 2012 15:44:24 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493318/ https://lwn.net/Articles/493318/ jzbiciak <div class="FormattedComment"> How is this at all different than just opening up the device node associated with the partition? If you're root, what's stopping you?<br> <p> As Ted Ts'o suggested, if a process has the capability to do raw I/O, why not let it see raw disk blocks occasionally? You've already given it permission to do low level I/O in spite of a filesystem, so what's the harm in letting it stale blocks within a filesystem?<br> </div> Thu, 19 Apr 2012 15:35:15 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493317/ https://lwn.net/Articles/493317/ sandeen <div class="FormattedComment"> As the thread wore on, numbers were posted which show XFS has no serious performance degradation under the same workload. At this point, blowing a security hole in ext4 and promoting the flag to the VFS level seems incredibly premature.<br> <p> I'd look into just what is making ext4 slow here but so far I can't reproduce a slowdown anything like what the patch submitter has seen...<br> <p> -Eric<br> </div> Thu, 19 Apr 2012 15:21:30 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493310/ https://lwn.net/Articles/493310/ vonbrand <p>The problem is that zeroing blocks is work, and besides SSDs (and RAIDs) shouldn't be written except when really needed.</p> <p>Why not just split the range fallocated and just rewrite the affected blocks, not the whole range?</p> Thu, 19 Apr 2012 14:56:37 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493253/ https://lwn.net/Articles/493253/ epa <div class="FormattedComment"> Maybe the filesystem needs a low-priority scrubber process that zeroes out unallocated blocks, and marks them as zeroed. They can then be allocated quickly later.<br> <p> If enough already-zeroed blocks aren't available (or they aren't contiguous enough) then you still have to go to the work of initializing blocks when fallocate() is called. But if those blocks are never used and the file is then shrunk or deleted, the zeroed blocks are still available for next time so the work isn't entirely wasted.<br> </div> Thu, 19 Apr 2012 09:48:11 +0000 Allocating uninitialized file blocks https://lwn.net/Articles/493230/ https://lwn.net/Articles/493230/ slashdot <div class="FormattedComment"> This is something that should never be done unless the benefit is truly huge it is mathematically provable that there's no other way to achieve it.<br> <p> Even if an application has root privileges, a bug in it (even just not zeroing out padding in a structure) may result in an accidental leak of data from a totally unrelated file to a remote client.<br> <p> The only sensible variant is zeroing blocks from deleted files in the background and only using those scrubbed blocks.<br> <p> </div> Thu, 19 Apr 2012 07:15:14 +0000