Bug 429028

Summary: SMART status not available for all hard drives
Product: [Applications] partitionmanager Reporter: Nathan Kinney <nakinney>
Component: generalAssignee: Andrius Štikonas <andrius>
Status: RESOLVED FIXED    
Severity: minor CC: nate, zawertun
Priority: NOR    
Version: 4.2.0   
Target Milestone: ---   
Platform: Manjaro   
OS: Linux   
Latest Commit: Version Fixed In: 21.04
Attachments: Screenshot
Output of sudo smartctl --all --json /dev/sdc
attachment-31212-0.html
plasma-disks info center
attachment-29622-0.html
kpmcore-20.12.3-fix-exit-code-check.patch

Description Nathan Kinney 2020-11-12 18:46:23 UTC
Created attachment 133264 [details]
Screenshot

SUMMARY
The SMART status for my two of my 14TB Western Digital (WD141KRYZ) drives is grayed out. The two drive that that are grayed out have UDMA_CRC_Error_Count errors that were caused by bad SATA cables, but have since been fixed. Partition Manager won't show the status, but gnome-disk-utility 3.38.0 will. So does smartctl command line. 

STEPS TO REPRODUCE
1. Open KDE Partition Manager
2. Select /dev/sdc or /dev/sdd (both WD141KRYZ) 
3. Right click to open context menu
4. SMART status is grayed out on these two drives

OBSERVED RESULT
Not able to get SMART status within KDE Partition Manager

EXPECTED RESULT
SMART status to work

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Manjaro 20.2
(available in About System)
KDE Plasma Version: 5.20.2
KDE Frameworks Version: 5.75.0
Qt Version: 5.15.1

ADDITIONAL INFORMATION

[nakinney@linuxnas ~]$ sudo sfdisk -l
Disk /dev/nvme0n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: Patriot P300 256GB                      
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 84513481-04A5-7149-B1C3-12E2EACBC9C1

Device             Start       End   Sectors   Size Type
/dev/nvme0n1p1      4096    618495    614400   300M EFI System
/dev/nvme0n1p2    618496 356258346 355639851 169.6G Linux filesystem
/dev/nvme0n1p3 356258347 500103449 143845103  68.6G Linux swap


Disk /dev/nvme1n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: Patriot P300 256GB                      
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5F5AE912-649A-2546-900A-72CC14850CDE

Device         Start       End   Sectors   Size Type
/dev/nvme1n1p1  2048 500103167 500101120 238.5G Linux filesystem


Disk /dev/sda: 12.73 TiB, 14000519643136 bytes, 27344764928 sectors
Disk model: WDC WD141KRYZ-01
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 35C472A3-1A9D-1A4C-901E-E72B25FA8B5E

Device           Start         End     Sectors  Size Type
/dev/sda1         2048 27344746495 27344744448 12.7T Solaris /usr & Apple ZFS
/dev/sda9  27344746496 27344762879       16384    8M Solaris reserved 1


Disk /dev/sdb: 12.73 TiB, 14000519643136 bytes, 27344764928 sectors
Disk model: WDC WD141KRYZ-01
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 5AC753CD-086F-C045-9805-7CAE1BEB5F68

Device           Start         End     Sectors  Size Type
/dev/sdb1         2048 27344746495 27344744448 12.7T Solaris /usr & Apple ZFS
/dev/sdb9  27344746496 27344762879       16384    8M Solaris reserved 1


Disk /dev/sdc: 12.73 TiB, 14000519643136 bytes, 27344764928 sectors
Disk model: WDC WD141KRYZ-01
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 142970D1-CF47-4D4B-B569-FA3F9D40E066

Device           Start         End     Sectors  Size Type
/dev/sdc1         2048 27344746495 27344744448 12.7T Solaris /usr & Apple ZFS
/dev/sdc9  27344746496 27344762879       16384    8M Solaris reserved 1


Disk /dev/sdd: 12.73 TiB, 14000519643136 bytes, 27344764928 sectors
Disk model: WDC WD141KRYZ-01
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 6D2BC394-A346-5745-BCC6-18E30F903C43

Device           Start         End     Sectors  Size Type
/dev/sdd1         2048 27344746495 27344744448 12.7T Solaris /usr & Apple ZFS
/dev/sdd9  27344746496 27344762879       16384    8M Solaris reserved 1


Disk /dev/loop0: 97.7 MiB, 102445056 bytes, 200088 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 274 MiB, 287309824 bytes, 561152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0e50079d

Device       Boot Start    End Sectors  Size Id Type
/dev/loop1p1 *       64 561151  561088  274M  0 Empty
/dev/loop1p2        708   6403    5696  2.8M ef EFI (FAT-12/16/32)


Disk /dev/loop2: 55.32 MiB, 58007552 bytes, 113296 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 97.74 MiB, 102486016 bytes, 200168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop4: 55.36 MiB, 58052608 bytes, 113384 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Comment 1 Andrius Štikonas 2020-11-12 18:51:05 UTC
Can you please attach
smartctl --all --json /dev/sdc

Without that output I can't really tell anything at all.
Comment 2 Nathan Kinney 2020-11-12 19:03:57 UTC
Created attachment 133265 [details]
Output of sudo smartctl --all --json /dev/sdc

Andrius Štikonas <bugzilla_noreply@kde.org> requested the output.
Comment 3 Nathan Kinney 2020-11-12 19:07:23 UTC
Created attachment 133266 [details]
attachment-31212-0.html

I've added the output as an attachment to the bug report.

Thanks for looking into it.

On Thu, Nov 12, 2020 at 10:51 AM Andrius Štikonas <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=429028
>
> --- Comment #1 from Andrius Štikonas <andrius@stikonas.eu> ---
> Can you please attach
> smartctl --all --json /dev/sdc
>
> Without that output I can't really tell anything at all.
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 4 Andrius Štikonas 2020-11-12 19:44:00 UTC
> I've added the output as an attachment to the bug report.
> 
> Thanks for looking into it.
> 

Thanks for attaching it. I haven't really looked at it much yet. And wouldn't have much time during workdays anyway. Maybe over weekend...
Comment 5 Nate Graham 2020-11-13 15:15:55 UTC
Does plasma-disks (accessible in Info Center) show SMART status for these drives?
Comment 6 Nathan Kinney 2020-11-13 21:37:11 UTC
Created attachment 133317 [details]
plasma-disks info center
Comment 7 Nathan Kinney 2020-11-13 21:38:27 UTC
Created attachment 133318 [details]
attachment-29622-0.html

The SMART status does show for these disks in Info Center.

On Fri, Nov 13, 2020 at 7:15 AM Nate Graham <bugzilla_noreply@kde.org>
wrote:

> https://bugs.kde.org/show_bug.cgi?id=429028
>
> Nate Graham <nate@kde.org> changed:
>
>            What    |Removed                     |Added
>
> ----------------------------------------------------------------------------
>                  CC|                            |nate@kde.org
>
> --- Comment #5 from Nate Graham <nate@kde.org> ---
> Does plasma-disks (accessible in Info Center) show SMART status for these
> drives?
>
> --
> You are receiving this mail because:
> You reported the bug.
Comment 8 Andrius Štikonas 2020-11-13 22:11:08 UTC
(In reply to Nathan Kinney from comment #6)
> Created attachment 133317 [details]
> plasma-disks info center

Thanks for confirming this (even though I expected plasma disks to work).

I guess it's a bug in parsing json structures that are returned by smartctl.
Comment 9 Yaroslav Sidlovsky 2021-03-17 10:58:16 UTC
Same bug.
For 1 of my drives smartctl returns non 0 exit status.
Because exit status of smartctl is not simple success or failure report but a bitfield.

Citation from the man:
```
EXIT STATUS
The exit statuses of smartctl are defined by a bitmask.  If all is well with the disk, the  exit  status  (return  value)  of
smartctl  is  0  (all bits turned off).  If a problem occurs, or an error, potential error, or fault is detected, then a non-
zero status is returned.  In this case, the eight different bits in the exit status  have  the  following  meanings  for  ATA
disks; some of these values may also be returned for SCSI disks.

Bit 0: Command line did not parse.

Bit 1: Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode (see '-n' op‐
tion above).

Bit 2: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure (see  '-b'
option above).

Bit 3: SMART status check returned "DISK FAILING".

Bit 4: We found prefail Attributes <= threshold.

Bit 5: SMART  status  check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <= threshold at
some time in the past.

Bit 6: The device error log contains records of errors.

Bit 7: The device self-test log contains records of errors.  [ATA only] Failed self-tests outdated by a newer successful  ex‐
tended self-test are ignored.
```

And I see exitstatus 64 for /dev/sdb & partition manager traits this as error.
(see this check: https://invent.kde.org/system/kpmcore/-/blob/ad35460628f82c5025f7e5600b6d15cfcdf75d42/src/core/smartparser.cpp#L120).
Comment 10 Andrius Štikonas 2021-03-17 11:12:24 UTC
(In reply to Yaroslav Sidlovsky from comment #9)
> Same bug.
> For 1 of my drives smartctl returns non 0 exit status.
> Because exit status of smartctl is not simple success or failure report but
> a bitfield.
> 
> Citation from the man:
> ```
> EXIT STATUS
> The exit statuses of smartctl are defined by a bitmask.  If all is well with
> the disk, the  exit  status  (return  value)  of
> smartctl  is  0  (all bits turned off).  If a problem occurs, or an error,
> potential error, or fault is detected, then a non-
> zero status is returned.  In this case, the eight different bits in the exit
> status  have  the  following  meanings  for  ATA
> disks; some of these values may also be returned for SCSI disks.
> 
> Bit 0: Command line did not parse.
> 
> Bit 1: Device open failed, device did not return an IDENTIFY DEVICE
> structure, or device is in a low-power mode (see '-n' op‐
> tion above).
> 
> Bit 2: Some SMART or other ATA command to the disk failed, or there was a
> checksum error in a SMART data structure (see  '-b'
> option above).
> 
> Bit 3: SMART status check returned "DISK FAILING".
> 
> Bit 4: We found prefail Attributes <= threshold.
> 
> Bit 5: SMART  status  check returned "DISK OK" but we found that some (usage
> or prefail) Attributes have been <= threshold at
> some time in the past.
> 
> Bit 6: The device error log contains records of errors.
> 
> Bit 7: The device self-test log contains records of errors.  [ATA only]
> Failed self-tests outdated by a newer successful  ex‐
> tended self-test are ignored.
> ```
> 
> And I see exitstatus 64 for /dev/sdb & partition manager traits this as
> error.
> (see this check:
> https://invent.kde.org/system/kpmcore/-/blob/
> ad35460628f82c5025f7e5600b6d15cfcdf75d42/src/core/smartparser.cpp#L120).

Thanks for looking into this. Now it makes sense why it fails.
Comment 11 Yaroslav Sidlovsky 2021-03-17 11:32:49 UTC
Created attachment 136781 [details]
kpmcore-20.12.3-fix-exit-code-check.patch

Proposed patch. Or we can just try to parse JSON and if output is not JSON - fail?
Comment 12 Andrius Štikonas 2021-03-17 12:35:06 UTC
(In reply to Yaroslav Sidlovsky from comment #11)
> Created attachment 136781 [details]
> kpmcore-20.12.3-fix-exit-code-check.patch
> 
> Proposed patch. Or we can just try to parse JSON and if output is not JSON -
> fail?

This should work but can you submit it via merge request on https://invent.kde.org/system/kpmcore
Comment 13 Yaroslav Sidlovsky 2021-03-17 12:41:44 UTC
https://invent.kde.org/system/kpmcore/-/merge_requests/28
Comment 14 Yaroslav Sidlovsky 2021-03-17 13:17:21 UTC
Git commit 8746ef72fd1b84a665f3bb6abbc8d765affa9ed6 by Yaroslav Sidlovsky.
Committed on 17/03/2021 at 13:03.
Pushed by stikonas into branch 'master'.

Fix smartctl exit status success check

According to the smartctl man page:
```
EXIT STATUS
The  exit  statuses of smartctl are defined by a bitmask.  If all is well with the disk, the exit status (return value) of smartctl is 0 (all bits turned off).  If a problem occurs, or an error, potential error, or fault is detected, then a non-zero status is
returned.  In this case, the eight different bits in the exit status have the following meanings for ATA disks; some of these values may also be returned for SCSI disks.

Bit 0: Command line did not parse.

Bit 1: Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode (see '-n' option above).

Bit 2: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure (see '-b' option above).

Bit 3: SMART status check returned "DISK FAILING".

Bit 4: We found prefail Attributes <= threshold.

Bit 5: SMART status check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.

Bit 6: The device error log contains records of errors.

Bit 7: The device self-test log contains records of errors.  [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored.
```

M  +5    -1    src/core/smartparser.cpp

https://invent.kde.org/system/kpmcore/commit/8746ef72fd1b84a665f3bb6abbc8d765affa9ed6
Comment 15 Andrius Štikonas 2021-03-17 13:18:21 UTC
Git commit 2ea9ff49124750ece175cb1f27a1492fc50287a3 by Andrius Štikonas, on behalf of Yaroslav Sidlovsky.
Committed on 17/03/2021 at 13:18.
Pushed by stikonas into branch 'release/21.04'.

Fix smartctl exit status success check

According to the smartctl man page:
```
EXIT STATUS
The  exit  statuses of smartctl are defined by a bitmask.  If all is well with the disk, the exit status (return value) of smartctl is 0 (all bits turned off).  If a problem occurs, or an error, potential error, or fault is detected, then a non-zero status is
returned.  In this case, the eight different bits in the exit status have the following meanings for ATA disks; some of these values may also be returned for SCSI disks.

Bit 0: Command line did not parse.

Bit 1: Device open failed, device did not return an IDENTIFY DEVICE structure, or device is in a low-power mode (see '-n' option above).

Bit 2: Some SMART or other ATA command to the disk failed, or there was a checksum error in a SMART data structure (see '-b' option above).

Bit 3: SMART status check returned "DISK FAILING".

Bit 4: We found prefail Attributes <= threshold.

Bit 5: SMART status check returned "DISK OK" but we found that some (usage or prefail) Attributes have been <= threshold at some time in the past.

Bit 6: The device error log contains records of errors.

Bit 7: The device self-test log contains records of errors.  [ATA only] Failed self-tests outdated by a newer successful extended self-test are ignored.
```

M  +5    -1    src/core/smartparser.cpp

https://invent.kde.org/system/kpmcore/commit/2ea9ff49124750ece175cb1f27a1492fc50287a3