Skip to content

Commit

Permalink
CA-387861 use 'devicemapper' for Fairlock exclusion resource name
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Smith <tim.smith@cloud.com>
  • Loading branch information
Tim Smith authored and TimSmithCtx committed May 7, 2024
1 parent 2eef1f6 commit 0ac8e84
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
14 changes: 7 additions & 7 deletions drivers/lvutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def cmd_lvm(cmd, pread_func=util.pread2, *args):
util.SMlog("CMD_LVM: Not all lvm arguments are of type 'str'")
return None

with Fairlock("multipath"):
with Fairlock("devicemapper"):
start_time = time.time()
stdout = pread_func([os.path.join(LVM_BIN, lvm_cmd)] + lvm_args, * args)
end_time = time.time()
Expand Down Expand Up @@ -653,7 +653,7 @@ def activateNoRefcount(path, refresh):
text = cmd_lvm([CMD_LVCHANGE, "--refresh", path])
mapperDevice = path[5:].replace("-", "--").replace("/", "-")
cmd = [CMD_DMSETUP, "table", mapperDevice]
with Fairlock("multipath"):
with Fairlock("devicemapper"):
ret = util.pread(cmd)
util.SMlog("DM table for %s: %s" % (path, ret.strip()))
# Restore slave mode lvm.conf
Expand Down Expand Up @@ -696,7 +696,7 @@ def _checkActive(path):
mapperDevice = path[5:].replace("-", "--").replace("/", "-")
cmd = [CMD_DMSETUP, "status", mapperDevice]
try:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
ret = util.pread2(cmd)
mapperDeviceExists = True
util.SMlog("_checkActive: %s: %s" % (mapperDevice, ret))
Expand Down Expand Up @@ -736,7 +736,7 @@ def _lvmBugCleanup(path):
cmd_rf = [CMD_DMSETUP, "remove", mapperDevice, "--force"]

try:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
util.pread(cmd_st, expect_rc=1)
except util.CommandException as e:
if e.code == 0:
Expand All @@ -752,14 +752,14 @@ def _lvmBugCleanup(path):
util.SMlog("_lvmBugCleanup: removing dm device %s" % mapperDevice)
for i in range(LVM_FAIL_RETRIES):
try:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
util.pread2(cmd_rm)
break
except util.CommandException as e:
if i < LVM_FAIL_RETRIES - 1:
util.SMlog("Failed on try %d, retrying" % i)
try:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
util.pread(cmd_st, expect_rc=1)
util.SMlog("_lvmBugCleanup: dm device {}"
" removed".format(mapperDevice)
Expand Down Expand Up @@ -804,7 +804,7 @@ def removeDevMapperEntry(path, strict=True):
if not strict:
cmd = [CMD_DMSETUP, "status", path]
try:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
util.pread(cmd, expect_rc=1)
return True
except:
Expand Down
6 changes: 3 additions & 3 deletions drivers/mpath_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __str__(self):

def mpexec(cmd):
util.SMlog("mpath cmd: %s" % cmd)
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(rc, stdout, stderr) = util.doexec(mpathcmd, cmd)
if stdout != "multipathd> ok\nmultipathd> " \
and stdout != "multipathd> " + cmd + "\nok\nmultipathd> ":
Expand Down Expand Up @@ -79,7 +79,7 @@ def is_working():

def do_get_topology(cmd):
util.SMlog("mpath cmd: %s" % cmd)
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(rc, stdout, stderr) = util.doexec(mpathcmd, cmd)
util.SMlog("mpath output: %s" % stdout)
lines = stdout.split('\n')[:-1]
Expand Down Expand Up @@ -112,7 +112,7 @@ def list_paths(scsi_id):
def list_maps():
cmd = "list maps"
util.SMlog("mpath cmd: %s" % cmd)
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(rc, stdout, stderr) = util.doexec(mpathcmd, cmd)
util.SMlog("mpath output: %s" % stdout)
return [x.split(' ')[0] for x in stdout.split('\n')[2:-1]]
Expand Down
14 changes: 7 additions & 7 deletions drivers/mpath_dmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _resetDMP(sid, explicit_unmap=False):
# tables. In that case, list_paths will return [], but remove_map might
# throw an exception. Catch it and ignore it.
if explicit_unmap:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
util.retry(lambda: util.pread2(['/usr/sbin/multipath', '-f', sid]),
maxretry=3, period=4)
util.retry(lambda: util.pread2(['/usr/sbin/multipath', '-W']), maxretry=3,
Expand Down Expand Up @@ -111,13 +111,13 @@ def refresh(sid, npaths):
def _is_valid_multipath_device(sid):

# Check if device is already multipathed
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-l', sid])
if not stdout + stderr:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-ll', sid])
if not stdout + stderr:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-a', sid])
if ret < 0:
util.SMlog("Failed to add {}: wwid could be explicitly "
Expand All @@ -136,7 +136,7 @@ def _is_valid_multipath_device(sid):
for dev in devs:
devpath = os.path.join(by_scsid_path, dev)
real_path = util.get_real_path(devpath)
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-c', real_path])
if ret == 0:
break
Expand All @@ -150,7 +150,7 @@ def _is_valid_multipath_device(sid):
if not stdout + stderr:
# Attempt to cleanup wwids file before raising
try:
with Fairlock("multipath"):
with Fairlock("devicemapper"):
(ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-w', sid])
except OSError:
util.SMlog("Error removing {} from wwids file".format(sid))
Expand All @@ -170,7 +170,7 @@ def _refresh_DMP(sid, npaths):
path = os.path.join(DEVMAPPERPATH, sid)
# If the mapper path doesn't exist force a reload in multipath
if not os.path.exists(path):
with Fairlock("multipath"):
with Fairlock("devicemapper"):
util.retry(lambda: util.pread2(['/usr/sbin/multipath', '-r', sid]), maxretry=3, period=4)
util.wait_for_path(path, 30)
if not os.path.exists(path):
Expand Down

0 comments on commit 0ac8e84

Please sign in to comment.