if not track_idx:
log.warning("cannot lookup clone tracking index for {0}".format(clone_subvolume.base_path))
raise VolumeException(-errno.EINVAL, "error canceling clone")
- if SubvolumeOpSm.is_init_state(SubvolumeTypes.TYPE_CLONE, clone_state):
- # clone has not started yet -- cancel right away.
- self._cancel_pending_clone(fs_handle, clone_subvolume, clonename, groupname, status, track_idx)
- return
+ clone_job = (track_idx, clone_subvolume.base_path)
+ jobs = [j[0] for j in self.jobs[volname]]
+ with lock_timeout_log(self.lock):
+ if SubvolumeOpSm.is_init_state(SubvolumeTypes.TYPE_CLONE, clone_state) and not clone_job in jobs:
+ logging.debug("Cancelling pending job {0}".format(clone_job))
+ # clone has not started yet -- cancel right away.
+ self._cancel_pending_clone(fs_handle, clone_subvolume, clonename, groupname, status, track_idx)
+ return
# cancelling an on-going clone would persist "canceled" state in subvolume metadata.
# to persist the new state, async cloner accesses the volume in exclusive mode.
# accessing the volume in exclusive mode here would lead to deadlock.
canceled = False
log.info("canceling job {0} for volume {1}".format(job, volname))
try:
- if not volname in self.q and not volname in self.jobs and not job in self.jobs[volname]:
+ vol_jobs = [j[0] for j in self.jobs.get(volname, [])]
+ if not volname in self.q and not job in vol_jobs:
return canceled
for j in self.jobs[volname]:
if j[0] == job: