How to use FIO inside the container with direct read/write?

How do I use FIO inside the container with direct read/write?
It gives me an error if it is not buffered mode.

Thanks in advance!

@brauner have you ever looked into FIO?
@michacassola is that a privileged or unprivileged container?

O_DIRECT requires filesystem support. What’s the underlying fs? If it’s zfs then it won’t do O_DIRECT (correctly).

I always use unprivileged containers for security reasons.

I will try on BTRFS and LVM.

By the way, where do these wierd benchmarks come from?:

write: io=2652.6MB, bw=11317KB/s, iops=2829, runt=240018msec
read : io=4096.0MB, bw=71598KB/s, iops=17899, runt= 58581msec

write: io=4024.7MB, bw=17169KB/s, iops=4292, runt=240002msec
read : io=4096.0MB, bw=19910KB/s, iops=4977, runt=210659msec

write: io=4096.0MB, bw=68276KB/s, iops=17068, runt= 61432msec
read : io=4096.0MB, bw=20680KB/s, iops=5169, runt=202822msec

ZFS reads are properly thanks to ZFS aggressive caching.
Not sure what’s up with LVM though, also not sure what the underlying storage is and what kind of performance would be expected from it.

Note that there are potentially two layers of buffering involved: The loopback device and the filesystem.

It works with direct mode on BTRFS and LVM:

LVM Direct:
write: io=2477.9MB, bw=10570KB/s, iops=2642, runt=240041msec
read : io=4096.0MB, bw=26037KB/s, iops=6509, runt=161091msec

BTRFS Direct:
write: io=4096.0MB, bw=28302KB/s, iops=7075, runt=148196msec
read : io=4096.0MB, bw=25304KB/s, iops=6325, runt=165759msec

With these kind of results I wonder what kind of weird SSD setup my VPS provider has.