|
|
719f88 |
From 7ecf84e7958cd901b5190073afb6204f1d9c73e7 Mon Sep 17 00:00:00 2001
|
|
|
719f88 |
From: Gris Ge <fge@redhat.com>
|
|
|
719f88 |
Date: Fri, 8 Dec 2017 19:03:42 +0800
|
|
|
719f88 |
Subject: [PATCH 1/3] MegaRAID plugin: Fix cache information query.
|
|
|
719f88 |
|
|
|
719f88 |
* MegaRAID always enable read cache. Old code treat that as read ahead
|
|
|
719f88 |
cache which is not what we defined in API document.
|
|
|
719f88 |
|
|
|
719f88 |
* Fix the write cache set function to handle 'Cache I/O'.
|
|
|
719f88 |
|
|
|
719f88 |
* Inform user via volume_read_cache_policy_update(): read cache is
|
|
|
719f88 |
always enabled, if they are looking for read ahead cache setting, they
|
|
|
719f88 |
should use storcli/perccli.
|
|
|
719f88 |
|
|
|
719f88 |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
719f88 |
---
|
|
|
719f88 |
plugin/megaraid/megaraid.py | 77 ++++++++++++++++++++++++++++-----------------
|
|
|
719f88 |
1 file changed, 48 insertions(+), 29 deletions(-)
|
|
|
719f88 |
|
|
|
719f88 |
diff --git a/plugin/megaraid/megaraid.py b/plugin/megaraid/megaraid.py
|
|
|
719f88 |
index 8982ff9a..25b900da 100644
|
|
|
719f88 |
--- a/plugin/megaraid/megaraid.py
|
|
|
719f88 |
+++ b/plugin/megaraid/megaraid.py
|
|
|
719f88 |
@@ -1067,9 +1067,6 @@ def volume_cache_info(self, volume, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
sys_all_output = self._storcli_exec(
|
|
|
719f88 |
["/%s" % vd_path.split('/')[1], "show", "all"])
|
|
|
719f88 |
|
|
|
719f88 |
- write_cache_status = Volume.WRITE_CACHE_STATUS_WRITE_THROUGH
|
|
|
719f88 |
- read_cache_status = Volume.READ_CACHE_STATUS_DISABLED
|
|
|
719f88 |
-
|
|
|
719f88 |
ram_size = _mega_size_to_lsm(
|
|
|
719f88 |
sys_all_output['HwCfg'].get('On Board Memory Size', '0 KB'))
|
|
|
719f88 |
if ram_size > 0:
|
|
|
719f88 |
@@ -1081,36 +1078,42 @@ def volume_cache_info(self, volume, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
flag_battery_ok = True
|
|
|
719f88 |
|
|
|
719f88 |
lsi_cache_setting = vd_basic_info['Cache']
|
|
|
719f88 |
- if lsi_cache_setting[0] == 'R':
|
|
|
719f88 |
- read_cache_policy = Volume.READ_CACHE_POLICY_ENABLED
|
|
|
719f88 |
- if flag_has_ram:
|
|
|
719f88 |
- read_cache_status = Volume.READ_CACHE_STATUS_ENABLED
|
|
|
719f88 |
- elif lsi_cache_setting[0:2] == 'NR':
|
|
|
719f88 |
- read_cache_policy = Volume.READ_CACHE_POLICY_DISABLED
|
|
|
719f88 |
- else:
|
|
|
719f88 |
- raise LsmError(
|
|
|
719f88 |
- ErrorNumber.PLUGIN_BUG,
|
|
|
719f88 |
- "Unknown read cache %s for volume %s" %
|
|
|
719f88 |
- (lsi_cache_setting, vd_path))
|
|
|
719f88 |
+ # According to MegaRAID document, read I/O is always cached for direct
|
|
|
719f88 |
+ # I/O and cache I/O.
|
|
|
719f88 |
+ read_cache_policy = Volume.READ_CACHE_POLICY_ENABLED
|
|
|
719f88 |
+ write_cache_status = Volume.WRITE_CACHE_STATUS_WRITE_THROUGH
|
|
|
719f88 |
+ read_cache_status = Volume.READ_CACHE_STATUS_DISABLED
|
|
|
719f88 |
|
|
|
719f88 |
- if 'AWB' in lsi_cache_setting:
|
|
|
719f88 |
+ if lsi_cache_setting.endswith('D'):
|
|
|
719f88 |
+ # Direct I/O
|
|
|
719f88 |
+ if 'AWB' in lsi_cache_setting:
|
|
|
719f88 |
+ write_cache_policy = Volume.WRITE_CACHE_POLICY_WRITE_BACK
|
|
|
719f88 |
+ elif 'WB' in lsi_cache_setting:
|
|
|
719f88 |
+ write_cache_policy = Volume.WRITE_CACHE_POLICY_AUTO
|
|
|
719f88 |
+ elif 'WT' in lsi_cache_setting:
|
|
|
719f88 |
+ write_cache_policy = Volume.WRITE_CACHE_POLICY_WRITE_THROUGH
|
|
|
719f88 |
+ else:
|
|
|
719f88 |
+ raise LsmError(
|
|
|
719f88 |
+ ErrorNumber.PLUGIN_BUG,
|
|
|
719f88 |
+ "Unknown write cache %s for volume %s" %
|
|
|
719f88 |
+ (lsi_cache_setting, vd_path))
|
|
|
719f88 |
+ elif lsi_cache_setting.endswith('C'):
|
|
|
719f88 |
+ # cache I/O always caches write and read and ignore changes.
|
|
|
719f88 |
write_cache_policy = Volume.WRITE_CACHE_POLICY_WRITE_BACK
|
|
|
719f88 |
- if flag_has_ram:
|
|
|
719f88 |
- write_cache_status = Volume.WRITE_CACHE_STATUS_WRITE_BACK
|
|
|
719f88 |
- elif 'WB' in lsi_cache_setting:
|
|
|
719f88 |
- # This mode means enable write cache when battery or CacheVault
|
|
|
719f88 |
- # is healthy.
|
|
|
719f88 |
- write_cache_policy = Volume.WRITE_CACHE_POLICY_AUTO
|
|
|
719f88 |
- if flag_has_ram and flag_battery_ok:
|
|
|
719f88 |
- write_cache_status = Volume.WRITE_CACHE_STATUS_WRITE_BACK
|
|
|
719f88 |
- elif 'WT' in lsi_cache_setting:
|
|
|
719f88 |
- write_cache_policy = Volume.WRITE_CACHE_POLICY_WRITE_THROUGH
|
|
|
719f88 |
else:
|
|
|
719f88 |
raise LsmError(
|
|
|
719f88 |
ErrorNumber.PLUGIN_BUG,
|
|
|
719f88 |
- "Unknown write cache %s for volume %s" %
|
|
|
719f88 |
+ "Unknown I/O type %s for volume %s" %
|
|
|
719f88 |
(lsi_cache_setting, vd_path))
|
|
|
719f88 |
|
|
|
719f88 |
+ if flag_has_ram:
|
|
|
719f88 |
+ read_cache_status = Volume.READ_CACHE_STATUS_ENABLED
|
|
|
719f88 |
+ if write_cache_policy == Volume.WRITE_CACHE_POLICY_WRITE_BACK:
|
|
|
719f88 |
+ write_cache_status = Volume.WRITE_CACHE_STATUS_WRITE_BACK
|
|
|
719f88 |
+ elif write_cache_policy == Volume.WRITE_CACHE_POLICY_AUTO:
|
|
|
719f88 |
+ if flag_battery_ok:
|
|
|
719f88 |
+ write_cache_status = Volume.WRITE_CACHE_STATUS_WRITE_BACK
|
|
|
719f88 |
+
|
|
|
719f88 |
# TODO(Gris Ge): When 'Block SSD Write Disk Cache Change' of
|
|
|
719f88 |
# 'Supported Adapter Operations' is 'Yes'
|
|
|
719f88 |
lsi_disk_cache_setting = vd_prop_info['Disk Cache Policy']
|
|
|
719f88 |
@@ -1162,12 +1165,27 @@ def volume_write_cache_policy_update(self, volume, wcp,
|
|
|
719f88 |
"""
|
|
|
719f88 |
Depending on "storcli /c0/vX set wrcache=<wt|wb|awb>" command.
|
|
|
719f88 |
"""
|
|
|
719f88 |
- cmd = [_vd_path_of_lsm_vol(volume), "set"]
|
|
|
719f88 |
+ vd_path = _vd_path_of_lsm_vol(volume)
|
|
|
719f88 |
+ # Check whether we are working on cache I/O which ignore write cache
|
|
|
719f88 |
+ # setting and always cache write.
|
|
|
719f88 |
+ vol_show_output = self._storcli_exec([vd_path, "show", "all"])
|
|
|
719f88 |
+ vd_basic_info = vol_show_output[vd_path][0]
|
|
|
719f88 |
+ lsi_cache_setting = vd_basic_info['Cache']
|
|
|
719f88 |
+ if lsi_cache_setting.endswith('C'):
|
|
|
719f88 |
+ flag_cache_io = True
|
|
|
719f88 |
+ else:
|
|
|
719f88 |
+ flag_cache_io = False
|
|
|
719f88 |
+
|
|
|
719f88 |
+ cmd = [vd_path, "set"]
|
|
|
719f88 |
if wcp == Volume.WRITE_CACHE_POLICY_WRITE_BACK:
|
|
|
719f88 |
cmd.append("wrcache=awb")
|
|
|
719f88 |
elif wcp == Volume.WRITE_CACHE_POLICY_AUTO:
|
|
|
719f88 |
+ if flag_cache_io:
|
|
|
719f88 |
+ self._storcli_exec([vd_path, "set", "iopolicy=Direct"])
|
|
|
719f88 |
cmd.append("wrcache=wb")
|
|
|
719f88 |
elif wcp == Volume.WRITE_CACHE_POLICY_WRITE_THROUGH:
|
|
|
719f88 |
+ if flag_cache_io:
|
|
|
719f88 |
+ self._storcli_exec([vd_path, "set", "iopolicy=Direct"])
|
|
|
719f88 |
cmd.append("wrcache=wt")
|
|
|
719f88 |
else:
|
|
|
719f88 |
raise LsmError(ErrorNumber.PLUGIN_BUG,
|
|
|
719f88 |
@@ -1181,8 +1199,9 @@ def volume_read_cache_policy_update(self, volume, rcp,
|
|
|
719f88 |
storcli always enable read cache and no way to change it
|
|
|
719f88 |
"""
|
|
|
719f88 |
raise LsmError(ErrorNumber.NO_SUPPORT,
|
|
|
719f88 |
- "LSI MegaRAID always enable read cache and refused to "
|
|
|
719f88 |
- "change that.")
|
|
|
719f88 |
+ "MegaRAID always enable read cache and refused to "
|
|
|
719f88 |
+ "change that. You can change read ahead cache "
|
|
|
719f88 |
+ "setting via storcli/perccli")
|
|
|
719f88 |
|
|
|
719f88 |
@_handle_errors
|
|
|
719f88 |
def volume_delete(self, volume, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
|
|
|
719f88 |
From 9502647282e4ccb18aa41933cb8471c61240fa36 Mon Sep 17 00:00:00 2001
|
|
|
719f88 |
From: Gris Ge <fge@redhat.com>
|
|
|
719f88 |
Date: Fri, 8 Dec 2017 19:04:45 +0800
|
|
|
719f88 |
Subject: [PATCH 2/3] MegaRAID plugin: PEP8 clean up
|
|
|
719f88 |
|
|
|
719f88 |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
719f88 |
---
|
|
|
719f88 |
plugin/megaraid/megaraid.py | 6 ++++--
|
|
|
719f88 |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
719f88 |
|
|
|
719f88 |
diff --git a/plugin/megaraid/megaraid.py b/plugin/megaraid/megaraid.py
|
|
|
719f88 |
index 25b900da..c317c11d 100644
|
|
|
719f88 |
--- a/plugin/megaraid/megaraid.py
|
|
|
719f88 |
+++ b/plugin/megaraid/megaraid.py
|
|
|
719f88 |
@@ -85,6 +85,7 @@ def _disk_type_of(disk_show_basic_dict):
|
|
|
719f88 |
|
|
|
719f88 |
return Disk.TYPE_UNKNOWN
|
|
|
719f88 |
|
|
|
719f88 |
+
|
|
|
719f88 |
_DISK_STATE_MAP = {
|
|
|
719f88 |
'Onln': Disk.STATUS_OK,
|
|
|
719f88 |
'Offln': Disk.STATUS_ERROR,
|
|
|
719f88 |
@@ -409,7 +410,7 @@ def plugin_info(self, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
|
|
|
719f88 |
@_handle_errors
|
|
|
719f88 |
def time_out_set(self, ms, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
- self._tmo_ms = ms # TODO(Gris Ge): Not implemented yet.
|
|
|
719f88 |
+ self._tmo_ms = ms # TODO(Gris Ge): Not implemented yet.
|
|
|
719f88 |
|
|
|
719f88 |
@_handle_errors
|
|
|
719f88 |
def time_out_get(self, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
@@ -874,7 +875,8 @@ def _vcr_cap_get(self, mega_sys_path):
|
|
|
719f88 |
supported_strip_sizes = list(
|
|
|
719f88 |
min_strip_size * (2 ** i)
|
|
|
719f88 |
for i in range(
|
|
|
719f88 |
- 0, int(math.log(int_div(max_strip_size, min_strip_size), 2) + 1)))
|
|
|
719f88 |
+ 0, int(math.log(int_div(max_strip_size, min_strip_size), 2)
|
|
|
719f88 |
+ + 1)))
|
|
|
719f88 |
|
|
|
719f88 |
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
719f88 |
# The math above is to generate a list like:
|
|
|
719f88 |
|
|
|
719f88 |
From 0dd64bd71093cf480317251628f66bd4b99ca2a1 Mon Sep 17 00:00:00 2001
|
|
|
719f88 |
From: Gris Ge <fge@redhat.com>
|
|
|
719f88 |
Date: Fri, 8 Dec 2017 19:05:16 +0800
|
|
|
719f88 |
Subject: [PATCH 3/3] MegaRAID plugin: Be consistent on vd_path extraction.
|
|
|
719f88 |
|
|
|
719f88 |
* Always use _vd_path_of_lsm_vol() to extract private data to vd_path.
|
|
|
719f88 |
|
|
|
719f88 |
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
|
719f88 |
---
|
|
|
719f88 |
plugin/megaraid/megaraid.py | 2 +-
|
|
|
719f88 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
719f88 |
|
|
|
719f88 |
diff --git a/plugin/megaraid/megaraid.py b/plugin/megaraid/megaraid.py
|
|
|
719f88 |
index c317c11d..13c05b52 100644
|
|
|
719f88 |
--- a/plugin/megaraid/megaraid.py
|
|
|
719f88 |
+++ b/plugin/megaraid/megaraid.py
|
|
|
719f88 |
@@ -760,7 +760,7 @@ def volume_raid_info(self, volume, flags=Client.FLAG_RSVD):
|
|
|
719f88 |
ErrorNumber.INVALID_ARGUMENT,
|
|
|
719f88 |
"Ilegal input volume argument: missing plugin_data property")
|
|
|
719f88 |
|
|
|
719f88 |
- vd_path = volume.plugin_data
|
|
|
719f88 |
+ vd_path = _vd_path_of_lsm_vol(volume)
|
|
|
719f88 |
vol_show_output = self._storcli_exec([vd_path, "show", "all"])
|
|
|
719f88 |
vd_basic_info = vol_show_output[vd_path][0]
|
|
|
719f88 |
vd_id = int(vd_basic_info['DG/VD'].split('/')[-1])
|