Recent changes (master)
The following changes since commit acb7a302059b0cc397c95a232a44cb14c524bbde:
Merge branch 'dmabuf-io_uringv1' of https://github.com/swarnagh6/fio (2026-10-12 19:21:58 -0400)
are available in the Git repository at:
git://git.kernel.dk/fio.git master
for you to fetch changes up to 4767beef328a257c4300358ffa2901f3e0f1dc68:
Merge branch 'write_zeries' of https://github.com/panky-codes/fio (2026-10-19 11:57:14 -0400)
----------------------------------------------------------------
Pankaj Raghav (1):
fio: add FALLOC_FL_WRITE_ZEROES support to falloc
Vincent Fu (1):
Merge branch 'write_zeries' of https://github.com/panky-codes/fio
HOWTO.rst | 8 ++++++-- configure | 23 +++++++++++++++++++++++ file.h | 3 ++- filesetup.c | 15 +++++++++++++++ fio.1 | 8 ++++++-- options.c | 6 ++++++ 6 files changed, 58 insertions(+), 5 deletions(-)
---
Diff of recent changes:
HOWTO.rst +6 -2
@@ -1357,6 +1357,10 @@ I/O type Pre-allocate via :manpage:`fallocate(2)` with FALLOC_FL_KEEP_SIZE set. + **write_zeroes** + Pre-allocate via :manpage:`fallocate(2)` with + FALLOC_FL_WRITE_ZEROES set. + **truncate** Extend file to final size via :manpage:`ftruncate(2)` instead of allocating.
@@ -1367,8 +1371,8 @@ I/O type **1** Backward-compatible alias for **posix**. - May not be available on all supported platforms. **keep** is only available - on Linux. If using ZFS on Solaris this cannot be set to **posix** + May not be available on all supported platforms. **keep** and + **write_zeroes** are only available on Linux. If using ZFS on Solaris this cannot be set to **posix** because ZFS doesn't support pre-allocation. Default: **native** if any pre-allocation methods except **truncate** are available, **none** if not.
configure +23 -0
@@ -1098,6 +1098,26 @@ if compile_prog "" "" "linux_fallocate"; then fi print_config "Linux fallocate" "$linux_fallocate" +########################################## +# Linux fallocate FALLOC_FL_WRITE_ZEROES probe +if test "$linux_fallocate_write_zeroes" != "yes" ; then + linux_fallocate_write_zeroes="no" +fi +cat > $TMPC << EOF +#include <stdio.h> +#include <fcntl.h> +#include <linux/falloc.h> +int main(int argc, char **argv) +{ + int r = fallocate(0, FALLOC_FL_WRITE_ZEROES, 0, 1024); + return r; +} +EOF +if compile_prog "" "" "linux_fallocate_write_zeroes"; then + linux_fallocate_write_zeroes="yes" +fi +print_config "Linux fallocate write zeroes" "$linux_fallocate_write_zeroes" + ########################################## # POSIX fadvise probe if test "$posix_fadvise" != "yes" ; then
@@ -3221,6 +3241,9 @@ fi if test "$linux_fallocate" = "yes" ; then output_sym "CONFIG_LINUX_FALLOCATE" fi +if test "$linux_fallocate_write_zeroes" = "yes" ; then + output_sym "CONFIG_LINUX_FALLOCATE_WRITE_ZEROES" +fi if test "$posix_fallocate" = "yes" ; then output_sym "CONFIG_POSIX_FALLOCATE" fi
file.h +2 -1
@@ -63,7 +63,7 @@ enum {/* * No pre-allocation when laying down files, or call posix_fallocate(), or -* call fallocate() with FALLOC_FL_KEEP_SIZE set. +* call fallocate() with FALLOC_FL_KEEP_SIZE or FALLOC_FL_WRITE_ZEROES set. */ enum fio_fallocate_mode {FIO_FALLOCATE_NONE =1 ,
@@ -71,6 +71,7 @@ enum fio_fallocate_mode {FIO_FALLOCATE_KEEP_SIZE =3 ,FIO_FALLOCATE_NATIVE =4 ,FIO_FALLOCATE_TRUNCATE =5 , + FIO_FALLOCATE_WRITE_ZEROES = 6, };/*
filesetup.c +15 -0
@@ -95,6 +95,21 @@ static void fallocate_file(struct thread_data *td, struct fio_file *f) break; } +#ifdef CONFIG_LINUX_FALLOCATE_WRITE_ZEROES +case FIO_FALLOCATE_WRITE_ZEROES : { +int r; + +dprint (FD_FILE ,"fallocate(FALLOC_FL_WRITE_ZEROES) " +"file %s size %llu\n" , f->file_name, + (unsigned long long ) f->real_file_size); + + r =fallocate (f->fd,FALLOC_FL_WRITE_ZEROES ,0 , f->real_file_size); +if (r !=0 ) +td_verror (td, errno,"fallocate" ); + +break ; + } +#endif /* CONFIG_LINUX_FALLOCATE_WRITE_ZEROES */ #endif /* CONFIG_LINUX_FALLOCATE */ case FIO_FALLOCATE_TRUNCATE : {int r;
fio.1 +6 -2
@@ -1139,6 +1139,10 @@ Pre-allocate via \fBposix_fallocate\fR\|(3). Pre-allocate via \fBfallocate\fR\|(2) with FALLOC_FL_KEEP_SIZE set. .TP +.B write_zeroes +Pre-allocate via \fBfallocate\fR\|(2) with +FALLOC_FL_WRITE_ZEROES set. +.TP .B truncate Extend file to final size using \fBftruncate\fR|(2) instead of allocating.
@@ -1150,8 +1154,8 @@ Backward-compatible alias for \fBnone\fR. Backward-compatible alias for \fBposix\fR. .RE .P -May not be available on all supported platforms. \fBkeep\fR is only available -on Linux. If using ZFS on Solaris this cannot be set to \fBposix\fR +May not be available on all supported platforms. \fBkeep\fR and +\fBwrite_zeroes\fR are only available on Linux. If using ZFS on Solaris this cannot be set to \fBposix\fR because ZFS doesn't support pre-allocation. Default: \fBnative\fR if any pre-allocation methods except \fBtruncate\fR are available, \fBnone\fR if not. .P
options.c +6 -0
@@ -3011,6 +3011,12 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .oval = FIO_FALLOCATE_KEEP_SIZE, .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)", }, +#ifdef CONFIG_LINUX_FALLOCATE_WRITE_ZEROES + { .ival = "write_zeroes", + .oval = FIO_FALLOCATE_WRITE_ZEROES, + .help = "Use fallocate(..., FALLOC_FL_WRITE_ZEROES, ...)", + }, +#endif #endif { .ival = "truncate", .oval = FIO_FALLOCATE_TRUNCATE,