From 7e2a2aa027a96bf71a48428c8821f1be3aec4c7c Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Thu, 22 Dec 2022 17:13:08 +1300 Subject: [PATCH] Reduce thin pool by one more extent The previous commit was tested on 2TB without issue, but testing on a very small volume (80GB) resulted in the thin pool lvextend failing for being one extent too large. This change reduces the pool size by one extent. Change-Id: I7ca002783f8f15946bc84af95eecaa097e70aaf1 Related: rhbz#2149586 --- .../elements/growvols/static/usr/local/sbin/growvols | 4 +++- .../elements/growvols/tests/test_growvols.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols b/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols index 0e5d4686d..0c3fdc0b6 100755 --- a/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols +++ b/diskimage_builder/elements/growvols/static/usr/local/sbin/growvols @@ -512,9 +512,11 @@ def main(argv): thin_pool = find_thin_pool(devices, group) if thin_pool: # total size available, reduced by POOL_METADATA_SIZE - # rounded down to whole extent + # rounded down to whole extent and reduced by 1 extent + # for metadata overhead size_bytes -= POOL_METADATA_SIZE size_bytes -= size_bytes % PHYSICAL_EXTENT_BYTES + size_bytes -= PHYSICAL_EXTENT_BYTES dev_path = '/dev/%s' % devname grow_vols = find_grow_vols(opts, devices, group, size_bytes) diff --git a/diskimage_builder/elements/growvols/tests/test_growvols.py b/diskimage_builder/elements/growvols/tests/test_growvols.py index db1f87c7d..b1622d646 100644 --- a/diskimage_builder/elements/growvols/tests/test_growvols.py +++ b/diskimage_builder/elements/growvols/tests/test_growvols.py @@ -601,13 +601,13 @@ class TestGrowvols(base.BaseTestCase): mock.call(['vgextend', 'vg', '/dev/sda5']), mock.call(['lvextend', '--poolmetadatasize', '+1073741824B', '/dev/mapper/vg-lv_thinpool', '/dev/sda5']), - mock.call(['lvextend', '-L+208331079680B', + mock.call(['lvextend', '-L+208326885376B', '/dev/mapper/vg-lv_thinpool', '/dev/sda5']), - mock.call(['lvextend', '--size', '+41666215936B', + mock.call(['lvextend', '--size', '+41662021632B', '/dev/mapper/vg-lv_home']), - mock.call(['lvextend', '--size', '+83332431872B', + mock.call(['lvextend', '--size', '+83328237568B', '/dev/mapper/vg-lv_var']), - mock.call(['lvextend', '--size', '+83332431872B', + mock.call(['lvextend', '--size', '+83336626176B', '/dev/mapper/vg-lv_root']), mock.call(['xfs_growfs', '/dev/mapper/vg-lv_home']), mock.call(['xfs_growfs', '/dev/mapper/vg-lv_var']),