Skip to content

Commit

Permalink
Merge pull request #142 from dwlehman/7.2-cherry-picks
Browse files Browse the repository at this point in the history
7.2 cherry picks
  • Loading branch information
dwlehman committed Jun 2, 2015
2 parents 321107a + bff2198 commit 1a944d2
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 25 deletions.
5 changes: 0 additions & 5 deletions blivet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,11 +1223,6 @@ def newBTRFS(self, *args, **kwargs):

if kwargs.pop("subvol", False):
dev_class = BTRFSSubVolumeDevice
# make sure there's a valid parent device
parents = kwargs.get("parents", [])
if not parents or len(parents) != 1 or \
not isinstance(parents[0], BTRFSVolumeDevice):
raise ValueError("new btrfs subvols require a parent volume")

# set up the subvol name, using mountpoint if necessary
if not name:
Expand Down
35 changes: 24 additions & 11 deletions blivet/devicetree.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import pprint
import copy

from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError
from .errors import CryptoError, DeviceError, DeviceTreeError, DiskLabelCommitError, DMError, FSError, InvalidDiskLabelError, LUKSError, MDRaidError, StorageError, UnusableConfigurationError
from .devices import BTRFSDevice, BTRFSSubVolumeDevice, BTRFSVolumeDevice, BTRFSSnapShotDevice
from .devices import DASDDevice, DMDevice, DMLinearDevice, DMRaidArrayDevice, DiskDevice
from .devices import FcoeDiskDevice, FileDevice, LoopDevice, LUKSDevice
Expand Down Expand Up @@ -940,9 +940,16 @@ def addUdevPartitionDevice(self, info, disk=None):
# - devices that do not have a usable disklabel
# - devices that contain disklabels made by isohybrid
#
if (disk.partitionable and not
(disk.format.type == "iso9660" or disk.format.hidden)):
raise DeviceTreeError("failed to scan disk %s" % disk.name)
if disk.partitionable and \
disk.format.type != "iso9660" and \
not disk.format.hidden and \
not self._isIgnoredDisk(disk):
if info.get("ID_PART_TABLE_TYPE") == "gpt":
msg = "corrupt gpt disklabel on disk %s" % disk.name
else:
msg = "failed to scan disk %s" % disk.name

raise UnusableConfigurationError(msg)

# there's no need to filter partitions on members of multipaths or
# fwraid members from lvm since multipath and dmraid are already
Expand Down Expand Up @@ -1525,6 +1532,12 @@ def handleUdevLVMPVFormat(self, info, device):
if vg_device:
vg_device.parents.append(device)
else:
same_name = self.getDeviceByName(vg_name)
if isinstance(same_name, LVMVolumeGroupDevice) and \
not (all(self._isIgnoredDisk(d) for d in same_name.disks) or
all(self._isIgnoredDisk(d) for d in device.disks)):
raise UnusableConfigurationError("multiple LVM volume groups with the same name")

try:
vg_size = udev.device_get_vg_size(pv_info)
vg_free = udev.device_get_vg_free(pv_info)
Expand Down Expand Up @@ -2182,22 +2195,22 @@ def _populate(self):
if flags.installer_mode:
self.teardownAll()

def _hideIgnoredDisks(self):
def _is_ignored(disk):
return ((self.ignoredDisks and disk.name in self.ignoredDisks) or
(self.exclusiveDisks and
disk.name not in self.exclusiveDisks))
def _isIgnoredDisk(self, disk):
return ((self.ignoredDisks and disk.name in self.ignoredDisks) or
(self.exclusiveDisks and
disk.name not in self.exclusiveDisks))

def _hideIgnoredDisks(self):
# hide any subtrees that begin with an ignored disk
for disk in [d for d in self._devices if d.isDisk]:
if _is_ignored(disk):
if self._isIgnoredDisk(disk):
ignored = True
# If the filter allows all members of a fwraid or mpath, the
# fwraid or mpath itself is implicitly allowed as well. I don't
# like this very much but we have supported this usage in the
# past, so I guess we will support it forever.
if disk.parents and all(p.format.hidden for p in disk.parents):
ignored = any(_is_ignored(d) for d in disk.parents)
ignored = any(self._isIgnoredDisk(d) for d in disk.parents)

if ignored:
self.hide(disk)
Expand Down
4 changes: 4 additions & 0 deletions blivet/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ class DeviceTreeError(StorageError):
class DeviceNotFoundError(StorageError):
pass

class UnusableConfigurationError(StorageError):
""" User has an unusable initial storage configuration. """
pass

# DeviceAction
class DeviceActionError(StorageError):
pass
Expand Down
26 changes: 18 additions & 8 deletions blivet/partitioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,18 @@ def allocatePartitions(storage, disks, partitions, freespace):

continue

temp_part = addPartition(disklabel,
_free,
_part_type,
_part.req_size,
_part.req_start_sector,
_part.req_end_sector)
try:
temp_part = addPartition(disklabel,
_free,
_part_type,
_part.req_size,
_part.req_start_sector,
_part.req_end_sector)
except ArithmeticError as e:
log.debug("failed to allocate aligned partition "
"for growth test")
continue

_part.partedPartition = temp_part
_part.disk = _disk
temp_parts.append(_part)
Expand Down Expand Up @@ -1760,9 +1766,13 @@ def getDiskChunks(disk, partitions, free):
# also check that the resulting aligned geometry has a non-zero length.
# (It is possible that both will align to the same sector in a small
# enough region.)
al_start = disk.format.alignment.alignUp(f, f.start)
al_end = disk.format.endAlignment.alignDown(f, f.end)
if al_start >= al_end:
continue
geom = parted.Geometry(device=f.device,
start=disk.format.alignment.alignUp(f, f.start),
end=disk.format.endAlignment.alignDown(f, f.end))
start=al_start,
end=al_end)
if geom.length < disk.format.alignment.grainSize:
continue

Expand Down
14 changes: 13 additions & 1 deletion blivet/udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,19 @@ def device_is_biosraid_member(info):
return False

def device_get_dm_partition_disk(info):
return re.sub(r'p?\d*$', '', device_get_name(info))
if not device_is_dm_partition(info):
return None

disk = None
majorminor = info.get("ID_PART_ENTRY_DISK")
if majorminor:
major, minor = majorminor.split(":")
for device in get_devices():
if device.get("MAJOR") == major and device.get("MINOR") == minor:
disk = device_get_name(device)
break

return disk

def device_is_dm_partition(info):
return (device_is_dm(info) and
Expand Down

0 comments on commit 1a944d2

Please sign in to comment.