#1473·fio

The Linux native fallocate and posix_fallocate(punch hole in some of the filesystem) are not written to the block device

Author: homerlCreated Sep 23, 2022Updated Mar 26, 2026

Please acknowledge the following before creating a ticket

Description of the bug:

There is no FIO issue, the test order, and the filesystem optimization cause the impossible result.

Environment:

bash
uname -r
3.10.0-1127.el7.x86_64

cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.1.1-20190605/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.1.1 20190605 (Red Hat 9.1.1-2) (GCC) 

Test under fio 3.7 and fio 3.32:

fio -v 
3.7 

./fio -v
fio-3.32

./configure | grep falloc
Linux fallocate               yes
POSIX fallocate               yes

Reproduction steps

bash
 parted /dev/sdu unit s p
Model: WDC WUH722020BL5204 (scsi)
Disk /dev/sdu: 39063650304s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start  End          Size         File system  Name  Flags
 1      2048s  7812499455s  7812497408s               1

mkfs.ext4 /dev/sdu1

 mount /dev/sdu1 /mnt
 df -hT /mnt
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sdu1      ext4  3.6T   89M  3.4T   1% /mnt

fio-fio-3.32/fio  -rw=randwrite -ioengine=sync -direct=1 -size=600G -numjobs=4 -blocksize=4K -directory=/mnt/fio -name=fio-test
fio-test: (g=0): rw=randwrite, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=sync, iodepth=1
......
fio-3.32
Starting 4 processes
fio-test: Laying out IO file (1 file / 614400MiB)
fio-test: Laying out IO file (1 file / 614400MiB)
fio-test: Laying out IO file (1 file / 614400MiB)
fio-test: Laying out IO file (1 file / 614400MiB)
......
Run status group 0 (all jobs):
  WRITE: bw=3195KiB/s (3271kB/s), 798KiB/s-799KiB/s (817kB/s-818kB/s), io=638MiB (669MB), run=204399-204399msec

The first step must be "-rw=write or -rw=randwrite", 4x 600G files generated after a few seconds by the Linux native fallocate
Ctrl + c or limit the run time.

ls -ls /mnt/fio/
total 2516582416
629145604 -rw-r--r-- 1 root root 644245094400 Sep 23 22:00 fio-test.0.0
629145604 -rw-r--r-- 1 root root 644245094400 Sep 23 22:00 fio-test.1.0
629145604 -rw-r--r-- 1 root root 644245094400 Sep 23 22:00 fio-test.2.0
629145604 -rw-r--r-- 1 root root 644245094400 Sep 23 22:00 fio-test.3.0

man fio

fallocate=str
......
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 because ZFS doesn't support pre-allo‐cation. 
Default: native if any pre-allocation methods are available, none if not.

The average random write is only 3195KiB/s
About 218.79 hours(629147188 KiB*4/3195 KiBps/3600 secs) to fill all test files, which means I will limit the test time by runtime and time_based

The random write test just fills 0.9% of data in 2 hours, the others are an area represented by zeros(file holes).

The random read average bandwidth reaches 7129MiB/s......the 7200rpm HDD limit throughput is only 277 MiB/s in the WDC spec

time fio-fio-3.32/fio  -rw=randread -ioengine=sync -direct=1 -size=600G -numjobs=4 -blocksize=4K -directory=/mnt/fio -name=fio-test
fio-test: (g=0): rw=randread, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=sync, iodepth=1
...
fio-3.32
Starting 4 processes
^Cbs: 4 (f=4): [r(4)][52.7%][r=7135MiB/s][r=1826k IOPS][eta 02m:46s]
fio: terminating on signal 2
.......
Run status group 0 (all jobs):
   READ: bw=7129MiB/s (7476MB/s), 1747MiB/s-1832MiB/s (1831MB/s-1921MB/s), io=1291GiB (1386GB), run=185394-185395msec

Disk stats (read/write):
  sdu: ios=14295/2, merge=0/0, ticks=1755/14, in_queue=1764, util=0.95%

real	3m5.902s
user	6m8.947s
sys	6m12.186s

The fallocatte call will bring about the incorrect test result with some testing order and test parameters.
I think the same impact in some distributed filesystems too if the file hole has been optimized.