[PATCH] Create partitions with exactly the geometry we calculate.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If we use the device constraint as before, libparted will
align the start and end to a cylinder boundary which, on
my disks, means a granularity of 7MB. Not good enough.

Plus, for mdraid we need >= 1% variation in size between
members of an array. We can get this with cylinder-aligned
partitions, but we'll have to do the alignment ourselves
and continue to use exact constraints.
---
 storage/devices.py      |    6 ++----
 storage/partitioning.py |   11 ++++++++---
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/storage/devices.py b/storage/devices.py
index be604f5..713449b 100644
--- a/storage/devices.py
+++ b/storage/devices.py
@@ -723,14 +723,12 @@ class DiskDevice(StorageDevice):
                                                              part.geometry))
 
         geometry = device.partedPartition.geometry
-        # XXX at some point we need to improve precision of non-grow sizes
-        #constraint = parted.Constraint(exactGeom=geometry,
-        #                               device=self.partedDisk.device)
+        constraint = parted.Constraint(exactGeom=geometry)
         partition = parted.Partition(disk=self.partedDisk,
                                      type=device.partedPartition.type,
                                      geometry=geometry)
         self.partedDisk.addPartition(partition,
-                                     constraint=self.partedDisk.device.getConstraint())
+                                     constraint=constraint)
 
     def probe(self):
         """ Probe for any missing information about this device.
diff --git a/storage/partitioning.py b/storage/partitioning.py
index 7cad2f3..c104401 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -507,6 +507,10 @@ def doPartitioning(storage, exclusiveDisks=None):
         disks = [d for d in disks if d.name in exclusiveDisks]
 
     partitions = storage.partitions
+    for part in partitions:
+        if not part.exists:
+            # start over with flexible-size requests
+            part.req_size = part.req_base_size
 
     # FIXME: isn't there a better place for this to happen?
     try:
@@ -698,18 +702,19 @@ def allocatePartitions(disks, partitions):
 
         # create minimum geometry for this request
         # req_size is in MB
+        sectors_per_track = disk.device.biosGeometry[2]
         length = (_part.req_size * (1024 * 1024)) / sectorSize
         new_geom = parted.Geometry(device=disk.device,
-                                   start=free.start,
+                                   start=max(sectors_per_track, free.start),
                                    length=length)
 
         # create the partition and add it to the disk
         partition = parted.Partition(disk=disk,
                                      type=part_type,
                                      geometry=new_geom)
+        constraint = parted.Constraint(exactGeom=new_geom)
         disk.addPartition(partition=partition,
-                          constraint=disk.device.getConstraint())
-#                          constraint=parted.Constraint(device=disk.device))
+                          constraint=constraint)
         log.debug("created partition %s of %dMB and added it to %s" % (partition.getDeviceNodeName(), partition.getSize(), disk))
 
         # this one sets the name
-- 
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux