Nir Soffer has uploaded a new change for review.

Change subject: periodic: Avoid useless drive monitoring
......................................................................

periodic: Avoid useless drive monitoring

The periodic system is checking every 2 seconds if a vm is ready for
commands (Vm.isDomainReadyForCommands). If a vm is ready, it schedules
an extend task in the scheduler (Vm.extendDrivesIfNeeded).

However, if a vm does not have any chunked drives (thin provisioned
block storage), or is in the middle of live storage migration
from non-chunked drive to chunked drive, extending drives is never
needed.

Checking if a vm is ready for commands should be safe, but recently
libvirt fixed a bug that cause this check to get stuck.

Now we check if a vm has chunked drives or non-chunked drives
replicating to chunked drives in DriveWatermarkMonitor.required,
skipping such vms early.

This change saves one libvirt call per vm each 2 seconds, and running
useless extend task per vm in the executor, reducing cpu usage when
using file based storage. This also reduces the risk of uncontrolled
executor worker discarding when NFS server become unresponsive.

Change-Id: I274acc2112cd9b55ac1867d850401be8911adf29
Relates-To: https://bugzilla.redhat.com/1337073
Signed-off-by: Nir Soffer <[email protected]>
---
M lib/vdsm/virt/periodic.py
M vdsm/virt/vm.py
2 files changed, 20 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/59764/1

diff --git a/lib/vdsm/virt/periodic.py b/lib/vdsm/virt/periodic.py
index 8ed5d67..2f57323 100644
--- a/lib/vdsm/virt/periodic.py
+++ b/lib/vdsm/virt/periodic.py
@@ -371,8 +371,7 @@
     @property
     def required(self):
         return (super(DriveWatermarkMonitor, self).required and
-                # Avoid queries from storage during recovery process
-                self._vm.isDisksStatsCollectionEnabled())
+                self._vm.needsDriveMonitoring())
 
     def _execute(self):
         self._vm.extendDrivesIfNeeded()
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index b5eec87..f439472 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -917,10 +917,7 @@
     def _getExtendCandidates(self):
         ret = []
 
-        for drive in self._devices[hwclass.DISK]:
-            if not (drive.chunked or drive.replicaChunked):
-                continue
-
+        for drive in self._chunkedDrives():
             try:
                 capacity, alloc, physical = self._getExtendInfo(drive)
             except libvirt.libvirtError as e:
@@ -931,6 +928,14 @@
             ret.append((drive, drive.volumeID, capacity, alloc, physical))
 
         return ret
+
+    def _chunkedDrives(self):
+        """
+        Return list of chunked drives, or non-chunked drives replicating to
+        chunked replica drive.
+        """
+        return [drive for drive in self._devices[hwclass.DISK]
+                if drive.chunked or drive.replicaChunked]
 
     def _getExtendInfo(self, drive):
         """
@@ -990,6 +995,16 @@
             return True
         return False
 
+    def needsDriveMonitoring(self):
+        """
+        Return True if vm needs drive monitoring for this cycle.
+
+        This is called every 2 seconds (configurable) by the periodic system.
+        If this retruns True, the periodic system will invoke
+        extendDrivesIfNeeded during this periodic cycle.
+        """
+        return self._volumesPrepared and bool(self._chunkedDrives())
+
     def extendDrivesIfNeeded(self):
         try:
             extend = [x for x in self._getExtendCandidates()


-- 
To view, visit https://gerrit.ovirt.org/59764
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I274acc2112cd9b55ac1867d850401be8911adf29
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/admin/lists/[email protected]

Reply via email to