<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx</link><description>It's a case of filesystem-colored glasses.</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10383104</link><pubDate>Tue, 08 Jan 2013 09:06:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10383104</guid><dc:creator>Matt</dc:creator><description>&lt;p&gt;@f0dder: &amp;quot;You didn&amp;#39;t read my entire post? Let me quote the relevant part: &amp;quot;Sparse Files were obviously counterproductive to the goal of avoiding fragmentation :)&amp;quot;&lt;/p&gt;
&lt;p&gt;Well sparse files are the only way to achieve what you want - and the fragmentation of sparse files across disk is a fairly small problem - ranges are automatically collected and nearly full sparse files are automatically converted to non-sparse files by background tasks in Windows. Sparse files are ordered collections of &amp;quot;ranges&amp;quot; of blocks where blocks outside of those ranges are zero. All other files have a &amp;quot;valid data&amp;quot; pointer where the data before that value holds non-garbage data on disk.&lt;/p&gt;
&lt;p&gt;Consequently if you want to write the last 4KB of a 1GB file without writing the other blocks to disk you have to either use sparse files, or suffer the large write of zeroes back to disk.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10383104" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10383045</link><pubDate>Tue, 08 Jan 2013 03:04:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10383045</guid><dc:creator>Roman</dc:creator><description>&lt;p&gt;&amp;gt; But the point of discussion is &amp;quot;If I yank a thumb drive before delayed writes are complete, why doesn&amp;#39;t journaling fix the problem?&amp;quot;&lt;/p&gt;
&lt;p&gt;Oh, I see. This makes sense. May I humbly suggest that the title of this entry is somewhat misleading then? It _sounds_ like you intend to discuss why you can&amp;#39;t just yank an NTFS formatted USB drive: note the part where the title seems to assert that &amp;quot;you have to be careful when using [NTFS] with a USB thumb drive&amp;quot; - but you go on to clarify that this only applies if delayed writes are permitted.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10383045" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382982</link><pubDate>Mon, 07 Jan 2013 21:42:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382982</guid><dc:creator>Nawak</dc:creator><description>&lt;p&gt;&amp;gt;&amp;gt; Ultimately, on graceful close, the reserved allocation will be truncated to the current file length, even if there was a reservation.&lt;/p&gt;
&lt;p&gt;&amp;gt; [Um, the discussion is about what happens when there is not a graceful close&lt;/p&gt;
&lt;p&gt;@Raymond: Indeed, but alegr1&amp;#39;s remark can apply to the fsck done during the drive remount. Since the last operation didn&amp;#39;t finish, the allocated space could be reclaimed. Also, reading back I think that alegr1&amp;#39;s remark applied to Matt&amp;#39;s second comment about some (apparently small) files&amp;#39; allocation staying very large after a browser crash. In that case, the OS would do the graceful close (from the FS POV) on process exit, wouldn&amp;#39;t it?&lt;/p&gt;
&lt;p&gt;@Matt:&lt;/p&gt;
&lt;p&gt;1) Reserve being part of quota: well, ok, but could as well be! I think including would still be fair (since reserved space isn&amp;#39;t available to other users), so another decision I&amp;#39;ll have to contest! ;-). Note that I don&amp;#39;t advocate having a &amp;quot;reserve&amp;quot; marginally different from the &amp;quot;size&amp;quot; after a close (or remount). This would only be a hint for opened files.&lt;/p&gt;
&lt;p&gt;2) Implementation detail? Let&amp;#39;s call it optional functionality! If the reservation promise isn&amp;#39;t kept then it&amp;#39;s only a performance degradation for the offending FS. So I think every FS could return OK without doing anything. Reserve space qualify as a hint and isn&amp;#39;t therefore contractual so no API would be broken in your case. If you want to talk about implementation details, being able to fill up a file with zeroes at no cost when resizing it, *that* is an implementation detail! And implementing this could be way harder for another FS than answering OK to a hint it didn&amp;#39;t take.&lt;/p&gt;
&lt;p&gt;3) You are right. So that&amp;#39;s always A-&amp;gt;B-&amp;gt;C with A being optional. So if you implement a service that allocates and set the reserve, there&amp;#39;s no extra cost at all, since you still have to at least update the commit at each write (commit+filesize in my solution, but maybe the informations aren&amp;#39;t in the same physical places?)&lt;/p&gt;
&lt;p&gt;4) I already acknowledged that. The benefit was that the corruption was more visible.&lt;/p&gt;
&lt;p&gt;@Matt and others: Yes, none of what I propose would magically uncorrupt a file from a drive that has been removed before the end of the operation. The initial point was to make it more visible that something went wrong, even if I admit that not everyone knows what size a particular file should be... Wait! No, the start of all this was my surprise of seeing Raymond say that having the final size at the end of the auto-repair was the correct behaviour. I now know that it is indeed correct considering what CopyFile asked. Hilarity ensued when I asked for another service! ;-)&lt;/p&gt;
&lt;p&gt;@f0dder:&lt;/p&gt;
&lt;p&gt;- I agree that when an FS/API is already designed, coded and tested, that kind of service would have to gain a lot of points to justify the work. Still doesn&amp;#39;t make the requested behaviour &amp;quot;incorrect&amp;quot; or wrong to examine.&lt;/p&gt;
&lt;p&gt;- for your second &amp;quot;2)&amp;quot;: there wouldn&amp;#39;t be more metadata updates than there already is. As Matt noted, you still have to change the commit size at each write. If my uninformed opinion is correct, you could update the size in the same write.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382982" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382918</link><pubDate>Mon, 07 Jan 2013 17:59:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382918</guid><dc:creator>f0dder</dc:creator><description>&lt;p&gt;@Matt: &amp;quot;Yes. Sparse files.&amp;quot;&lt;/p&gt;
&lt;p&gt;You didn&amp;#39;t read my entire post? Let me quote the relevant part: &amp;quot;Sparse Files were obviously counterproductive to the goal of avoiding fragmentation :)&amp;quot;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382918" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382899</link><pubDate>Mon, 07 Jan 2013 17:18:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382899</guid><dc:creator>Roman</dc:creator><description>&lt;p&gt;Raymond, I think the confusion arose because your first sentence says you need to do X to enable formatting as NTFS, while later on you talk about the write-behind cache. Frankly, I&amp;#39;m still confused, even after your clarification :)&lt;/p&gt;
&lt;p&gt;On my Win7, I was able to format a USB hard drive as NTFS without making any promises or agreeing to any warning dialogs. I assume the write caching is disabled, based on what you say about that being the default. Therefore, I should be safe to yank it and expect the just-copied *data* to survive too (not just filesystem metadata), right?&lt;/p&gt;
&lt;div class="post"&gt;[&lt;em&gt;If the rules changed in Windows 7, nobody told me about it. (Not that I expected them to.) But the point of discussion is &amp;quot;If I yank a thumb drive before delayed writes are complete, why doesn&amp;#39;t journaling fix the problem?&amp;quot; The rules around delayed writes may have changed, but that doesn&amp;#39;t affect the discussion. -Raymond&lt;/em&gt;]&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382899" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382858</link><pubDate>Mon, 07 Jan 2013 15:56:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382858</guid><dc:creator>JamesJohnston</dc:creator><description>&lt;p&gt;Raymond: &amp;quot;Write-behind caching is disabled by default on removable drives. You get into this mess only if you override the default.&amp;quot;&lt;/p&gt;
&lt;p&gt;xpclient: &amp;quot;I checked that same drive on XP/Vista/7/8 and XP blocks NTFS if it&amp;#39;s set for Quick Removal and allows NTFS if set for Performance but Vista and later OSes allow formatting it as NTFS irrespective of whether it&amp;#39;s set for Quick Removal or Performance.&amp;quot;&lt;/p&gt;
&lt;p&gt;There seems to be an underlying story here which I&amp;#39;ve somehow missed. &amp;nbsp;Did Windows Vista introduce support for NTFS and Quick Removal? &amp;nbsp;Did prior versions of Windows not support that configuration?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382858" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382766</link><pubDate>Mon, 07 Jan 2013 08:52:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382766</guid><dc:creator>Matt</dc:creator><description>&lt;p&gt;@fodder: &amp;quot;is there a way to pre-allocating a file size and then writing to an arbitrary location in it, without (NTFS) having to zerofill from the former last-valid location to the current random offset?&amp;quot;&lt;/p&gt;
&lt;p&gt;Yes. Sparse files.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382766" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382726</link><pubDate>Mon, 07 Jan 2013 01:52:40 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382726</guid><dc:creator>f0dder</dc:creator><description>&lt;p&gt;I was thinking that having an in-memory &amp;quot;eventual filesize hint&amp;quot; for NTFS could have been a nice thing - something that wouldn&amp;#39;t be used in the on-disk structures, simply a best-effort thing for the driver to take into consideration while the operation is still running. If the process crashes, file size would be trimmed to the (journalled as normally) FS metadata updated by the last write.&lt;/p&gt;
&lt;p&gt;But after pondering a bit:&lt;/p&gt;
&lt;p&gt;1) starts at -1000, is probably hard to do right, and doesn&amp;#39;t bring much to the table.&lt;/p&gt;
&lt;p&gt;2) doesn&amp;#39;t solve the &amp;quot;file /contents/ might be corrupt&amp;quot; problem.&lt;/p&gt;
&lt;p&gt;2) while (likely) reducing fragmentation, you still get &amp;quot;a zillion&amp;quot; metadata updates, so the copy will be slower than really pre-allocating the output file size.&lt;/p&gt;
&lt;p&gt;Bonus question: is there a way to pre-allocating a file size and then writing to an arbitrary location in it, without (NTFS) having to zerofill from the former last-valid location to the current random offset? Last time I played around with that was back on XP, and SetFileValidData() seemed a bit dangerous and privilege-hungry for general purpose. Sparse Files were obviously counterproductive to the goal of avoiding fragmentation :)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382726" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382611</link><pubDate>Sat, 05 Jan 2013 20:34:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382611</guid><dc:creator>@xpclient</dc:creator><description>&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;Do you notice a tone of complaint in my comment?&amp;quot;. &lt;/p&gt;
&lt;p&gt;Yes. Almost everything you say on Rayomond&amp;#39;s blog is phrased in a critical way. Rather than &amp;quot;Bug or feature?&amp;quot; you could have phrased it less agressively, e.g. &amp;quot;why is that?&amp;quot; or &amp;quot;am I missing something?&amp;quot;, rather than just assuming that things not working as you expect is because the feature is broken.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382611" width="1" height="1"&gt;</description></item><item><title>re: If NTFS is a robust journaling file system, why do you have to be careful when using it with a USB thumb drive?</title><link>http://blogs.msdn.com/b/oldnewthing/archive/2013/01/01/10381556.aspx#10382608</link><pubDate>Sat, 05 Jan 2013 19:57:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10382608</guid><dc:creator>alegr1</dc:creator><description>&lt;p&gt;FAT32 (artificial) volume size limit is 32 GB. Over than that, exFAT should be recommended. Actually, it makes sense to use exFAT for smaller drives, unless you plan to use the drive at systems where exFAT is not inbox, or not installed as update.&lt;/p&gt;
&lt;p&gt;&amp;gt;how can a user be sure the CopyFile succeeded?&lt;/p&gt;
&lt;p&gt;1. Make sure CopyFile issues FlushFileBuffers for removeable volume.&lt;/p&gt;
&lt;p&gt;2. For a removable volume, limit amount of write-back to 1-2 seconds worth of data, and have a short write-back idle delay. This is for applications that don&amp;#39;t use CopyFile.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10382608" width="1" height="1"&gt;</description></item></channel></rss>