changes suggested in review
This commit is contained in:
parent
65a961be1a
commit
0141defa01
|
@ -119,7 +119,7 @@ def verify_size_ok(level, sizes):
|
||||||
print("exactly right!")
|
print("exactly right!")
|
||||||
r = True
|
r = True
|
||||||
else:
|
else:
|
||||||
print("underestimated size by", real_size - calc_size)
|
print("subiquity wasted space", real_size - calc_size)
|
||||||
r = True
|
r = True
|
||||||
finally:
|
finally:
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
|
@ -235,8 +235,10 @@ DEFAULT_CHUNK = 512
|
||||||
# devices vary, which is not normal but also not something we prevent).
|
# devices vary, which is not normal but also not something we prevent).
|
||||||
#
|
#
|
||||||
# All this is tested against reality in ./scripts/get-raid-sizes.py
|
# All this is tested against reality in ./scripts/get-raid-sizes.py
|
||||||
def calculate_data_offset(devsize):
|
def calculate_data_offset_bytes(devsize):
|
||||||
devsize >>= 9 # convert to sectors
|
# Convert to sectors to make it easier to compare this code to mdadm's (we
|
||||||
|
# convert back at the end)
|
||||||
|
devsize >>= 9
|
||||||
|
|
||||||
devsize = align_down(devsize, DEFAULT_CHUNK)
|
devsize = align_down(devsize, DEFAULT_CHUNK)
|
||||||
|
|
||||||
|
@ -260,9 +262,8 @@ def calculate_data_offset(devsize):
|
||||||
"get_raid_size: adjusting for %s sectors of overhead", data_offset)
|
"get_raid_size: adjusting for %s sectors of overhead", data_offset)
|
||||||
data_offset = align_up(data_offset, 2*1024)
|
data_offset = align_up(data_offset, 2*1024)
|
||||||
|
|
||||||
data_offset <<= 9 # convert back to bytes
|
# convert back to bytes
|
||||||
|
return data_offset << 9
|
||||||
return data_offset
|
|
||||||
|
|
||||||
|
|
||||||
def raid_device_sort(devices):
|
def raid_device_sort(devices):
|
||||||
|
@ -277,7 +278,7 @@ def get_raid_size(level, devices):
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
return 0
|
return 0
|
||||||
devices = raid_device_sort(devices)
|
devices = raid_device_sort(devices)
|
||||||
data_offset = calculate_data_offset(devices[0].size)
|
data_offset = calculate_data_offset_bytes(devices[0].size)
|
||||||
sizes = [align_down(dev.size - data_offset) for dev in devices]
|
sizes = [align_down(dev.size - data_offset) for dev in devices]
|
||||||
min_size = min(sizes)
|
min_size = min(sizes)
|
||||||
if min_size <= 0:
|
if min_size <= 0:
|
||||||
|
|
Loading…
Reference in New Issue