Skip to content

Commit

Permalink
Add lvm2 version check to pass the --fs flag along
Browse files Browse the repository at this point in the history
Signed-off-by: Brooklyn Dewolf <[email protected]>
  • Loading branch information
BrooklynDewolf committed May 23, 2024
1 parent d206f0b commit edefdc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/vdsm/osinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def package_versions():
'qemu-kvm': ('qemu-kvm', 'qemu-kvm-rhev', 'qemu-kvm-ev'),
'spice-server': ('spice-server',),
'vdsm': ('vdsm',),
'lvm2': ('lvm2', 'lvm2-libs'),
}

if glusterEnabled:
Expand Down
13 changes: 13 additions & 0 deletions lib/vdsm/storage/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

from vdsm import constants
from vdsm import utils
from vdsm import osinfo
from vdsm.common import commands
from vdsm.common import errors
from vdsm.common import logutils
Expand Down Expand Up @@ -240,6 +241,15 @@ def __getattr__(self, attrName):
USE_DEVICES = config.get("lvm", "config_method").lower() == "devices"


def _get_lvm_version():
packages = osinfo.package_versions()
lvm_version = tuple(
int(v)
for v in packages['lvm2']['version'].split('.')
)
return lvm_version


def _prepare_device_set(devs):
devices = set(d.strip() for d in chain(devs, USER_DEV_LIST))
devices.discard('')
Expand Down Expand Up @@ -1781,12 +1791,15 @@ def extendLV(vgName, lvName, size_mb, refresh=True):


def reduceLV(vgName, lvName, size_mb, force=False):
lvm_version = _get_lvm_version()
log.info("Reducing LV %s/%s to %s megabytes (force=%s)",
vgName, lvName, size_mb, force)
cmd = ("lvreduce",) + LVM_NOBACKUP
if force:
cmd += ("--force",)
cmd += ("--size", "%sm" % (size_mb,), "%s/%s" % (vgName, lvName))
if lvm_version >= (2, 3, 17):
cmd += ("--fs",)

try:
_lvminfo.run_command(cmd, devices=_lvminfo._getVGDevs((vgName,)))
Expand Down

0 comments on commit edefdc6

Please sign in to comment.