Adam Litke has submitted this change and it was merged. 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 resourceManager locks and volume leases. The contextmanager accepts a variable number of lock lists where each list corresponds to the locks required to protect one element of the operation (eg. a source volume). Lists must contain only AbstractLock derived objects. All locks from all lists are aggregated and locked according to the rules. When exiting the context (or upon error) the locks are released in reverse order. If an exception was raised inside the context, that exception will be propagated regardless of any lock release failures that may occur. The following rules are currently enforced: - Locks are collected from all lists and sorted using namespace, name, and mode (in that order) - Due to namespace sorting, ResourceManager locks are taken before volume leases - Duplicate locks are removed (only when ns, name, and mode match) - Locks are acquired in sorted order and released in reverse order Change-Id: I2b0a204818d44b6205515277f4c2834cb2b7a057 Signed-off-by: Adam Litke <ali...@redhat.com> Reviewed-on: https://gerrit.ovirt.org/61435 Reviewed-by: Nir Soffer <nsof...@redhat.com> Continuous-Integration: Jenkins CI --- M lib/vdsm/storage/Makefile.am A lib/vdsm/storage/guarded.py M tests/Makefile.am A tests/storage_guarded_test.py M tests/storagetestlib.py M tests/storagetestlibTests.py M vdsm.spec.in 7 files changed, 428 insertions(+), 0 deletions(-) Approvals: Adam Litke: Verified Nir Soffer: Looks good to me, approved Jenkins CI: Passed CI tests -- To view, visit https://gerrit.ovirt.org/61435 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2b0a204818d44b6205515277f4c2834cb2b7a057 Gerrit-PatchSet: 16 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Adam Litke <ali...@redhat.com> Gerrit-Reviewer: Adam Litke <ali...@redhat.com> Gerrit-Reviewer: Freddy Rolland <froll...@redhat.com> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Liron Aravot <lara...@redhat.com> Gerrit-Reviewer: Nir Soffer <nsof...@redhat.com> Gerrit-Reviewer: gerrit-hooks <automat...@ovirt.org> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/admin/lists/vdsm-patches@lists.fedorahosted.org