]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/volumes/fs/operations/lock.py
f5c022935e8faf0b5dccf0a0f8d1bd78738ee974
1 from contextlib
import contextmanager
2 from threading
import Lock
3 from typing
import Dict
5 # singleton design pattern taken from http://www.aleax.it/5ep.html
7 class GlobalLock(object):
9 Global lock to serialize operations in mgr/volumes. This lock
10 is currently held when accessing (opening) a volume to perform
11 group/subvolume operations. Since this is a big lock, it's rather
12 inefficient -- but right now it's ok since mgr/volumes does not
13 expect concurrent operations via its APIs.
15 As and when features get added (such as clone, where mgr/volumes
16 would maintain subvolume states in the filesystem), there might
17 be a need to allow concurrent operations. In that case it would
18 be nice to implement an efficient path based locking mechanism.
20 See: https://people.eecs.berkeley.edu/~kubitron/courses/cs262a-F14/projects/reports/project6_report.pdf
28 with self
._shared
_state
['lock']:
29 if not self
._shared
_state
['init']:
30 self
._shared
_state
['init'] = True
31 # share this state among all instances
32 self
.__dict
__ = self
._shared
_state
36 with self
._shared
_state
['lock']: