On Sat, 2008-02-23 at 16:43 -0700, Rob Bosch wrote: > Matt's patch worked great for cygwin (preallocate.diff). The same approach > is not working well under CentOS since it writes out all those 0's for the > files using the posix_fallocate function. It seems to me that under Linux > the ftruncate function may be better suited for the implementation?
IIUC, ftruncate doesn't preallocate the file; it only changes the logical size. I did a little test on my computer (using reiserfs) of copying a 146 MB file to a new file, a posix_fallocated file, and an ftruncated file. The copies took 6.1 s, 4.9 s, and 6.3 s, respectively; ftruncate was no better than calling nothing at all. > I tested using ftruncate in lieu of posix_fallocate and it appears to create > the files almost instantaneously on both XFS and Ext3 (the only file system > formats I've tested). Filefrag reports just a single extent on both file > systems (file created was 77GB). Oddly, filefrag reports a perfect > fragmentation of 172 with the file I created on Ext2 but it only had 1 > extent. I'm not sure I fully understand the "perfect" fragmentation number. For a meaningful test, you should actually write 77GB of data into a new file and an ftruncated file and see if there's any difference in the resulting fragmentation. In your patch, you should use fallocate in place of ftruncate. If your glibc is like mine and doesn't provide direct access to fallocate, you'll have to use syscall and __NR_fallocate . Matt -- To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
