diff --git a/cmdline/unix.c b/cmdline/unix.c index 32861927..f7cd906e 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -1860,11 +1860,6 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others) { void* (*func)(void* arg) = 0; - if (operation == DEVICE_DOWN) { - /* flush all the disk caches before spinning down */ - sync(); - } - #if HAVE_LINUX_DEVICE tommy_node* i; struct stat st; @@ -1883,6 +1878,17 @@ int devquery(tommy_list* high, tommy_list* low, int operation, int others) uint64_t device = devinfo->device; uint64_t access_stat; +#if HAVE_SYNCFS + if (operation == DEVICE_DOWN) { + /* flush the high level filesystem before spinning down */ + int f = open(devinfo->mount, O_RDONLY); + if (f >= 0) { + syncfs(f); + close(f); + } + } +#endif + /* if the major is the null device, find the real one */ if (major(device) == 0) { /* obtain the real device */ diff --git a/configure.ac b/configure.ac index 981b1109..e0ad29fa 100644 --- a/configure.ac +++ b/configure.ac @@ -69,7 +69,7 @@ dnl Checks for library functions. AC_CHECK_FUNCS([memset strchr strerror strrchr mkdir gettimeofday strtoul]) AC_CHECK_FUNCS([getopt getopt_long snprintf vsnprintf sigaction]) AC_CHECK_FUNCS([ftruncate fallocate access]) -AC_CHECK_FUNCS([fsync posix_fadvise sync_file_range]) +AC_CHECK_FUNCS([fsync posix_fadvise sync_file_range syncfs]) AC_CHECK_FUNCS([getc_unlocked ferror_unlocked fnmatch]) AC_CHECK_FUNCS([futimes futimens futimesat localtime_r lutimes utimensat]) AC_CHECK_FUNCS([fstatat flock])