storage/v2: report aligned min size value

This commit is contained in:
Dan Bungert 2022-05-31 09:16:51 -06:00
parent 4d2d6455bf
commit 69b765efd5
2 changed files with 6 additions and 5 deletions

View File

@ -707,10 +707,12 @@ class Partition(_Formattable):
fs_data = self._m._probe_data.get('filesystem', {}).get(self._path()) fs_data = self._m._probe_data.get('filesystem', {}).get(self._path())
if fs_data is None: if fs_data is None:
return -1 return -1
val = fs_data.get('ESTIMATED_MIN_SIZE') val = fs_data.get('ESTIMATED_MIN_SIZE', -1)
if val == 0: if val == 0:
return self.device.alignment_data().part_align return self.device.alignment_data().part_align
return val if val == -1:
return -1
return align_up(val, self.device.alignment_data().part_align)
@property @property
def ok_for_raid(self): def ok_for_raid(self):

View File

@ -936,14 +936,13 @@ class TestPartitionTableEditing(TestAPI):
@timeout() @timeout()
async def test_est_min_size(self): async def test_est_min_size(self):
# load config, edit size, use that for server
cfg = self.machineConfig('examples/win10-along-ubuntu.json') cfg = self.machineConfig('examples/win10-along-ubuntu.json')
with cfg.edit() as data: with cfg.edit() as data:
fs = data['storage']['filesystem'] fs = data['storage']['filesystem']
fs['/dev/sda1']['ESTIMATED_MIN_SIZE'] = 0 fs['/dev/sda1']['ESTIMATED_MIN_SIZE'] = 0
# data file has no sda2 in filesystem # data file has no sda2 in filesystem
fs['/dev/sda3']['ESTIMATED_MIN_SIZE'] = -1 fs['/dev/sda3']['ESTIMATED_MIN_SIZE'] = -1
fs['/dev/sda4']['ESTIMATED_MIN_SIZE'] = 1 << 30 fs['/dev/sda4']['ESTIMATED_MIN_SIZE'] = (1 << 20) + 1
extra = ['--storage-version', '2'] extra = ['--storage-version', '2']
async with start_server(cfg, extra_args=extra) as inst: async with start_server(cfg, extra_args=extra) as inst:
@ -952,7 +951,7 @@ class TestPartitionTableEditing(TestAPI):
[p1, _, p3, p4, _] = sda['partitions'] [p1, _, p3, p4, _] = sda['partitions']
self.assertEqual(1 << 20, p1['estimated_min_size']) self.assertEqual(1 << 20, p1['estimated_min_size'])
self.assertEqual(-1, p3['estimated_min_size']) self.assertEqual(-1, p3['estimated_min_size'])
self.assertEqual(1 << 30, p4['estimated_min_size']) self.assertEqual(2 << 20, p4['estimated_min_size'])
class TestGap(TestAPI): class TestGap(TestAPI):