Thread (20 messages) 20 messages, 6 authors, 2011-05-24

Re: [PATCH] ext4: use vmtruncate() instead of ext4_truncate() in ext4_setattr()

From: Eric Sandeen <hidden>
Date: 2011-05-18 14:05:31

On 5/18/11 1:13 AM, Dave Chinner wrote:
It's entirely up to the filesystem how it treats blocks beyond EOF
during truncation. XFS frees them on truncate down, because it is
much safer to just truncate away everything beyond the new EOF than
to leave written extents beyond EOF as potential landmines.

Indeed, that's why calling vmtruncate() as a bad fix. If you have:


	       NUUUUUUUUUUWWWWWWWWWOUUUUUUUUU
       ....----+----------+--------+--------+
               A	  B        C        D

Where	A = new EOF (N)
	A->B = unwritten (U)
	B->C = written (W)
	C = old EOF (O)
	C->D = unwritten (U)

Then just calling vmtruncate() will leave the blocks in the range
B->C as written blocks. Hence then doing an extending truncate back
out to D will expose stale data rather than zeros in the range
B->C....
Hm, running recent xfstests which includes fsx-with-fallocate should probably
eventually catch that then.

-Eric
 
Cheers,

Dave.
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help