From: Jens Axboe Date: Thu, 17 Feb 2022 19:08:41 +0000 (-0700) Subject: Use fcntl(..., F_FULLSYNC) if available X-Git-Tag: fio-3.30~40 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=a04e0665cb5d3a545ab1dbe2d2b7c150b404735d;p=fio.git Use fcntl(..., F_FULLSYNC) if available Some operating systems don't perform a data integrity flush when fsync() is done, but provide fcntl(fd, F_FULLSYNC) to provide that kind of guarantee. To ensure that comparisons between operating systems is fair, use fcntl() to do a proper sync if available. Signed-off-by: Jens Axboe --- diff --git a/configure b/configure index 0efde7d6..fd1d435b 100755 --- a/configure +++ b/configure @@ -645,6 +645,25 @@ if compile_prog "" "-lz" "zlib" ; then fi print_config "zlib" "$zlib" +########################################## +# fcntl(F_FULLFSYNC) support +if test "$fcntl_sync" != "yes" ; then + fcntl_sync="no" +fi +cat > $TMPC << EOF +#include +#include + +int main(int argc, char **argv) +{ + return fcntl(0, F_FULLSYNC); +} +EOF +if compile_prog "" "" "fcntl(F_FULLSYNC)" ; then + fcntl_sync="yes" +fi +print_config "fcntl(F_FULLSYNC)" "$fcntl_sync" + ########################################## # linux-aio probe if test "$libaio" != "yes" ; then @@ -3174,6 +3193,9 @@ fi if test "$pdb" = yes; then output_sym "CONFIG_PDB" fi +if test "$fcntl_sync" = "yes" ; then + output_sym "CONFIG_FCNTL_SYNC" +fi print_config "Lib-based ioengines dynamic" "$dynamic_engines" cat > $TMPC << EOF diff --git a/io_u.c b/io_u.c index 059637e5..9d977d34 100644 --- a/io_u.c +++ b/io_u.c @@ -2297,7 +2297,11 @@ int do_io_u_sync(const struct thread_data *td, struct io_u *io_u) int ret; if (io_u->ddir == DDIR_SYNC) { +#ifdef CONFIG_FCNTL_SYNC + ret = fcntl(io_u->file->fd, F_FULLSYNC); +#else ret = fsync(io_u->file->fd); +#endif } else if (io_u->ddir == DDIR_DATASYNC) { #ifdef CONFIG_FDATASYNC ret = fdatasync(io_u->file->fd);