Change in vdsm[master]: clusterlock: add the local locking implementation
danken at redhat.com
danken at redhat.com
Thu Jan 24 14:00:14 UTC 2013
Dan Kenigsberg has posted comments on this change.
Change subject: clusterlock: add the local locking implementation
......................................................................
Patch Set 3: I would prefer that you didn't submit this
(5 inline comments)
....................................................
File vdsm/storage/clusterlock.py
Line 132: class SANLockInit(object):
Line 133: def __init__(self, sdUUID, idsPath, leasesPath):
Line 134: self._sdUUID = sdUUID
Line 135: self._idsPath = idsPath
Line 136: self._leasesPath = leasesPath
I don't see why it's not just a little function, initSanlock(sdUUID, idsPath, leasesPath) or something like that.
Line 137:
Line 138: def initLock(self):
Line 139: try:
Line 140: sanlock.init_lockspace(self._sdUUID, self._idsPath)
Line 140: sanlock.init_lockspace(self._sdUUID, self._idsPath)
Line 141: sanlock.init_resource(self._sdUUID, SDM_LEASE_NAME,
Line 142: [(self._leasesPath, SDM_LEASE_OFFSET)])
Line 143: except sanlock.SanlockException:
Line 144: self.log.warn("Cannot initialize clusterlock", exc_info=True)
self.log never defined.
Line 145: raise se.ClusterLockInitError()
Line 146:
Line 147:
Line 148: class SANLock(object):
Line 307:
Line 308: if lockFile:
Line 309: try:
Line 310: fcntl.fcntl(lockFile, fcntl.F_GETFD)
Line 311: except IOError as e:
handle EINTR (rare, but painful)
Line 312: # We found a stale file descriptor, removing.
Line 313: del self._globalLockMap[self._sdUUID]
Line 314:
Line 315: # Raise any other unkown error.
Line 322:
Line 323: lockFile = misc.safe_open(self._idsPath, os.O_RDONLY)
Line 324:
Line 325: try:
Line 326: fcntl.flock(lockFile, fcntl.LOCK_EX | fcntl.LOCK_NB)
do we really want to flock with self._globalLockMapSync taken? it means that one LocalSD can starve others.
Line 327: except IOError as e:
Line 328: misc.safe_close(lockFile)
Line 329: if e.errno in (os.errno.EACCES, os.errno.EAGAIN):
Line 330: raise se.AcquireLockFailure(
....................................................
File vdsm/storage/misc.py
Line 1469: fl = fcntl.fcntl(fd, fcntl.F_GETFL)
Line 1470: fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
Line 1471:
Line 1472:
Line 1473: def safe_open(path, flags):
nice. so you may want a safe_flock for completeness.
Line 1474: while True:
Line 1475: try:
Line 1476: fd = os.open(path, flags)
Line 1477: except IOError as e:
--
To view, visit http://gerrit.ovirt.org/10282
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I106618a9a61cc96727edaf2e3ab043b2ec28ebe1
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Ayal Baron <abaron at redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Federico Simoncelli <fsimonce at redhat.com>
Gerrit-Reviewer: Maor Lipchuk <mlipchuk at redhat.com>
Gerrit-Reviewer: Saggi Mizrahi <smizrahi at redhat.com>
Gerrit-Reviewer: Vered Volansky <vvolansk at redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server
More information about the vdsm-patches
mailing list