Example #1
0
File: FileSR.py Project: xcp-ng/sm
    def _kickGC(self):
        # don't bother if an instance already running (this is just an
        # optimization to reduce the overhead of forking a new process if we
        # don't have to, but the process will check the lock anyways)
        lockRunning = Lock(cleanup.LOCK_TYPE_RUNNING, self.uuid)
        if not lockRunning.acquireNoblock():
            if cleanup.should_preempt(self.session, self.uuid):
                util.SMlog(
                    "Aborting currently-running coalesce of garbage VDI")
                try:
                    if not cleanup.abort(self.uuid, soft=True):
                        util.SMlog("The GC has already been scheduled to "
                                   "re-start")
                except util.CommandException as e:
                    if e.code != errno.ETIMEDOUT:
                        raise
                    util.SMlog('failed to abort the GC')
                finally:
                    return
            else:
                util.SMlog("A GC instance already running, not kicking")
                return
        else:
            lockRunning.release()

        util.SMlog("Kicking GC")
        cleanup.gc(self.session, self.uuid, True)
Example #2
0
    def _kickGC(self):
        # don't bother if an instance already running (this is just an 
        # optimization to reduce the overhead of forking a new process if we 
        # don't have to, but the process will check the lock anyways)
        lockRunning = Lock(cleanup.LOCK_TYPE_RUNNING, self.uuid) 
        if not lockRunning.acquireNoblock():
            if cleanup.should_preempt(self.session, self.uuid):
                util.SMlog("Aborting currently-running coalesce of garbage VDI")
                cleanup.abort(self.uuid)
            else:
                util.SMlog("A GC instance already running, not kicking")
                return
        else:
            lockRunning.release()

        util.SMlog("Kicking GC")
        cleanup.gc(self.session, self.uuid, True)
    def _kickGC(self):
        # don't bother if an instance already running (this is just an
        # optimization to reduce the overhead of forking a new process if we
        # don't have to, but the process will check the lock anyways)
        lockRunning = Lock(cleanup.LOCK_TYPE_RUNNING, self.uuid)
        if not lockRunning.acquireNoblock():
            if cleanup.should_preempt(self.session, self.uuid):
                util.SMlog(
                    "Aborting currently-running coalesce of garbage VDI")
                cleanup.abort(self.uuid)
            else:
                util.SMlog("A GC instance already running, not kicking")
                return
        else:
            lockRunning.release()

        util.SMlog("Kicking GC")
        cleanup.gc(self.session, self.uuid, True)
Example #4
0
File: FileSR.py Project: falaa/sm
                        util.SMlog("The GC has already been scheduled to "
                                "re-start")
                except util.CommandException, e:
                    if e.code != errno.ETIMEDOUT:
                        raise
                    util.SMlog('failed to abort the GC')
                finally:
                    return
            else:
                util.SMlog("A GC instance already running, not kicking")
                return
        else:
            lockRunning.release()

        util.SMlog("Kicking GC")
        cleanup.gc(self.session, self.uuid, True)

    def _isbind(self):
        # os.path.ismount can't deal with bind mount
        st1 = os.stat(self.path)
        st2 = os.stat(self.remotepath)
        return st1.st_dev == st2.st_dev and st1.st_ino == st2.st_ino

    def _checkmount(self):
        mount_path = self.path
        if self.handles("cifs"):
            mount_path = self.mountpoint

        return util.ioretry(lambda: util.pathexists(mount_path) and \
                                (util.ismount(mount_path) or \
                                 util.pathexists(self.remotepath) and self._isbind()))
Example #5
0
                        util.SMlog("The GC has already been scheduled to "
                                "re-start")
                except util.CommandException, e:
                    if e.code != errno.ETIMEDOUT:
                        raise
                    util.SMlog('failed to abort the GC')
                finally:
                    return
            else:
                util.SMlog("A GC instance already running, not kicking")
                return
        else:
            lockRunning.release()

        util.SMlog("Kicking GC")
        cleanup.gc(self.session, self.uuid, True)

    def _isbind(self):
        # os.path.ismount can't deal with bind mount
        st1 = os.stat(self.path)
        st2 = os.stat(self.remotepath)
        return st1.st_dev == st2.st_dev and st1.st_ino == st2.st_ino

    def _checkmount(self):
        mount_path = self.path
        if self.handles("smb"):
            mount_path = self.mountpoint

        return util.ioretry(lambda: util.pathexists(mount_path) and \
                                (util.ismount(mount_path) or \
                                 util.pathexists(self.remotepath) and self._isbind()))