[PATCH 5/6] Make an extra effort to remove dm partition nodes that want to stay.

David Lehman dlehman at redhat.com
Mon May 5 17:46:10 UTC 2014



On 05/02/2014 05:11 PM, Anne Mulhern wrote:
>
>
>
>
> ----- Original Message -----
>> From: "David Lehman" <dlehman at redhat.com>
>> To: anaconda-patches at lists.fedorahosted.org
>> Sent: Friday, May 2, 2014 1:03:42 PM
>> Subject: [PATCH 5/6] Make an extra effort to remove dm partition nodes that	want to stay.
>>
>> When running tests using disk image files it is a fairly regular
>> occurrence to find that dm device nodes for partitions are not removed
>> after removing the partition from the disk. lsof and fuser report
>> nothing, and kpartx -d doesn't think it has anything to do since the
>> partition table shows no partitions.
>>
>> The same happens when trying to deactivate them without having removed
>> them first.
>> ---
>>   blivet/devices.py | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/blivet/devices.py b/blivet/devices.py
>> index 79e6c53..8e192fc 100644
>> --- a/blivet/devices.py
>> +++ b/blivet/devices.py
>> @@ -1737,6 +1737,16 @@ class PartitionDevice(StorageDevice):
>>               self.disk.format.removePartition(part)
>>               self.disk.format.commit()
>>
>> +    def _postDestroy(self):
>> +        super(PartitionDevice, self)._postDestroy()
>> +        if isinstance(self.disk, DMDevice):
>> +            udev.udev_settle()
>> +            if self.status:
>> +                try:
>> +                    dm.dm_remove(self.name)
>> +                except (errors.DMError, OSError):
>> +                    pass
>> +
>>       def deactivate(self):
>>           """
>>           This is never called. For instructional purposes only.
>> @@ -1986,6 +1996,10 @@ class DMDevice(StorageDevice):
>>           if rc:
>>               raise errors.DMError("partition deactivation failed for '%s'" %
>>               self.name)
>>           udev.udev_settle()
>> +        for dev in os.listdir("/dev/mapper/"):
>> +            prefix = self.name + "p"
>> +            if dev.startswith(prefix) and dev[len(prefix):].isdigit():
>> +                util.run_program(["dmsetup", "remove", dev])
>>
>
> Probably it would be more proper to implement last line above in devicelibs.dm.

Switched it to call dm.dm_remove(dev) instead.


More information about the anaconda-patches mailing list