Skip to content

fadvise64 syscall not hooked

Reported by 王荣耀 m201972975@alumni.hust.edu.cn via email.

Running fio with libaio engine reports Bad file descriptor. Reproduced:

gkfs fio --name=write_test --directory=/tmp/gkfs_mountdir --rw=write --bs=4k --size=4k --thread=1 --numjobs=1 --iodepth=1 --loops=1 --buffered=0 --ioengine=libaio
write_test: (g=0): rw=write, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=1
fio-3.27
Starting 1 thread
write_test: Laying out IO file (1 file / 0MiB)
fio: cache invalidation of /tmp/gkfs_mountdir/write_test.0.0 failed: Bad file descriptor
fio: cache invalidation of /tmp/gkfs_mountdir/write_test.0.0 failed: Bad file descriptor
fio: pid=3993920, err=9/file:ioengines.c:486, func=io commit, error=Bad file descriptor

write_test: (groupid=0, jobs=1): err= 9 (file:ioengines.c:486, func=io commit, error=Bad file descriptor): pid=3993920: Thu Feb 16 09:31:04 2023
  cpu          : usr=35.71%, sys=0.00%, ctx=3, majf=0, minf=3
  IO depths    : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0%
     submit    : 0=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     complete  : 0=100.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
     issued rwts: total=0,1,0,0 short=0,0,0,0 dropped=0,0,0,0
     latency   : target=0, window=0, percentile=100.00%, depth=1

Run status group 0 (all jobs):

Looking at the logs, this is because fadvise64() is used but not hooked. As a result, the syscall is passed to the kernel with a file descriptor from us which is invalid.