mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-20 22:48:22 +00:00
Speed up test suite by avoiding fsync
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls into no-ops, and use it in programs that copy files but do not need to take special care to sync writes (grub-mknetdir, grub-rescue, grub-mkstandalone). On my laptop, this reduces partmap_test's runtime from 1236 seconds to 204 seconds.
This commit is contained in:
1 parent
fc3f2b72cd
commit
5c7206e45e
9 files changed
+52
-11
No files matched your search
@@ -455,6 +455,8 @@ grub_util_fd_close (grub_util_fd_t fd)
|
||||
}
|
||||
}
|
||||
|
||||
static int allow_fd_syncs = 1;
|
||||
|
||||
static void
|
||||
grub_util_fd_sync_volume (grub_util_fd_t fd)
|
||||
{
|
||||
@@ -469,17 +471,26 @@ grub_util_fd_sync_volume (grub_util_fd_t fd)
|
||||
void
|
||||
grub_util_fd_sync (grub_util_fd_t fd)
|
||||
{
|
||||
switch (fd->type)
|
||||
if (allow_fd_syncs)
|
||||
{
|
||||
case GRUB_UTIL_FD_FILE:
|
||||
fsync (fd->fd);
|
||||
return;
|
||||
case GRUB_UTIL_FD_DISK:
|
||||
grub_util_fd_sync_volume (fd);
|
||||
return;
|
||||
switch (fd->type)
|
||||
{
|
||||
case GRUB_UTIL_FD_FILE:
|
||||
fsync (fd->fd);
|
||||
return;
|
||||
case GRUB_UTIL_FD_DISK:
|
||||
grub_util_fd_sync_volume (fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_disable_fd_syncs (void)
|
||||
{
|
||||
allow_fd_syncs = 0;
|
||||
}
|
||||
|
||||
void
|
||||
grub_hostdisk_flush_initial_buffer (const char *os_dev __attribute__ ((unused)))
|
||||
{
|
||||
|
||||
@@ -191,10 +191,19 @@ grub_util_fd_strerror (void)
|
||||
return strerror (errno);
|
||||
}
|
||||
|
||||
static int allow_fd_syncs = 1;
|
||||
|
||||
void
|
||||
grub_util_fd_sync (grub_util_fd_t fd)
|
||||
{
|
||||
fsync (fd);
|
||||
if (allow_fd_syncs)
|
||||
fsync (fd);
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_disable_fd_syncs (void)
|
||||
{
|
||||
allow_fd_syncs = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -240,10 +240,19 @@ grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len)
|
||||
return real_read;
|
||||
}
|
||||
|
||||
static int allow_fd_syncs = 1;
|
||||
|
||||
void
|
||||
grub_util_fd_sync (grub_util_fd_t fd)
|
||||
{
|
||||
FlushFileBuffers (fd);
|
||||
if (allow_fd_syncs)
|
||||
FlushFileBuffers (fd);
|
||||
}
|
||||
|
||||
void
|
||||
grub_util_disable_fd_syncs (void)
|
||||
{
|
||||
allow_fd_syncs = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in new issue
Block a user