+#ifdef SUPPORT_PREALLOCATION
+ if (preallocate_files && fd != -1 && total_size > 0 && (!inplace_sizing || total_size > size_r)) {
+ /* Try to preallocate enough space for file's eventual length. Can
+ * reduce fragmentation on filesystems like ext4, xfs, and NTFS. */
+ if ((preallocated_len = do_fallocate(fd, 0, total_size)) < 0)
+ rsyserr(FWARNING, errno, "do_fallocate %s", full_fname(fname));
+ } else
+#endif
+ if (inplace_sizing) {
+#ifdef HAVE_FTRUNCATE
+ /* The most compatible way to create a sparse file is to start with no length. */
+ if (sparse_files > 0 && whole_file && fd >= 0 && do_ftruncate(fd, 0) == 0)
+ preallocated_len = 0;
+ else
+#endif
+ preallocated_len = size_r;
+ } else
+ preallocated_len = 0;
+