- if (td->o.fallocate && !td->o.fill_device) {
- dprint(FD_FILE, "fallocate file %s size %llu\n", f->file_name,
- f->real_file_size);
-
- r = posix_fallocate(f->fd, 0, f->real_file_size);
- if (r > 0) {
- log_err("fio: posix_fallocate fails: %s\n",
- strerror(r));
+ if (!td->o.fill_device) {
+ switch (td->o.fallocate_mode) {
+ case FIO_FALLOCATE_NONE:
+ break;
+ case FIO_FALLOCATE_POSIX:
+ dprint(FD_FILE, "posix_fallocate file %s size %llu\n",
+ f->file_name, f->real_file_size);
+
+ r = posix_fallocate(f->fd, 0, f->real_file_size);
+ if (r > 0) {
+ log_err("fio: posix_fallocate fails: %s\n",
+ strerror(r));
+ }
+ break;
+#ifdef FIO_HAVE_LINUX_FALLOCATE
+ case FIO_FALLOCATE_KEEP_SIZE:
+ dprint(FD_FILE,
+ "fallocate(FALLOC_FL_KEEP_SIZE) "
+ "file %s size %llu\n",
+ f->file_name, f->real_file_size);
+
+ r = fallocate(f->fd, FALLOC_FL_KEEP_SIZE, 0,
+ f->real_file_size);
+ if (r != 0) {
+ td_verror(td, errno, "fallocate");
+ }
+ break;
+#endif /* FIO_HAVE_LINUX_FALLOCATE */
+ default:
+ log_err("fio: unknown fallocate mode: %d\n",
+ td->o.fallocate_mode);
+ assert(0);