Change in vdsm[master]: logging: Improve logging when receiving signals
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: logging: Improve logging when receiving signals
......................................................................
logging: Improve logging when receiving signals
Log INFO message when receiving signals, explaining the action taken.
Change-Id: I1462d296ca99e8eb2eee8640648db0eea039a83c
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
M vdsm/vdsm
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/89/61289/1
diff --git a/vdsm/vdsm b/vdsm/vdsm
index a6dc727..400f542 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -70,12 +70,12 @@
running = [True]
def sigtermHandler(signum, frame):
- log.debug("Received signal %s" % signum)
+ log.info("Received signal %s, shutting down" % signum)
running[0] = False
def sigusr1Handler(signum, frame):
if irs:
- log.debug("Received signal %s" % signum)
+ log.info("Received signal %s, stopping SPM" % signum)
irs.spmStop(
irs.getConnectedStoragePoolsList()['poollist'][0])
--
To view, visit https://gerrit.ovirt.org/61289
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1462d296ca99e8eb2eee8640648db0eea039a83c
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: debug: Add virt-alignment-scan.debug tool
by Nir Soffer
Nir Soffer has uploaded a new change for review.
Change subject: debug: Add virt-alignment-scan.debug tool
......................................................................
debug: Add virt-alignment-scan.debug tool
Change-Id: I2ec4d0219ea039d57ee8809339a7e03d71980bf8
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
A vdsm/virt-alignment-scan.debug
1 file changed, 24 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/40896/1
diff --git a/vdsm/virt-alignment-scan.debug b/vdsm/virt-alignment-scan.debug
new file mode 100755
index 0000000..e904b45
--- /dev/null
+++ b/vdsm/virt-alignment-scan.debug
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Debug tool for virt-alignmnet-scan
+#
+# Installation:
+#
+# mv /usr/bin/virt-alignment-scan /usr/bin/virt-alignment-scan.real
+# ln -s /usr/share/vdsm/virt-alignment-scan.debug /usr/bin/virt-alignment-scan
+#
+# Uinstall
+#
+# mv /usr/bin/virt-alignment-scan.real /usr/bin/virt-alignment-scan
+
+log="/var/log/vdsm/virt-alignmnet-scan.debug.log"
+
+/usr/bin/virt-alignment-scan "$@"
+rc=$?
+if [ $rc -ne 0 ]; then
+ # See https://bugzilla.redhat.com/show_bug.cgi?id=1151838#c28
+ sleep 30
+ /usr/bin/libguestfs-test-tool >> $log 2>&1
+fi
+
+exit $rc
--
To view, visit https://gerrit.ovirt.org/40896
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2ec4d0219ea039d57ee8809339a7e03d71980bf8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: sdm: Use guarded.context in copy_data
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: sdm: Use guarded.context in copy_data
......................................................................
sdm: Use guarded.context in copy_data
Change-Id: I5c2a9527f5e3787069e0847e1bf775a60321b306
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M tests/storage_sdm_copy_data_test.py
M vdsm/storage/sdm/api/copy_data.py
2 files changed, 71 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/61693/1
diff --git a/tests/storage_sdm_copy_data_test.py b/tests/storage_sdm_copy_data_test.py
index def8934..45c5540 100644
--- a/tests/storage_sdm_copy_data_test.py
+++ b/tests/storage_sdm_copy_data_test.py
@@ -33,8 +33,11 @@
from vdsm import jobs
from vdsm import qemuimg
from vdsm.storage import constants as sc
+from vdsm.storage import guarded
from storage import blockVolume
+from storage import resourceManager as rm
+from storage import sd
import storage.sdm.api.copy_data
@@ -49,6 +52,7 @@
rm = FakeResourceManager()
with MonkeyPatchScope([
(storage.sdm.api.copy_data, 'sdCache', env.sdcache),
+ (guarded, 'rmanager', rm),
(blockVolume, 'rmanager', rm),
]):
src_vols = make_qemu_chain(env, self.SIZE, src_fmt,
@@ -68,6 +72,40 @@
qemuimg.create(vol.volumePath, size=self.SIZE,
format=qemuimg.FORMAT.QCOW2, backing=backing)
return vol
+
+ def check_locks(self, storage_type, src, dst):
+ src_img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, src.sdUUID)
+ dst_img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, dst.sdUUID)
+ locks = sorted({
+ guarded.ResourceManagerLock(sc.STORAGE, src.sdUUID,
+ rm.LockType.shared),
+ guarded.ResourceManagerLock(sc.STORAGE, dst.sdUUID,
+ rm.LockType.shared),
+ guarded.ResourceManagerLock(src_img_ns, src.imgUUID,
+ rm.LockType.shared),
+ guarded.ResourceManagerLock(dst_img_ns, dst.imgUUID,
+ rm.LockType.exclusive),
+ })
+ if storage_type == 'block':
+ # NOTE: LVM locks are taken implicitly as part of block volume
+ # prepare. As a result they are acquired in the order that the
+ # prepare is called (src -> dst). This probably should be changed
+ # but we'd have to add a bulk prepare function that uses guarded.
+ locks.extend([
+ guarded.ResourceManagerLock(
+ sd.getNamespace(sc.LVM_ACTIVATION_NAMESPACE, src.sdUUID),
+ src.volUUID, rm.LockType.shared),
+ guarded.ResourceManagerLock(
+ sd.getNamespace(sc.LVM_ACTIVATION_NAMESPACE, dst.sdUUID),
+ dst.volUUID, rm.LockType.exclusive),
+ ])
+
+ expected_acquires = [('acquireResource', (l.ns, l.name, l.mode), {})
+ for l in locks]
+ expected_releases = [('releaseResource', (l.ns, l.name), {})
+ for l in reversed(locks)]
+ calls = guarded.rmanager.__calls__
+ self.assertEqual(expected_acquires + expected_releases, calls)
@permutations((
('file', 'raw', 'raw'),
@@ -106,6 +144,7 @@
verify_qemu_chain(dst_chain)
self.assertEqual(sc.fmt2str(dst_fmt),
qemuimg.info(dst_vol.volumePath)['format'])
+ self.check_locks(env_type, src_vol, dst_vol)
@permutations((
('file', 'raw', 'raw', (0, 1)),
diff --git a/vdsm/storage/sdm/api/copy_data.py b/vdsm/storage/sdm/api/copy_data.py
index aff0185..b9dd555 100644
--- a/vdsm/storage/sdm/api/copy_data.py
+++ b/vdsm/storage/sdm/api/copy_data.py
@@ -26,7 +26,10 @@
from vdsm import properties
from vdsm import qemuimg
from vdsm.storage import constants as sc
+from vdsm.storage import guarded
+from storage import resourceManager as rm
+from storage import sd
from storage import volume
from storage.sdc import sdCache
@@ -42,8 +45,8 @@
def __init__(self, job_id, host_id, source, destination):
super(Job, self).__init__(job_id, 'copy_data', host_id)
- self._source = _create_endpoint(source)
- self._dest = _create_endpoint(destination)
+ self._source = _create_endpoint(source, writable=False)
+ self._dest = _create_endpoint(destination, writable=True)
self._operation = None
@property
@@ -55,26 +58,26 @@
self._operation.abort()
def _run(self):
- # TODO: LOCKING!
- with self._source.prepare(), self._dest.prepare(writable=True):
- # Do not start copying if we have already been aborted
- if self._status == jobs.STATUS.ABORTED:
- return
+ with guarded.context(self._source, self._dest):
+ with self._source.prepare(), self._dest.prepare():
+ # Do not start copying if we have already been aborted
+ if self._status == jobs.STATUS.ABORTED:
+ return
- self._operation = qemuimg.convert(
- self._source.path,
- self._dest.path,
- srcFormat=self._source.qemu_format,
- dstFormat=self._dest.qemu_format,
- backing=self._dest.backing_path,
- backingFormat=self._dest.backing_qemu_format)
- self._operation.wait_for_completion()
+ self._operation = qemuimg.convert(
+ self._source.path,
+ self._dest.path,
+ srcFormat=self._source.qemu_format,
+ dstFormat=self._dest.qemu_format,
+ backing=self._dest.backing_path,
+ backingFormat=self._dest.backing_qemu_format)
+ self._operation.wait_for_completion()
-def _create_endpoint(params):
+def _create_endpoint(params, writable):
endpoint_type = params.pop('endpoint_type')
if endpoint_type == 'div':
- return CopyDataDivEndpoint(params)
+ return CopyDataDivEndpoint(params, writable)
else:
raise ValueError("Invalid or unsupported endpoint %r" % params)
@@ -84,11 +87,20 @@
img_id = properties.UUID(required=True)
vol_id = properties.UUID(required=True)
- def __init__(self, params):
+ def __init__(self, params, writable):
self.sd_id = params.get('sd_id')
self.img_id = params.get('img_id')
self.vol_id = params.get('vol_id')
+ self._writable = writable
self._vol = None
+
+ @property
+ def locks(self):
+ img_ns = sd.getNamespace(sc.IMAGE_NAMESPACE, self.sd_id)
+ mode = rm.LockType.exclusive if self._writable else rm.LockType.shared
+ return (guarded.ResourceManagerLock(sc.STORAGE, self.sd_id,
+ rm.LockType.shared),
+ guarded.ResourceManagerLock(img_ns, self.img_id, mode))
@property
def path(self):
@@ -114,10 +126,10 @@
return sc.fmt2str(parent_vol.getFormat())
@contextmanager
- def prepare(self, writable=False):
+ def prepare(self):
dom = sdCache.produce_manifest(self.sd_id)
self._vol = dom.produceVolume(self.img_id, self.vol_id)
- self._vol.prepare(rw=writable, justme=True)
+ self._vol.prepare(rw=self._writable, justme=True)
try:
yield
finally:
--
To view, visit https://gerrit.ovirt.org/61693
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c2a9527f5e3787069e0847e1bf775a60321b306
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: sampling: Retrieve backing chain stats
by ahino@redhat.com
Ala Hino has uploaded a new change for review.
Change subject: sampling: Retrieve backing chain stats
......................................................................
sampling: Retrieve backing chain stats
Update sampling mechanism to retrieve backing chain stats. This is
required to get the allocation value of all volumes in the chain.
These stats will be cachd in a volume UUID to allocatoin value
dictionary.
Based on the allocation value, we will find out how to extend volumes
during live merge. The logic of getting live merge ectend candidates
will be done in a separate patch.
Change-Id: I3bbb8643d1c86e90d1e2de7cb2a5b00116c71453
Signed-off-by: Ala Hino <ahino(a)redhat.com>
---
M lib/vdsm/virt/sampling.py
M lib/vdsm/virt/vmstats.py
2 files changed, 27 insertions(+), 2 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/60888/1
diff --git a/lib/vdsm/virt/sampling.py b/lib/vdsm/virt/sampling.py
index 8feaf37..c92fc4a 100644
--- a/lib/vdsm/virt/sampling.py
+++ b/lib/vdsm/virt/sampling.py
@@ -31,6 +31,9 @@
import threading
import time
+# 3rd party libs imports
+import libvirt
+
from vdsm import numa
from vdsm import utils
from vdsm.constants import P_VDSM_RUN, P_VDSM_CLIENT_LOG
@@ -493,17 +496,19 @@
fast_path = acquired and not self._skip_doms
doms = [] # whitelist, meaningful only in the slow path
try:
+ flags = libvirt.VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING
if fast_path:
# This is expected to be the common case.
# If everything's ok, we can skip all the costly checks.
- bulk_stats = self._conn.getAllDomainStats(self._stats)
+ bulk_stats = self._conn.getAllDomainStats(
+ self._stats, flags)
else:
# A previous call got stuck, or not every domain
# has properly recovered. Thus we must whitelist domains.
doms = self._get_responsive_doms()
if doms:
bulk_stats = self._conn.domainListGetStats(
- doms, self._stats)
+ doms, self._stats, flags)
else:
bulk_stats = []
except Exception:
diff --git a/lib/vdsm/virt/vmstats.py b/lib/vdsm/virt/vmstats.py
index 177e2a9..2f06a66 100644
--- a/lib/vdsm/virt/vmstats.py
+++ b/lib/vdsm/virt/vmstats.py
@@ -21,6 +21,7 @@
import contextlib
import logging
+import os
import six
@@ -43,6 +44,7 @@
cpu(stats, first_sample, last_sample, interval)
networks(vm, stats, first_sample, last_sample, interval)
disks(vm, stats, first_sample, last_sample, interval)
+ watermarks(stats, first_sample, last_sample, interval)
balloon(vm, stats, last_sample)
cpu_count(stats, last_sample)
tune_io(vm, stats)
@@ -352,6 +354,24 @@
return stats
+def watermarks(stats, first_sample, last_sample, interval):
+ if first_sample is None or last_sample is None:
+ return None
+
+ watermarks = {}
+ for key in last_sample:
+ if key.endswith("path"):
+ prefix, index, attr = key.split(".", 2)
+ path = last_sample[key]
+ alloc_key = "block" + "." + index + ".allocation"
+ allocation = last_sample[alloc_key]
+ vol_uuid = os.path.basename(path)
+ watermarks[vol_uuid] = allocation
+
+ if watermarks:
+ stats['watermarks'] = watermarks
+
+
def _disk_rate(first_sample, first_index, last_sample, last_index, interval):
stats = {}
--
To view, visit https://gerrit.ovirt.org/60888
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3bbb8643d1c86e90d1e2de7cb2a5b00116c71453
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino <ahino(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: storage: Introduce guarded utilities
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: Introduce guarded utilities
......................................................................
storage: Introduce guarded utilities
Throughout the storage code we have implicit locking rules which we follow in
order to ensure that concurrent operations will not conflict with one another.
We also require a specific locking order to prevent deadlocks. This code is
repeated throughout the storage subsystem and is error prone. To alleviate
this, introduce the guarded module with a context manager that can perform the
necessary locking. At first we will support only resourceManager locks but
this model can be easily extended to a support for volume leases.
The contextmanager accepts a list of entities which need to be guarded within
the context. It then collects all of the required locks from the entities and
locks them according to the rules. When exiting the context (or upon error)
the locks are released in reverse order.
Entities must provide the get_rm_locks() method which returns a list of ResourceManagerLocks required.
The following rules are currently enforced:
- Locks are collected from all entities and sorted
- Duplicate locks are removed
- Exclusive mode takes precedence over shared mode
Change-Id: I2b0a204818d44b6205515277f4c2834cb2b7a057
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
A lib/vdsm/storage/guarded.py
M tests/Makefile.am
A tests/storage_guarded_test.py
M vdsm.spec.in
4 files changed, 236 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/35/61435/1
diff --git a/lib/vdsm/storage/guarded.py b/lib/vdsm/storage/guarded.py
new file mode 100644
index 0000000..5614cf0
--- /dev/null
+++ b/lib/vdsm/storage/guarded.py
@@ -0,0 +1,94 @@
+#
+# Copyright 2016 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+from __future__ import absolute_import
+import logging
+
+from storage import resourceManager as rm
+
+log = logging.getLogger('storage.guarded')
+rmanager = rm.ResourceManager.getInstance()
+
+
+class operation_context(object):
+
+ def __init__(self, entities):
+ self._rm_locks = self._collect_rm_locks(entities)
+ self._held_locks = []
+
+ def __enter__(self):
+ try:
+ for lock in self._rm_locks:
+ lock.acquire()
+ self._held_locks.append(lock)
+ except:
+ self._release()
+ raise
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self._release()
+
+ def _collect_rm_locks(self, entities):
+ locks = []
+ for entity in entities:
+ locks.extend(entity.get_rm_locks())
+
+ # Exclusive locks always take precedence over shared
+ lock_set = set([l for l in locks if l.mode == rm.LockType.exclusive])
+ shared_locks = set([l for l in locks if l.mode == rm.LockType.shared])
+ lock_set.update(shared_locks)
+ return sorted(lock_set)
+
+ def _release(self):
+ while self._held_locks:
+ lock = self._held_locks.pop()
+ lock.release()
+
+
+class Entity(object):
+ """
+ Defines the interface that must be implemented by objects that wish to be
+ guarded by operation_context.
+ """
+
+ def get_rm_locks(self):
+ return []
+
+
+class ResourceManagerLock(object):
+ def __init__(self, ns, name, mode):
+ self.ns = ns
+ self.name = name
+ self.mode = mode
+
+ def acquire(self):
+ rmanager.acquireResource(self.ns, self.name, self.mode)
+
+ def release(self):
+ rmanager.releaseResource(self.ns, self.name)
+
+ def _key(self):
+ return self.ns, self.name
+
+ def __cmp__(self, other):
+ return cmp(self._key(), other._key())
+
+ def __hash__(self):
+ return hash(self._key())
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 467f2d4..c6e527f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -122,6 +122,7 @@
storage_asyncevent_test.py \
storage_check_test.py \
storage_directio_test.py \
+ storage_guarded_test.py \
storage_hsm_test.py \
storage_monitor_test.py \
storage_rwlock_test.py \
@@ -221,6 +222,7 @@
stompAsyncDispatcherTests.py \
stompTests.py \
storageMailboxTests.py \
+ storage_guarded_test.py \
storage_hsm_test.py \
storage_monitor_test.py \
storageServerTests.py \
diff --git a/tests/storage_guarded_test.py b/tests/storage_guarded_test.py
new file mode 100644
index 0000000..29db745
--- /dev/null
+++ b/tests/storage_guarded_test.py
@@ -0,0 +1,139 @@
+#
+# Copyright 2016 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+from __future__ import absolute_import
+from contextlib import contextmanager
+
+from monkeypatch import MonkeyPatchScope
+from storagefakelib import FakeResourceManager
+from testlib import VdsmTestCase, expandPermutations, permutations
+
+from vdsm.storage import guarded
+
+from storage import resourceManager as rm
+
+
+@expandPermutations
+class ContextTest(VdsmTestCase):
+
+ @contextmanager
+ def env(self):
+ rmanager = FakeResourceManager()
+ with MonkeyPatchScope([(guarded, 'rmanager', rmanager)]):
+ yield rmanager
+
+ def test_none(self):
+ with self.env():
+ with guarded.operation_context([]):
+ pass
+
+ def test_remove_duplicates(self):
+ resource_locks = [
+ guarded.ResourceManagerLock('A', 'a', rm.LockType.shared),
+ ]
+ src = GuardedEntity(resource_locks)
+ dst = GuardedEntity(resource_locks)
+ with self.env() as rmanager:
+ calls = [('acquireResource', ('A', 'a', rm.LockType.shared), {})]
+ with guarded.operation_context((src, dst)):
+ self.assertEqual(calls, rmanager.__calls__)
+ calls.append(('releaseResource', ('A', 'a'), {}))
+
+ def test_sorting(self):
+ src_locks = [
+ guarded.ResourceManagerLock('C', 'a', rm.LockType.shared),
+ guarded.ResourceManagerLock('A', 'b', rm.LockType.shared),
+ ]
+ src = GuardedEntity(src_locks)
+ dst_locks = [
+ guarded.ResourceManagerLock('A', 'a', rm.LockType.shared),
+ guarded.ResourceManagerLock('B', 'a', rm.LockType.shared),
+ ]
+ dst = GuardedEntity(dst_locks)
+ with self.env() as rmanager:
+ calls = [
+ ('acquireResource', ('A', 'a', rm.LockType.shared), {}),
+ ('acquireResource', ('A', 'b', rm.LockType.shared), {}),
+ ('acquireResource', ('B', 'a', rm.LockType.shared), {}),
+ ('acquireResource', ('C', 'a', rm.LockType.shared), {}),
+ ]
+ with guarded.operation_context((src, dst)):
+ self.assertEqual(calls, rmanager.__calls__)
+ calls.extend([
+ ('releaseResource', ('C', 'a'), {}),
+ ('releaseResource', ('B', 'a'), {}),
+ ('releaseResource', ('A', 'b'), {}),
+ ('releaseResource', ('A', 'a'), {}),
+ ])
+ self.assertEqual(calls, rmanager.__calls__)
+
+ def test_resource_exclusive_and_shared(self):
+ locks = [guarded.ResourceManagerLock('A', 'a', rm.LockType.shared)]
+ src = GuardedEntity(locks)
+ locks = [guarded.ResourceManagerLock('A', 'a', rm.LockType.exclusive)]
+ dst = GuardedEntity(locks)
+ with self.env() as rmanager:
+ calls = [('acquireResource',
+ ('A', 'a', rm.LockType.exclusive), {}),
+ ('releaseResource', ('A', 'a'), {})]
+ with guarded.operation_context((src, dst)):
+ pass
+ self.assertEqual(calls, rmanager.__calls__)
+
+
+class GuardedEntity(guarded.Entity):
+
+ def __init__(self, rm_list):
+ self.rm_list = rm_list
+
+ def get_rm_locks(self):
+ return self.rm_list
+
+
+@expandPermutations
+class ResourceManagerLockTest(VdsmTestCase):
+
+ def test_acquire_release(self):
+ res_mgr = FakeResourceManager()
+
+ res = guarded.ResourceManagerLock('ns_A', 'name_A', rm.LockType.shared)
+ with MonkeyPatchScope([(guarded, 'rmanager', res_mgr)]):
+ expected = []
+ res.acquire()
+ expected.append(('acquireResource',
+ (res.ns, res.name, res.mode), {}))
+ self.assertEqual(expected, res_mgr.__calls__)
+ res.release()
+ expected.append(('releaseResource', (res.ns, res.name), {}))
+ self.assertEqual(expected, res_mgr.__calls__)
+
+ @permutations((
+ (('A', 'a', rm.LockType.shared), ('B', 'a', rm.LockType.shared)),
+ (('A', 'a', rm.LockType.shared), ('A', 'b', rm.LockType.shared)),
+ ))
+ def test_less_than(self, a, b):
+ b = guarded.ResourceManagerLock(*b)
+ a = guarded.ResourceManagerLock(*a)
+ self.assertLess(a, b)
+
+ def test_equal_with_different_mode(self):
+ a = guarded.ResourceManagerLock('A', 'a', rm.LockType.shared)
+ b = guarded.ResourceManagerLock('A', 'a', rm.LockType.exclusive)
+ self.assertEqual(a, b)
diff --git a/vdsm.spec.in b/vdsm.spec.in
index b5d4f67..9b95e98 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -1240,6 +1240,7 @@
%{python_sitelib}/%{vdsm_name}/storage/exception.py*
%{python_sitelib}/%{vdsm_name}/storage/fileUtils.py*
%{python_sitelib}/%{vdsm_name}/storage/fuser.py*
+%{python_sitelib}/%{vdsm_name}/storage/guarded.py*
%{python_sitelib}/%{vdsm_name}/storage/hba.py*
%{python_sitelib}/%{vdsm_name}/storage/misc.py*
%{python_sitelib}/%{vdsm_name}/storage/mount.py*
--
To view, visit https://gerrit.ovirt.org/61435
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b0a204818d44b6205515277f4c2834cb2b7a057
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: storage: Remove unneeded multipath call
by frolland@redhat.com
Hello Fred Rolland,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/59865
to review the following change.
Change subject: storage: Remove unneeded multipath call
......................................................................
storage: Remove unneeded multipath call
As part of multipath rescan, we call iscsi and hba rescan.
These operations are sufficient to discover new devices and
detect changes in size.
Therefore, the multipath call is not needed and can be removed
improving the overall performance of GetDeviceList verb.
Detailed profiling :
time filename:lineno(function)
3.178 |hsm.py:1948(HSM._getDeviceList)
1.546 |--> sdc.py:80(StorageDomainCache.refreshStorage)
1.489 |--> multipath.py:65(rescan)
0.481 |--> iscsi.py:431(rescan) iscsi scan
0.076 |--> storage/hba.py:53(rescan) fc scan
0.912 |--> multipath.py:88(multipath) multipath
0.056 |--> multipath.py:92(resize_devices)
0.756 |--> lvm.py:843(getAllPVs)
0.756 |--> lvm.py:317(LVMCache._reloadpvs)
0.755 |--> lvm.py:290(LVMCache.cmd) pvs
0.871 |--> multipath.py:213(pathListIter)
0.029 |-->devicemapper.py:176(getPathsStatus) dmsetup status
Change-Id: Ie99da5ad7ec46f4a69a3d09a811e875d5e3a5b44
Bug-Url: https://bugzilla.redhat.com/1303578
Signed-off-by: Fred Rolland <frolland(a)redhat.com>
---
M vdsm/storage/multipath.py
1 file changed, 0 insertions(+), 4 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/65/59865/1
diff --git a/vdsm/storage/multipath.py b/vdsm/storage/multipath.py
index 77c54a7..03fcb57 100644
--- a/vdsm/storage/multipath.py
+++ b/vdsm/storage/multipath.py
@@ -30,7 +30,6 @@
from collections import namedtuple
from vdsm import commands
-from vdsm import constants
from vdsm import supervdsm
from vdsm import udevadm
from vdsm import utils
@@ -73,9 +72,6 @@
# First rescan iSCSI and FCP connections
iscsi.rescan()
hba.rescan()
-
- # Now let multipath daemon pick up new devices
- misc.execCmd([constants.EXT_MULTIPATH], sudo=True)
# Scanning SCSI interconnects starts a storm of udev events. Wait until all
# events are processed, ensuring detection of new devices and creation or
--
To view, visit https://gerrit.ovirt.org/59865
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie99da5ad7ec46f4a69a3d09a811e875d5e3a5b44
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Freddy Rolland <frolland(a)redhat.com>
Gerrit-Reviewer: Fred Rolland <frolland(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: wip: py3: port storage misc.py file to python3
by igoihman@redhat.com
Irit Goihman has uploaded a new change for review.
Change subject: wip: py3: port storage misc.py file to python3
......................................................................
wip: py3: port storage misc.py file to python3
Change-Id: I1adec40146967965329024718c6ff48d0fa089fb
Signed-off-by: Irit Goihman <igoihman(a)redhat.com>
---
M lib/vdsm/storage/misc.py
1 file changed, 7 insertions(+), 7 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/01/60001/1
diff --git a/lib/vdsm/storage/misc.py b/lib/vdsm/storage/misc.py
index 173d608..162570e 100644
--- a/lib/vdsm/storage/misc.py
+++ b/lib/vdsm/storage/misc.py
@@ -33,7 +33,6 @@
import inspect
import logging
import os
-import Queue
import random
import re
import signal
@@ -46,7 +45,8 @@
from array import array
from collections import defaultdict
from functools import wraps, partial
-from itertools import chain, imap
+from itertools import chain
+from six.moves import queue, map, range
from vdsm import commands
from vdsm import concurrent
@@ -69,7 +69,7 @@
def namedtuple2dict(nt):
- return dict(imap(lambda f: (f, getattr(nt, f)), nt._fields))
+ return dict(map(lambda f: (f, getattr(nt, f)), nt._fields))
class _LogSkip(object):
@@ -95,7 +95,7 @@
def logskip(var):
- if isinstance(var, types.StringTypes):
+ if isinstance(var, (str,)):
return lambda func: _LogSkip.wrap(func, var)
return _LogSkip.wrap(var, None)
@@ -423,7 +423,7 @@
Raises InvalidParameterException if value is not a string or if it could
not be converted to integer.
"""
- if not isinstance(size, basestring):
+ if not isinstance(size, six.string_types):
log.error("Number of sectors as int is not supported, use size in "
"bytes as string")
raise se.InvalidParameterException("size", size)
@@ -669,7 +669,7 @@
if maxthreads < 1 and maxthreads != UNLIMITED_THREADS:
raise ValueError("Wrong input to function itmap: %s", maxthreads)
- respQueue = Queue.Queue()
+ respQueue = queue.Queue()
def wrapper(value):
try:
@@ -699,7 +699,7 @@
maxthreads -= 1
# waiting for rest threads to end
- for i in xrange(threadsCount):
+ for i in range(threadsCount):
yield respQueue.get()
--
To view, visit https://gerrit.ovirt.org/60001
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1adec40146967965329024718c6ff48d0fa089fb
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Irit Goihman <igoihman(a)redhat.com>
7 years, 7 months
Change in vdsm[ovirt-4.0]: ovs: add OVS bridges cleanup to shell_helper
by phoracek@redhat.com
Petr Horáček has uploaded a new change for review.
Change subject: ovs: add OVS bridges cleanup to shell_helper
......................................................................
ovs: add OVS bridges cleanup to shell_helper
Change-Id: I55addefb42550d88c83548ca31a94e40b7e47184
Bug-Url: https://bugzilla.redhat.com/1195208
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
---
M contrib/shell_helper
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/61688/1
diff --git a/contrib/shell_helper b/contrib/shell_helper
index 4b7cb77..77f8422 100755
--- a/contrib/shell_helper
+++ b/contrib/shell_helper
@@ -139,6 +139,12 @@
done
}
+del_ovs_bridges() {
+ for bridge in `sudo ovs-vsctl list-br | grep vdsmbr_`; do
+ sudo ovs-vsctl del-br $bridge
+ done
+}
+
del_test_nets() {
cat << EOF | sudo python -
from __future__ import print_function
@@ -188,6 +194,7 @@
del_veths
del_bonds
del_bridges
+ del_ovs_bridges
del_test_nets
del_net_persistency
}
--
To view, visit https://gerrit.ovirt.org/61688
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I55addefb42550d88c83548ca31a94e40b7e47184
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
7 years, 7 months
Change in vdsm[ovirt-4.0]: ovs: use Setup class directly
by phoracek@redhat.com
Hello Dan Kenigsberg, Edward Haas,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/61686
to review the following change.
Change subject: ovs: use Setup class directly
......................................................................
ovs: use Setup class directly
We will need access to Setup instance in netswitch.py with next
patch.
Change-Id: I2fa674f479d569356775812931c832ef37f1fe2a
Bug-Url: https://bugzilla.redhat.com/1195208
Signed-off-by: Petr Horáček <phoracek(a)redhat.com>
Reviewed-on: https://gerrit.ovirt.org/60405
Reviewed-by: Edward Haas <edwardh(a)redhat.com>
Continuous-Integration: Jenkins CI
Reviewed-by: Dan Kenigsberg <danken(a)redhat.com>
---
M lib/vdsm/network/netswitch.py
M lib/vdsm/network/ovs/switch.py
2 files changed, 11 insertions(+), 13 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/86/61686/1
diff --git a/lib/vdsm/network/netswitch.py b/lib/vdsm/network/netswitch.py
index cea7d76..9dbd4fd 100644
--- a/lib/vdsm/network/netswitch.py
+++ b/lib/vdsm/network/netswitch.py
@@ -155,8 +155,12 @@
nets2remove.update(nets2edit)
with Transaction(in_rollback=in_rollback) as config:
- ovs_switch.setup(_ovs_info, nets2add, nets2remove, bonds2add,
- bonds2edit, bonds2remove)
+ with ovs_switch.create_setup(_ovs_info) as s:
+ s.remove_nets(nets2remove)
+ s.remove_bonds(bonds2remove)
+ s.edit_bonds(bonds2edit)
+ s.add_bonds(bonds2add)
+ s.add_nets(nets2add)
_update_running_config(networks, bondings, config)
ovs_switch.cleanup()
_setup_ipv6autoconf(networks)
diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py
index 35ef72b..85fcb36 100644
--- a/lib/vdsm/network/ovs/switch.py
+++ b/lib/vdsm/network/ovs/switch.py
@@ -46,23 +46,17 @@
bond, attrs, nets, _netinfo['networks'], kernel_nics)
-def setup(ovs_info, nets2add, nets2remove, bonds2add, bonds2edit,
- bonds2remove):
- ovsdb = driver.create()
- with Setup(ovsdb, ovs_info) as s:
- s.remove_nets(nets2remove)
- s.remove_bonds(bonds2remove)
- s.edit_bonds(bonds2edit)
- s.add_bonds(bonds2add)
- s.add_nets(nets2add)
-
-
def cleanup():
ovsdb = driver.create()
with ovsdb.transaction() as t:
t.add(*_cleanup_unused_bridges(ovsdb))
+def create_setup(ovs_info):
+ ovsdb = driver.create()
+ return Setup(ovsdb, ovs_info)
+
+
# TODO: We could move all setup() code into __init__ and __exit__.
class Setup(object):
def __init__(self, ovsdb, ovs_info):
--
To view, visit https://gerrit.ovirt.org/61686
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2fa674f479d569356775812931c832ef37f1fe2a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: ovirt-4.0
Gerrit-Owner: Petr Horáček <phoracek(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Edward Haas <edwardh(a)redhat.com>
7 years, 7 months
Change in vdsm[master]: storage: Sortable ResourceManager lock namespaces
by alitke@redhat.com
Adam Litke has uploaded a new change for review.
Change subject: storage: Sortable ResourceManager lock namespaces
......................................................................
storage: Sortable ResourceManager lock namespaces
In order to simplify correct locking order, change the namespace constants so
that they sort in the order that they should be taken.
Change-Id: Icfd94f0152c08f6260ca93228fd4c4a792e72051
Signed-off-by: Adam Litke <alitke(a)redhat.com>
---
M lib/vdsm/storage/constants.py
M tests/storage_guarded_test.py
2 files changed, 24 insertions(+), 16 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/61436/1
diff --git a/lib/vdsm/storage/constants.py b/lib/vdsm/storage/constants.py
index e49c88e..9803b89 100644
--- a/lib/vdsm/storage/constants.py
+++ b/lib/vdsm/storage/constants.py
@@ -22,11 +22,12 @@
from vdsm import qemuimg
+
# ResourceManager Lock Namespaces
-STORAGE = "Storage"
-LVM_ACTIVATION_NAMESPACE = 'lvmActivationNS'
-IMAGE_NAMESPACE = 'imageNS'
-VOLUME_NAMESPACE = 'volumeNS'
+STORAGE = "00_Storage"
+LVM_ACTIVATION_NAMESPACE = '01_lvmActivationNS'
+IMAGE_NAMESPACE = '02_imageNS'
+VOLUME_NAMESPACE = '03_volumeNS'
SECTOR_SIZE = 512
VG_EXTENT_SIZE_MB = 128
diff --git a/tests/storage_guarded_test.py b/tests/storage_guarded_test.py
index 29db745..bf4371a 100644
--- a/tests/storage_guarded_test.py
+++ b/tests/storage_guarded_test.py
@@ -25,9 +25,11 @@
from storagefakelib import FakeResourceManager
from testlib import VdsmTestCase, expandPermutations, permutations
+from vdsm.storage import constants as sc
from vdsm.storage import guarded
from storage import resourceManager as rm
+from storage.resourceFactories import IMAGE_NAMESPACE
@expandPermutations
@@ -58,29 +60,34 @@
def test_sorting(self):
src_locks = [
- guarded.ResourceManagerLock('C', 'a', rm.LockType.shared),
- guarded.ResourceManagerLock('A', 'b', rm.LockType.shared),
+ guarded.ResourceManagerLock(IMAGE_NAMESPACE, 'a',
+ rm.LockType.shared),
+ guarded.ResourceManagerLock(sc.STORAGE, 'b',
+ rm.LockType.shared),
]
src = GuardedEntity(src_locks)
dst_locks = [
- guarded.ResourceManagerLock('A', 'a', rm.LockType.shared),
- guarded.ResourceManagerLock('B', 'a', rm.LockType.shared),
+ guarded.ResourceManagerLock(sc.STORAGE, 'a', rm.LockType.shared),
+ guarded.ResourceManagerLock(IMAGE_NAMESPACE, 'b',
+ rm.LockType.exclusive),
]
dst = GuardedEntity(dst_locks)
with self.env() as rmanager:
calls = [
- ('acquireResource', ('A', 'a', rm.LockType.shared), {}),
- ('acquireResource', ('A', 'b', rm.LockType.shared), {}),
- ('acquireResource', ('B', 'a', rm.LockType.shared), {}),
- ('acquireResource', ('C', 'a', rm.LockType.shared), {}),
+ ('acquireResource', (sc.STORAGE, 'a', rm.LockType.shared), {}),
+ ('acquireResource', (sc.STORAGE, 'b', rm.LockType.shared), {}),
+ ('acquireResource',
+ (IMAGE_NAMESPACE, 'a', rm.LockType.shared), {}),
+ ('acquireResource',
+ (IMAGE_NAMESPACE, 'b', rm.LockType.exclusive), {}),
]
with guarded.operation_context((src, dst)):
self.assertEqual(calls, rmanager.__calls__)
calls.extend([
- ('releaseResource', ('C', 'a'), {}),
- ('releaseResource', ('B', 'a'), {}),
- ('releaseResource', ('A', 'b'), {}),
- ('releaseResource', ('A', 'a'), {}),
+ ('releaseResource', (IMAGE_NAMESPACE, 'a'), {}),
+ ('releaseResource', (IMAGE_NAMESPACE, 'b'), {}),
+ ('releaseResource', (sc.STORAGE, 'b'), {}),
+ ('releaseResource', (sc.STORAGE, 'a'), {}),
])
self.assertEqual(calls, rmanager.__calls__)
--
To view, visit https://gerrit.ovirt.org/61436
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icfd94f0152c08f6260ca93228fd4c4a792e72051
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke(a)redhat.com>
7 years, 7 months