From b817f6de8cd05bd923cf8b7694d2c9f3e306f2a5 Mon Sep 17 00:00:00 2001 From: Philip Guyton Date: Fri, 6 Jul 2018 18:59:23 +0100 Subject: [PATCH] missing validation - megaraid custom smart option raid dev target #1942 Adds previously missing '/dev/sd[a-z]' raid target device regex. This type of device is a valid target for megaraid, aacraid, and hpt drivers. Summary: - Add /dev/sd[a-z] regex (as above). - Add code comments for the above. - Add convenience raid target device regex of 'autodev': explicitly substitutes current disk by-id name (full path). Considered more robust than the above 'hard wired' device name option. - Enhance custom S.M.A.R.T options pre-processor, get_dev_options(), to handle the above 2 additional raid target device options. - Document the 'autodev' option on the "Add drive specific custom S.M.A.R.T options" page. - Improve / correct html formatting on the "Add drive specific custom S.M.A.R.T options" page. --- .../js/templates/disk/smartcustom_disks.jst | 10 ++++++---- .../static/storageadmin/js/views/smartcustom_disks.js | 4 +++- src/rockstor/system/smart.py | 10 +++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/rockstor/storageadmin/static/storageadmin/js/templates/disk/smartcustom_disks.jst b/src/rockstor/storageadmin/static/storageadmin/js/templates/disk/smartcustom_disks.jst index 4f055671e..c5cc09d6a 100644 --- a/src/rockstor/storageadmin/static/storageadmin/js/templates/disk/smartcustom_disks.jst +++ b/src/rockstor/storageadmin/static/storageadmin/js/templates/disk/smartcustom_disks.jst @@ -2,13 +2,15 @@

Please see the Smartmontools manual page for smartctl for possible custom options.

-
  • For smartmontools supported USB attached devices, ie USB to SATA adapters, please see: For smartmontools supported USB attached devices, ie USB to SATA adapters, please see: USB Device Support. -

  • -
  • For smartmontools supported RAID controllers please see: +

  • For smartmontools supported RAID controllers please see: Checking disks behind RAID controllers. -

  • +
    Note: 'autodev' option for hpt, megaraid, and aacraid to replace /dev/sdX parameter, JBOD assumed. + +

    This is an advanced option that is only required in specific circumstances. Please follow the above links to understand any options you choose to enter.

    Note: Supported smart options are -d to specify special devices and -T to set diff --git a/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js b/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js index 791204554..2d2f0819e 100644 --- a/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js +++ b/src/rockstor/storageadmin/static/storageadmin/js/views/smartcustom_disks.js @@ -81,7 +81,9 @@ SmartcustomDiskView = RockstorLayoutView.extend({ // Areca sata /dev/sg[2-9] but for hpahcisr and hpsa drivers /dev/sg[0-9]* (lsscsi -g to help) // so we still have an issue there. // HP Smart array with cciss driver uses /dev/cciss/c[0-9]d0 - var raidTargetRegExp = [/\/dev\/tw[e|a|l][0-9][0-5]{0,1}$/, /\/dev\/sg[0-9]$/, /\/dev\/cciss\/c[0-9]d0$/]; + // HighPoint RocketRaid SATA RAID controller (hpt), LSI MegaRAID SAS RAID controller Dell PERC 5/i,6/i controller (megaraid) + // and Adaptec SAS RAID controller (​aacraid) all expect /dev/sd[a-z] type raid device targets. + var raidTargetRegExp = [/\/dev\/tw[e|a|l][0-9][0-5]{0,1}$/, /\/dev\/sg[0-9]$/, /\/dev\/cciss\/c[0-9]d0$/, /\/dev\/sd[a-z]$/, /autodev$/]; // Initial cascade of syntactic checks. if (smartcustom_options.length == 0) { // allow zero length (empty) entry to remove existing options diff --git a/src/rockstor/system/smart.py b/src/rockstor/system/smart.py index 560894b29..a9e276fa3 100644 --- a/src/rockstor/system/smart.py +++ b/src/rockstor/system/smart.py @@ -414,9 +414,17 @@ def get_dev_options(dev_byid, custom_options=''): # TODO: think this ascii should be utf-8 as that's kernel standard # TODO: or just use str(custom_options).split() dev_options = custom_options.encode('ascii').split() + # Remove Rockstor native 'autodev' custom smart option raid dev target. + # As we automatically add the full path by-id if a raid controller + # target dev is not found, we can simply remove this option. + # N.B. here we assume there is either 'autodev' or a specified target: + # input validation was tested to reject both being entered. + if 'autodev' in dev_options: + dev_options.remove('autodev') # If our custom options don't contain a raid controller target then add # the full path to our base device as our last device specific option. - if (re.search('/dev/tw|/dev/cciss/c|/dev/sg', custom_options) is None): + if (re.search('/dev/tw|/dev/cciss/c|/dev/sg|/dev/sd', + custom_options) is None): # add full path to our custom options as we see no raid target dev dev_options += [ get_device_path(get_base_device_byid(dev_byid, TESTMODE))