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 <[email protected]> --- 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 <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/admin/lists/[email protected]
