Skip to content

Commit dd478c2

Browse files
committed
Set global{locking_type=0} when running lvm2 commands
The lvm2 commands that sos issues are all read-only. Disable locking when running the commands to avoid blocking if another process or node is holding a lock. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
1 parent f42f767 commit dd478c2

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

sos/plugins/lvm2.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,24 @@ def do_lvmdump(self, metadata=False):
3838
self.add_cmd_output(cmd)
3939

4040
def setup(self):
41-
self.add_cmd_output("vgdisplay -vv", root_symlink = "vgdisplay")
41+
# use locking_type 0 (no locks) when running LVM2 commands, from lvm.conf:
42+
# Turn locking off by setting to 0 (dangerous: risks metadata corruption
43+
# if LVM2 commands get run concurrently).
44+
# None of the commands issued by sos ever modify metadata and this avoids
45+
# the possibility of hanging lvm commands when another process or node
46+
# holds a conflicting lock.
47+
lvm_opts = '--config="global{locking_type=0}"'
48+
49+
self.add_cmd_output(
50+
"vgdisplay -vv %s" % lvm_opts,
51+
root_symlink="vgdisplay"
52+
)
4253
self.add_cmd_outputs([
43-
"vgscan -vvv",
44-
"pvscan -v",
45-
"pvs -a -v",
46-
"vgs -v",
47-
"lvs -a -o +devices"
54+
"vgscan -vvv %s" % lvm_opts,
55+
"pvscan -v %s" % lvm_opts,
56+
"pvs -a -v %s" % lvm_opts,
57+
"vgs -v %s" % lvm_opts,
58+
"lvs -a -o +devices %s" % lvm_opts
4859
])
4960

5061
self.add_copy_spec("/etc/lvm")

0 commit comments

Comments
 (0)