Skip to content

Commit

Permalink
Revert "CP-27709: suppress error if blkdiscard fails on full provisio…
Browse files Browse the repository at this point in the history
…ned lun"

This reverts commit 47fabe7.
  • Loading branch information
MarkSymsCtx committed Nov 29, 2018
1 parent dbc9e54 commit b4d3ddc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 36 deletions.
25 changes: 1 addition & 24 deletions drivers/lvutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
#


import glob
import re
import os
import errno
import time

import util
import scsiutil
import xs_errors
import xml.dom.minidom
from lvhdutil import VG_LOCATION,VG_PREFIX
Expand All @@ -42,7 +40,6 @@
CMD_VGREMOVE = "vgremove"
CMD_VGCHANGE = "vgchange"
CMD_VGEXTEND = "vgextend"
CMD_VGDISPLAY = "vgdisplay"
CMD_PVS = "pvs"
CMD_PVCREATE = "pvcreate"
CMD_PVREMOVE = "pvremove"
Expand All @@ -67,7 +64,7 @@
DEF_LVM_CONF = '/etc/lvm'

VG_COMMANDS = frozenset({CMD_VGS, CMD_VGCREATE, CMD_VGREMOVE, CMD_VGCHANGE,
CMD_VGEXTEND, CMD_VGDISPLAY})
CMD_VGEXTEND})
PV_COMMANDS = frozenset({CMD_PVS, CMD_PVCREATE, CMD_PVREMOVE, CMD_PVRESIZE})
LV_COMMANDS = frozenset({CMD_LVS, CMD_LVDISPLAY, CMD_LVCREATE, CMD_LVREMOVE,
CMD_LVCHANGE, CMD_LVRENAME, CMD_LVRESIZE,
Expand Down Expand Up @@ -728,23 +725,3 @@ def removeDevMapperEntry(path, strict=True):
util.SMlog("removeDevMapperEntry: dmsetup remove failed for file %s " \
"with error %s, and lsof ret is %s." % (path, str(e), ret))
return False

def vgIsFullyProvisioned(vgname):
"""
Check the PVs behind the specified VG and return
True if any of them is fully provisioned
"""
text = cmd_lvm([CMD_VGDISPLAY, '-v', vgname])
for line in text.splitlines():
match = re.search(r'PV Name\s+(\S+)', line)
if match:
device = util.diskFromPartition(scsiutil.getdev(match.group(1)))

for path in glob.glob(
'/sys/block/%s/device/scsi_disk/*/provisioning_mode' %
(device)):
with open(path) as mode_file:
mode = mode_file.read().strip()
if mode == 'full':
return True
return False
5 changes: 3 additions & 2 deletions drivers/scsiutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,9 @@ def scsi_dev_ctrl(ids, cmd):
opterr='An error occured during the scsi operation')

def getdev(path):
if match_dm(path):
newpath = path.replace("/dev/mapper/","/dev/disk/by-id/scsi-")
realpath = os.path.realpath(path)
if match_dm(realpath):
newpath = realpath.replace("/dev/mapper/","/dev/disk/by-id/scsi-")
else:
newpath = path
return os.path.realpath(newpath).split('/')[-1]
Expand Down
15 changes: 5 additions & 10 deletions drivers/trim_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,11 @@ def do_trim(session, args):
util.SMlog("Trim on SR: %s complete. " % sr_uuid)
result = str(True)
except util.CommandException, e:
if (lvutil.vgIsFullyProvisioned(vg_name)):
util.SMlog(
"blkdiscard failed on fully provisioned lun, %s" % lv_path)
result = str(True)
else:
err_msg = {
ERROR_CODE_KEY: 'TrimException',
ERROR_MSG_KEY: e.reason
}
result = to_xml(err_msg)
err_msg = {
ERROR_CODE_KEY: 'TrimException',
ERROR_MSG_KEY: e.reason
}
result = to_xml(err_msg)
except:
err_msg = {
ERROR_CODE_KEY: 'UnknownTrimException',
Expand Down

0 comments on commit b4d3ddc

Please sign in to comment.