[Bug 11588] better handling for --preallocate with --sparse

samba-bugs at samba.org samba-bugs at samba.org
Mon Oct 10 14:38:24 UTC 2016


--- Comment #24 from Theodore Ts'o <tytso at mit.edu> ---
So a simple workaround would be to use fallocate with KEEP_SIZE at first, then
use punch whole, write the blocks, etc., and then use either truncate to set
i_size, or seek to the desired size minus one and write a single byte.  
Seeking to the desired size minus one is more portable, but if you want to
avoid allocating an extra 4k block, you could try using truncate, and if that
doesn't set i_size (it's not guaranteed by POSIX, but I believe all Linux file
systems will set i_size), seeking to size-1 and writing a single zero byte is
guaranteed to work.

That being said, I agree that ext4 should allow punch hole to work beyond
i_size, if there are blocks allocated using fallocate(2).   We'll fix that for
the future, but for now, the workaround suggested above is probably the
simplest way to work around the issue in a way that's compatible with both the
current and future behavior.

You are receiving this mail because:
You are the QA Contact for the bug.

More information about the rsync mailing list