Yeela Kaplan has uploaded a new change for review. Change subject: Avoid prepare template by using unsafe qemu-img rebase ......................................................................
Avoid prepare template by using unsafe qemu-img rebase Change-Id: I959e49315b2539cdb9111edd1786590a22023907 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=979193 Signed-off-by: Yeela Kaplan <ykap...@redhat.com> --- M vdsm/storage/blockVolume.py M vdsm/storage/fileVolume.py M vdsm/storage/volume.py 3 files changed, 31 insertions(+), 40 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/93/18793/1 diff --git a/vdsm/storage/blockVolume.py b/vdsm/storage/blockVolume.py index effd3a5..c93a0b2 100644 --- a/vdsm/storage/blockVolume.py +++ b/vdsm/storage/blockVolume.py @@ -180,19 +180,9 @@ utils.rmFile(volPath) os.symlink(lvm.lvPath(dom.sdUUID, volUUID), volPath) - if not volParent: - cls.log.info("Request to create %s volume %s with size = %s " - "sectors", volume.type2name(volFormat), volPath, - size) - - if volFormat == volume.COW_FORMAT: - volume.createVolume(None, None, volPath, size, volFormat, - preallocate) - else: - # Create hardlink to template and its meta file - cls.log.info("Request to create snapshot %s/%s of volume %s/%s", - imgUUID, volUUID, srcImgUUID, srcVolUUID) - volParent.clone(imgPath, volUUID, volFormat, preallocate) + volume.Volume.createVolume(imgUUID, volUUID, size, volFormat, + preallocate, volParent, srcImgUUID, + srcVolUUID, imgPath, volPath) with cls._tagCreateLock: mdSlot = dom.mapMetaOffset(volUUID, VOLUME_MDNUMBLKS) diff --git a/vdsm/storage/fileVolume.py b/vdsm/storage/fileVolume.py index 4525b0e..614c7b1 100644 --- a/vdsm/storage/fileVolume.py +++ b/vdsm/storage/fileVolume.py @@ -145,19 +145,9 @@ cls.log.error("Unexpected error", exc_info=True) raise se.VolumesZeroingError(volPath) - if not volParent: - cls.log.info("Request to create %s volume %s with size = %s " - "sectors", volume.type2name(volFormat), volPath, - size) - - if volFormat == volume.COW_FORMAT: - volume.createVolume(None, None, volPath, size, volFormat, - preallocate) - else: - # Create hardlink to template and its meta file - cls.log.info("Request to create snapshot %s/%s of volume %s/%s", - imgUUID, volUUID, srcImgUUID, srcVolUUID) - volParent.clone(imgPath, volUUID, volFormat, preallocate) + volume.Volume.createVolume(imgUUID, volUUID, size, volFormat, + preallocate, volParent, srcImgUUID, + srcVolUUID, imgPath, volPath) # By definition the volume is a leaf cls.file_setrw(volPath, rw=True) diff --git a/vdsm/storage/volume.py b/vdsm/storage/volume.py index 928a3e7..1722b7f 100644 --- a/vdsm/storage/volume.py +++ b/vdsm/storage/volume.py @@ -249,12 +249,11 @@ self.setParent(backingVol) self.recheckIfLeaf() - def clone(self, dst_image_dir, dst_volUUID, volFormat, preallocate): + def clone(self, dstVolPath, volFormat, preallocate): """ - Clone self volume to the specified dst_image_dir/dst_volUUID + Clone self volume to the specified dstVolPath """ wasleaf = False - dst_path = None taskName = "parent volume rollback: " + self.volUUID vars.task.pushRecovery( task.Recovery(taskName, "volume", "Volume", @@ -264,27 +263,23 @@ wasleaf = True self.setInternal() try: - self.prepare(rw=False) - dst_path = os.path.join(dst_image_dir, dst_volUUID) self.log.debug("Volume.clone: %s to %s" % - (self.volumePath, dst_path)) + (self.volumePath, dstVolPath)) size = int(self.getMetaParam(SIZE)) parent = self.getVolumePath() parent_format = fmt2str(self.getFormat()) # We should use parent's relative path instead of full path parent = os.path.join(os.path.basename(os.path.dirname(parent)), os.path.basename(parent)) - createVolume(parent, parent_format, dst_path, - size, volFormat, preallocate) - self.teardown(self.sdUUID, self.volUUID) + _createVolume(parent, parent_format, dstVolPath, + size, volFormat, preallocate) except Exception as e: # FIXME: might race with other clones if wasleaf: self.setLeaf() - self.teardown(self.sdUUID, self.volUUID) self.log.error("Volume.clone: can't clone: %s to %s" % - (self.volumePath, dst_path)) - raise se.CannotCloneVolume(self.volumePath, dst_path, str(e)) + (self.volumePath, dstVolPath)) + raise se.CannotCloneVolume(self.volumePath, dstVolPath, str(e)) def _shareLease(self, dstImgPath): """ @@ -386,6 +381,21 @@ if preallocate not in VOL_TYPE: raise se.IncorrectType(type2name(preallocate)) + + @classmethod + def createVolume(cls, imgUUID, volUUID, size, volFmt, preallocate, + volParent, srcImgUUID, srcVolUUID, imgPath, volPath): + if not volParent: + cls.log.info("Request to create %s volume %s with size = %s " + "sectors", type2name(volFmt), volPath, size) + + if volFmt == COW_FORMAT: + _createVolume(None, None, volPath, size, volFmt, preallocate) + else: + # Create hardlink to template and its meta file + cls.log.info("Request to create snapshot %s/%s of volume %s/%s", + imgUUID, volUUID, srcImgUUID, srcVolUUID) + volParent.clone(volPath, volFmt, preallocate) @classmethod def create(cls, repoPath, sdUUID, imgUUID, size, volFormat, preallocate, @@ -997,7 +1007,7 @@ pass -def createVolume(parent, parent_format, volume, size, format, prealloc): +def _createVolume(parent, parent_format, volume, size, format, prealloc): """ --- Create new volume. 'parent' - backing volume name @@ -1036,7 +1046,8 @@ # cwd = os.path.split(os.path.split(volume)[0])[0] # Temporary fix for qemu-img creation problem - cmd += ["-F", parent_format, "-b", os.path.join("..", parent), volume] + cmd += ["-u", "-F", parent_format, "-b", os.path.join("..", parent), + volume] cwd = os.path.split(volume)[0] else: size = int(size) -- To view, visit http://gerrit.ovirt.org/18793 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I959e49315b2539cdb9111edd1786590a22023907 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Yeela Kaplan <ykap...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches