From 09603d4eaaf1fb8a2de4678ac302dff370d4e42c Mon Sep 17 00:00:00 2001 From: jackeichen Date: Tue, 9 Apr 2024 19:55:37 +0800 Subject: [PATCH 1/5] fix a bug when sas disk in jbod mode When connect the disk in JBOD mode, there will be no valid output to parse, fix it by check the output length --- pySMART/device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pySMART/device.py b/pySMART/device.py index 2a508cf..fe5215d 100644 --- a/pySMART/device.py +++ b/pySMART/device.py @@ -647,7 +647,7 @@ def _classify(self) -> str: '-l', 'sasphy', self.dev_reference]) - if returncode == 0 and 'SAS SSP' in raw[4]: + if returncode == 0 and len(raw) > 4 and 'SAS SSP' in raw[4]: fine_interface = 'sas' # Some older SAS devices do not support the SAS PHY log command. # For these, see if smartmontools reports a transport protocol. From bf7fb24b704109c29a0673843f13ee4e1a2885c5 Mon Sep 17 00:00:00 2001 From: Rafael Leira Date: Fri, 19 Apr 2024 16:54:42 +0200 Subject: [PATCH 2/5] Added testcase for #85 --- .../_-d_scsi_--all__dev_sdd | 52 +++ .../_-d_scsi_-l_background__dev_sdd | 6 + .../megaraid_jbod_sas_hdd_0/device.json | 369 ++++++++++++++++++ 3 files changed, 427 insertions(+) create mode 100644 tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_--all__dev_sdd create mode 100644 tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_-l_background__dev_sdd create mode 100644 tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_--all__dev_sdd b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_--all__dev_sdd new file mode 100644 index 0000000..94661cd --- /dev/null +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_--all__dev_sdd @@ -0,0 +1,52 @@ +smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-372.9.1.el8.x86_64] (local build) +Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org + +=== START OF INFORMATION SECTION === +Vendor: XXXXXXXXXXX +Product: XXXXXXXXXXX +Revision: CA00 +Compliance: SPC-5 +User Capacity: 800,166,076,416 bytes [800 GB] +Logical block size: 512 bytes +Physical block size: 4096 bytes +LU is resource provisioned, LBPRZ=1 +Rotation Rate: Solid State Device +Form Factor: 2.5 inches +Logical Unit id: 0x50025380725029b0 +Serial number: XXXXXXXXXXXXXXXX +Device type: disk +Transport protocol: SAS (SPL-3) +Local Time is: Tue Apr 9 08:02:36 2024 EDT +SMART support is: Available - device has SMART capability. +SMART support is: Enabled +Temperature Warning: Enabled + +=== START OF READ SMART DATA SECTION === +SMART Health Status: OK + +Percentage used endurance indicator: 0% +Current Drive Temperature: 42 C +Drive Trip Temperature: 65 C + +Manufactured in week 07 of year 2022 +Accumulated start-stop cycles: 135 +Specified load-unload count over device lifetime: 0 +Accumulated load-unload cycles: 0 +Elements in grown defect list: 0 + +Error counter log: + Errors Corrected by Total Correction Gigabytes Total + ECC rereads/ errors algorithm processed uncorrected + fast | delayed rewrites corrected invocations [10^9 bytes] errors +read: 0 0 0 0 0 27805.729 0 +write: 0 0 0 0 0 9378.908 0 +verify: 0 0 0 0 0 0.016 0 + +Non-medium error count: 84893 + +SMART Self-test log +Num Test Status segment LifeTime LBA_first_err [SK ASC ASQ] + Description number (hours) +# 1 Background short Completed - 349 - [- - -] + +Long (extended) Self-test duration: 3600 seconds [60.0 minutes] diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_-l_background__dev_sdd b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_-l_background__dev_sdd new file mode 100644 index 0000000..ffd4c27 --- /dev/null +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_-l_background__dev_sdd @@ -0,0 +1,6 @@ +smartctl 7.1 2019-12-30 r5022 [x86_64-linux-5.4.0-73-generic] (local build) +Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org + +=== START OF READ SMART DATA SECTION === +Device does not support Background scan results logging + diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json new file mode 100644 index 0000000..87f107e --- /dev/null +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json @@ -0,0 +1,369 @@ +{ + "interface": "scsi", + "name": "/dev/sdd", + "values": { + "abridged": false, + "assessment": "PASS", + "attributes": [ + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ], + "capacity": "800 GB", + "dev_interface": "sas", + "dev_reference": "/dev/sdd", + "diagnostics": { + "Corrected_Reads": 0, + "Corrected_Verifies": 0, + "Corrected_Writes": 0, + "Life_Left": 100, + "Load_Cycle_Count": 0, + "Load_Cycle_Pct_Left": null, + "Load_Cycle_Spec": 0, + "Non_Medium_Errors": null, + "Power_On_Hours": null, + "Reallocated_Sector_Ct": 0, + "Start_Stop_Cycles": 135, + "Start_Stop_Pct_Left": null, + "Start_Stop_Spec": null, + "_Reads_GB": 27805.729, + "_Reads_count": null, + "_Uncorrected_Reads": 0, + "_Uncorrected_Verifies": 0, + "_Uncorrected_Writes": 0, + "_Verifies_GB": 0.016, + "_Verifies_count": null, + "_Writes_GB": 9378.908, + "_Writes_count": null, + "_block_size": 512 + }, + "diags": { + "Corrected_Reads": "0", + "Corrected_Verifies": "0", + "Corrected_Writes": "0", + "Life_Left": "100%", + "Load_Cycle_Count": "0", + "Load_Cycle_Pct_Left": "-", + "Load_Cycle_Spec": "0", + "Non-Medium_Errors": "-", + "Power_On_Hours": "-", + "Reads_GB": "27805.729", + "Reads_count": "58312840183", + "Reallocated_Sector_Ct": "0", + "Start_Stop_Cycles": "135", + "Start_Stop_Pct_Left": "-", + "Start_Stop_Spec": "-", + "Uncorrected_Reads": "0", + "Uncorrected_Verifies": "0", + "Uncorrected_Writes": "0", + "Verifies_GB": "0.016", + "Verifies_count": "33554", + "Writes_GB": "9378.908", + "Writes_count": "19668995670", + "block_size": "512" + }, + "family": null, + "firmware": "CA00", + "if_attributes": null, + "interface": "scsi", + "is_ssd": true, + "logical_sector_size": 512, + "messages": [], + "model": "XXXXXXXXXXX", + "name": "sdd", + "physical_sector_size": 4096, + "rotation_rate": null, + "sector_size": 512, + "serial": "XXXXXXXXXXXXXXXX", + "size": 800166076416, + "size_raw": "800 GB", + "smart_capable": true, + "smart_enabled": true, + "smartctl_interface": "scsi", + "temperature": 42, + "temperatures": {}, + "test_capabilities": { + "conveyance": false, + "long": true, + "offline": false, + "selective": false, + "short": true + }, + "test_polling_time": { + "conveyance": 20, + "long": 1000, + "short": 10 + }, + "tests": [ + { + "asc": "-", + "ascq": "-", + "code": null, + "hours": "349", + "lba": "-", + "nsid": null, + "num": 1, + "remain": null, + "sct": null, + "segment": "-", + "sense": "-", + "status": "Completed", + "type": "Background short" + } + ], + "vendor": "XXXXXXXXXXX" + } +} \ No newline at end of file From 9cce6e2a7d1d75f02427541538fdfacac8a48d60 Mon Sep 17 00:00:00 2001 From: Rafael Leira Date: Fri, 19 Apr 2024 16:55:09 +0200 Subject: [PATCH 3/5] update changelog #85 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dcc976..b15f322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ Version 1.3.1 ============= - Added support for test polling_minutes. Requested in [#77](https://github.com/truenas/py-SMART/issues/77) and [#78](https://github.com/truenas/py-SMART/pull/78). Thanks @Gigahawk - Minnor typo fixed in NvmeAttributes (issue [#81](https://github.com/truenas/py-SMART/issues/81)). Thanks @petersulyok +- Minnor fix for JBOD devices (MR [#85](https://github.com/truenas/py-SMART/pull/85)). Thanks @jackeichen - **Breaking changes** - **smartctl.all**: - Officially removed support for python 3.7. From 61785a826077639b150b731d683d51638a6b75bd Mon Sep 17 00:00:00 2001 From: Rafael Leira Date: Fri, 19 Apr 2024 16:58:05 +0200 Subject: [PATCH 4/5] update #85 tests to the new test format --- .../megaraid_jbod_sas_hdd_0/device.json | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json index 87f107e..2922d6e 100644 --- a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json @@ -275,10 +275,19 @@ "Load_Cycle_Spec": 0, "Non_Medium_Errors": null, "Power_On_Hours": null, + "Reads_GB": 27805.729, + "Reads_count": 58312840183, "Reallocated_Sector_Ct": 0, "Start_Stop_Cycles": 135, "Start_Stop_Pct_Left": null, "Start_Stop_Spec": null, + "Uncorrected_Reads": 0, + "Uncorrected_Verifies": 0, + "Uncorrected_Writes": 0, + "Verifies_GB": 0.016, + "Verifies_count": 33554, + "Writes_GB": 9378.908, + "Writes_count": 19668995670, "_Reads_GB": 27805.729, "_Reads_count": null, "_Uncorrected_Reads": 0, @@ -288,7 +297,8 @@ "_Verifies_count": null, "_Writes_GB": 9378.908, "_Writes_count": null, - "_block_size": 512 + "_block_size": 512, + "block_size": 512 }, "diags": { "Corrected_Reads": "0", @@ -349,11 +359,12 @@ }, "tests": [ { - "asc": "-", - "ascq": "-", + "ASC": "-", + "ASCQ": "-", + "LBA": "-", + "_format": "scsi", "code": null, "hours": "349", - "lba": "-", "nsid": null, "num": 1, "remain": null, From 29b005781f48c076e9e66b8035c4d70ee5043055 Mon Sep 17 00:00:00 2001 From: Rafael Leira Date: Fri, 19 Apr 2024 17:22:09 +0200 Subject: [PATCH 5/5] trying to generalize test #85 --- .../_-d_scsi_--all__dev_sdd | 0 .../_-d_scsi_-l_background__dev_sdd | 0 .../_-d_scsi_-l_sasphy__dev_sdd | 4 ++++ .../megaraid_jbod_sas_hdd_0_issue_85/_-d_test__dev_sdd | 5 +++++ .../device.json | 1 - 5 files changed, 9 insertions(+), 1 deletion(-) rename tests/dataset/singletests/{megaraid_jbod_sas_hdd_0 => megaraid_jbod_sas_hdd_0_issue_85}/_-d_scsi_--all__dev_sdd (100%) rename tests/dataset/singletests/{megaraid_jbod_sas_hdd_0 => megaraid_jbod_sas_hdd_0_issue_85}/_-d_scsi_-l_background__dev_sdd (100%) create mode 100644 tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_-l_sasphy__dev_sdd create mode 100644 tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_test__dev_sdd rename tests/dataset/singletests/{megaraid_jbod_sas_hdd_0 => megaraid_jbod_sas_hdd_0_issue_85}/device.json (99%) diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_--all__dev_sdd b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_--all__dev_sdd similarity index 100% rename from tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_--all__dev_sdd rename to tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_--all__dev_sdd diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_-l_background__dev_sdd b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_-l_background__dev_sdd similarity index 100% rename from tests/dataset/singletests/megaraid_jbod_sas_hdd_0/_-d_scsi_-l_background__dev_sdd rename to tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_-l_background__dev_sdd diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_-l_sasphy__dev_sdd b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_-l_sasphy__dev_sdd new file mode 100644 index 0000000..fba5783 --- /dev/null +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_scsi_-l_sasphy__dev_sdd @@ -0,0 +1,4 @@ +smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-372.9.1.el8.x86_64] (local build) +Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org + +=== START OF READ SMART DATA SECTION === diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_test__dev_sdd b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_test__dev_sdd new file mode 100644 index 0000000..711d576 --- /dev/null +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/_-d_test__dev_sdd @@ -0,0 +1,5 @@ +smartctl 7.2 2021-01-17 r5171 [x86_64-linux-5.13.4-200.fc34.x86_64] (local build) +Copyright (C) 2002-20, Bruce Allen, Christian Franke, www.smartmontools.org + +/dev/sdd: Device of type 'scsi' [scsi] detected +/dev/sdd: Device of type 'scsi' [scsi] opened diff --git a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/device.json similarity index 99% rename from tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json rename to tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/device.json index 2922d6e..bcf82f3 100644 --- a/tests/dataset/singletests/megaraid_jbod_sas_hdd_0/device.json +++ b/tests/dataset/singletests/megaraid_jbod_sas_hdd_0_issue_85/device.json @@ -1,5 +1,4 @@ { - "interface": "scsi", "name": "/dev/sdd", "values": { "abridged": false,