This makes MultipathDevice.teardown() and PartitionDevice.teardown() work with the recursive teardownAll(). To do that, partitions actually have to tear down when they're on device-mapper maps, which is unlike real disks. --- storage/devices.py | 48 ++++++++++++++++++++++++++++-------------------- 1 files changed, 28 insertions(+), 20 deletions(-) diff --git a/storage/devices.py b/storage/devices.py index d9ff34a..796b01c 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -1314,6 +1314,21 @@ class PartitionDevice(StorageDevice): self.exists = False + def teardown(self, recursive=None): + """ Close, or tear down, a device. """ + log_method_call(self, self.name, status=self.status) + if not self.exists and not recursive: + raise DeviceError("device has not been created", self.name) + + if self.status: + if self.format.exists: + self.format.teardown() + devmap = block.getMap(major=self.major, minor=self.minor) + if devmap: + block.removeDeviceMap(devmap) + udev_settle() + StorageDevice.teardown(self, recursive=recursive) + def _getSize(self): """ Get the device's size. """ size = self._size @@ -2991,17 +3006,6 @@ class MultipathDevice(DMDevice): else: self.parents.append(parent) - def teardownPartitions(self): - log_method_call(self, name=self.name, kids=self.kids) - rc = iutil.execWithRedirect("kpartx", - ["-d", "-p", "p", "/dev/mapper/%s" % self.name], - stdout = "/dev/tty5", - stderr = "/dev/tty5") - if rc: - raise MPathError("multipath partition deactivation failed for '%s'"\ - % self.name) - udev_settle() - def setupPartitions(self): log_method_call(self, name=self.name, kids=self.kids) rc = iutil.execWithRedirect("kpartx", @@ -3027,15 +3031,19 @@ class MultipathDevice(DMDevice): raise DeviceError("device has not been created", self.name) if self.exists and os.path.exists(self.path): - self.teardownPartitions() - rc = iutil.execWithRedirect("multipath", - ['-f', self.name], - stdout = "/dev/tty5", - stderr = "/dev/tty5") - if rc: - raise MPathError("multipath deactivation failed for '%s'" % - self.name) - udev_settle() + #self.teardownPartitions() + #rc = iutil.execWithRedirect("multipath", + # ['-f', self.name], + # stdout = "/dev/tty5", + # stderr = "/dev/tty5") + #if rc: + # raise MPathError("multipath deactivation failed for '%s'" % + # self.name) + bdev = block.getDevice(self.name) + devmap = block.getMap(major=bdev[0], minor=bdev[1]) + if devmap.open_count: + return + block.removeDeviceMap(devmap) if recursive: self.teardownParents(recursive=recursive) -- 1.6.5.2 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list