Skip to content

Commit

Permalink
[IMP] In some case, we might want to keep some lvm active
Browse files Browse the repository at this point in the history
Signed-off-by: Cyril VINH-TUNG <[email protected]>
  • Loading branch information
cvinh committed Jun 25, 2024
1 parent 4d11cae commit 8acac94
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/vdsm/common/config.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,11 @@ parameters = [
'are either "filter" or "devices". Filter method will use LVM '
'filter, while device will use LVM devices file. The default '
'value is "devices".'),

('keep_active', '',
'In some case, you might want to keep active some lvm. You can list'
'them here separated with "comma".'
'For instance "/dev/vg1/lv1,/dev/vg1/lv2..."'),
]),

# Section: [sanlock]
Expand Down
8 changes: 8 additions & 0 deletions lib/vdsm/storage/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def __getattr__(self, attrName):

USE_DEVICES = config.get("lvm", "config_method").lower() == "devices"

KEEPACTIVE = [lvm for lvm in config.get("lvm", "keep_active").split(",")
if lvm is not None]


def _get_lvm_version():
packages = osinfo.package_versions()
Expand Down Expand Up @@ -1162,8 +1165,10 @@ def deactivateUnusedLVs(vgname, skiplvs=()):
# List prepared images LVs if any
pattern = "{}/{}/*/*".format(sc.P_VDSM_STORAGE, vgname)
prepared = frozenset(os.path.basename(n) for n in glob.iglob(pattern))
keep_active_lvs = KEEPACTIVE

for lv in _lvminfo.getAllLvs(vgname):
completelvname = "/dev/" + vgname + "/" + lv.name
if lv.active:
if lv.name in skiplvs:
log.debug("Skipping active lv: vg=%s lv=%s",
Expand All @@ -1174,6 +1179,9 @@ def deactivateUnusedLVs(vgname, skiplvs=()):
elif lv.opened:
log.debug("Skipping open lv: vg=%s lv=%s", vgname,
lv.name)
elif completelvname in keep_active_lvs:
log.debug("Skipping KEEPACTIVE lv: vg=%s lv=%s", vgname,
lv.name)
else:
deactivate.append(lv.name)

Expand Down

0 comments on commit 8acac94

Please sign in to comment.