Skip to content

Commit

Permalink
Make sure factory target size is within the limits of the fstype.
Browse files Browse the repository at this point in the history
  • Loading branch information
dwlehman committed Jul 24, 2015
1 parent a5000d4 commit a800128
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion blivet/devicefactory.py
Expand Up @@ -383,6 +383,22 @@ def _get_free_disk_space(self):
free_info = self.storage.getFreeSpace(disks=self.disks)
return sum(d[0] for d in free_info.values())

def _normalize_size(self):
if self.size is None:
self._handle_no_size()

size = self.size
fmt = getFormat(self.fstype)
if size < fmt.minSize:
size = fmt.minSize
elif fmt.maxSize and size > fmt.maxSize:
size = fmt.maxSize

if self.size != size:
log.debug("adjusted size from %s to %s to honor format limits",
self.size, size)
self.size = size

def _handle_no_size(self):
""" Set device size so that it grows to the largest size possible. """
if self.size is not None:
Expand Down Expand Up @@ -812,7 +828,7 @@ def _configure(self):
if self.container and self.container.exists:
self.disks = self.container.disks

self._handle_no_size()
self._normalize_size()
self._set_up_child_factory()

# Configure any devices this device will use as building blocks, except
Expand Down

0 comments on commit a800128

Please sign in to comment.