When spinning down sync only the related disks

This commit is contained in:
Andrea Mazzoleni 2025-12-26 11:48:25 +01:00
parent 524733a6db
commit 3678474074
2 changed files with 12 additions and 6 deletions

View file

@ -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 */

View file

@ -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])