LVM: Use --readonly for lvs

We only need information about existence of
LVs, which is readable w/ --readonly.

This should perform better in general
and may help dodge the problem appearing in
bug #1901783.

This requires LVM 2.02.107+.

Related-Bug: #1901783
Change-Id: Ib2a6dac8d074decfbbba2ca8330714f80d2973c9
This commit is contained in:
Eric Harney 2021-01-06 10:15:31 -05:00
parent f19a92064a
commit 83e511e012
2 changed files with 4 additions and 3 deletions

View File

@ -297,7 +297,8 @@ class LVM(executor.Executor):
"""
cmd = LVM.LVM_CMD_PREFIX + ['lvs', '--noheadings', '--unit=g',
'-o', 'vg_name,name,size', '--nosuffix']
'-o', 'vg_name,name,size', '--nosuffix',
'--readonly']
if lv_name is not None and vg_name is not None:
cmd.append("%s/%s" % (vg_name, lv_name))
elif vg_name is not None:

View File

@ -95,12 +95,12 @@ class BrickLvmTestCase(test.TestCase):
data += " fake-vg-3:10.00:10.00:0:"\
"mXzbuX-dKpG-Rz7E-xtKY-jeju-QsYU-SLG8Z3\n"
elif (_lvm_prefix + 'lvs, --noheadings, '
'--unit=g, -o, vg_name,name,size, --nosuffix, '
'--unit=g, -o, vg_name,name,size, --nosuffix, --readonly, '
'fake-vg/lv-nothere' in cmd_string):
raise processutils.ProcessExecutionError(
stderr="One or more specified logical volume(s) not found.")
elif (_lvm_prefix + 'lvs, --noheadings, '
'--unit=g, -o, vg_name,name,size, --nosuffix, '
'--unit=g, -o, vg_name,name,size, --nosuffix, --readonly, '
'fake-vg/lv-newerror' in cmd_string):
raise processutils.ProcessExecutionError(
stderr="Failed to find logical volume \"fake-vg/lv-newerror\"")