[PATCH RFC] iohelper: Introduces a small sleep do avoid hunging other tasks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While dumping very large VMs (over 128GB), iohelper seems to cause
very intense IO usage on the disk, and it causes some processes
(like journald) to hung, and depending on kernel configuration,
to panic.

This change creates a time window, after every 10GB written, so
this processes can write to the disk, and avoid hunging.

Signed-off-by: Leonardo Bras <leonardo@xxxxxxxxxxxxx>
---
 src/util/iohelper.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/util/iohelper.c b/src/util/iohelper.c
index ddc338b7c7..164c1e2085 100644
--- a/src/util/iohelper.c
+++ b/src/util/iohelper.c
@@ -52,6 +52,8 @@ runIO(const char *path, int fd, int oflags)
     unsigned long long total = 0;
     bool direct = O_DIRECT && ((oflags & O_DIRECT) != 0);
     off_t end = 0;
+    const unsigned long long sleep_step = (long long)10*1024*1024*1024;
+    unsigned long long next_sleep = sleep_step;
 
 #if HAVE_POSIX_MEMALIGN
     if (posix_memalign(&base, alignMask + 1, buflen)) {
@@ -128,6 +130,12 @@ runIO(const char *path, int fd, int oflags)
 
         total += got;
 
+        /* sleeps for a while to avoid hunging other tasks */
+        if (total > next_sleep) {
+            next_sleep += sleep_step;
+            usleep(100*1000);
+        }
+
         /* handle last write size align in direct case */
         if (got < buflen && direct && fdout == fd) {
             ssize_t aligned_got = (got + alignMask) & ~alignMask;
-- 
2.20.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux