]> git.proxmox.com Git - zfsonlinux.git/blame - zfs-patches/0036-Add-SMART-attributes-for-SSD-and-NVMe.patch
bump version to 0.7.7-pve1~bpo9
[zfsonlinux.git] / zfs-patches / 0036-Add-SMART-attributes-for-SSD-and-NVMe.patch
CommitLineData
75b07eca
FG
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: bunder2015 <omfgbunder@gmail.com>
3Date: Wed, 21 Feb 2018 16:52:47 -0500
4Subject: [PATCH] Add SMART attributes for SSD and NVMe
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9This adds the SMART attributes required to probe Samsung SSD and NVMe
10(and possibly others) disks when using the "zpool status -c" command.
11
12Reviewed-by: loli10K <ezomori.nozomu@gmail.com>
13Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
14Reviewed-by: Tony Hutter <hutter2@llnl.gov>
15Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
16Signed-off-by: bunder2015 <omfgbunder@gmail.com>
17Closes #7183
18Closes #7193
19(cherry picked from commit c705d8386b21b08aefdc62b6b1a556aab6717316)
20Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
21---
22 cmd/zpool/Makefile.am | 2 ++
23 cmd/zpool/zpool.d/nvme_err | 1 +
24 cmd/zpool/zpool.d/smart | 23 +++++++++++++++++++++--
25 3 files changed, 24 insertions(+), 2 deletions(-)
26 create mode 120000 cmd/zpool/zpool.d/nvme_err
27
28diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am
29index 6eff1d143..c7b8b76e3 100644
30--- a/cmd/zpool/Makefile.am
31+++ b/cmd/zpool/Makefile.am
32@@ -60,6 +60,7 @@ dist_zpoolexec_SCRIPTS = \
33 zpool.d/pend_sec \
34 zpool.d/off_ucor \
35 zpool.d/ata_err \
36+ zpool.d/nvme_err \
37 zpool.d/pwr_cyc \
38 zpool.d/upath \
39 zpool.d/vendor
40@@ -98,6 +99,7 @@ zpoolconfdefaults = \
41 pend_sec \
42 off_ucor \
43 ata_err \
44+ nvme_err \
45 pwr_cyc \
46 upath \
47 vendor
48diff --git a/cmd/zpool/zpool.d/nvme_err b/cmd/zpool/zpool.d/nvme_err
49new file mode 120000
50index 000000000..94f22861f
51--- /dev/null
52+++ b/cmd/zpool/zpool.d/nvme_err
53@@ -0,0 +1 @@
54+smart
55\ No newline at end of file
56diff --git a/cmd/zpool/zpool.d/smart b/cmd/zpool/zpool.d/smart
57index 3721f30ed..4bc3af39d 100755
58--- a/cmd/zpool/zpool.d/smart
59+++ b/cmd/zpool/zpool.d/smart
60@@ -23,6 +23,7 @@ off_ucor: Show SMART offline uncorrectable errors (ATA).
61 ata_err: Show SMART ATA errors (ATA).
62 pwr_cyc: Show SMART power cycle count (ATA).
63 serial: Show disk serial number.
64+nvme_err: Show SMART NVMe errors (NVMe).
65 "
66
67 script=$(basename "$0")
68@@ -37,7 +38,7 @@ smartctl_path=$(which smartctl)
69 if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ]; then
70 raw_out=$(eval "sudo $smartctl_path -a $VDEV_UPATH")
71
72- # Are we a SAS or ATA drive? Look for the right line in smartctl:
73+ # What kind of drive are we? Look for the right line in smartctl:
74 #
75 # SAS:
76 # Transport protocol: SAS
77@@ -45,7 +46,10 @@ if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ]; then
78 # SATA:
79 # ATA Version is: 8
80 #
81- type=$(echo "$raw_out" | grep -m 1 -Eo '^ATA|SAS$')
82+ # NVMe:
83+ # SMART/Health Information (NVMe Log 0xnn, NSID 0xnn)
84+ #
85+ type=$(echo "$raw_out" | grep -m 1 -Eo '^ATA|NVMe|SAS$')
86 out=$(echo "$raw_out" | awk '
87 # SAS specific
88 /read:/{print "rrd="$4"\nr_cor="$5"\nr_proc="$7"\nr_ucor="$8}
89@@ -71,10 +75,21 @@ if [ -b "$VDEV_UPATH" ] && [ -x "$smartctl_path" ]; then
90
91 # SATA common
92 /Temperature_Celsius/{print "temp="$10}
93+/Airflow_Temperature_Cel/{print "temp="$10}
94 /SMART overall-health self-assessment test result:/{print "health="$6}
95 /Power_On_Hours/{print "hours_on="$10}
96 /Serial Number:/{print "serial="$3}
97
98+# NVMe common
99+/Temperature:/{print "temp="$2}
100+/SMART overall-health self-assessment test result:/{print "health="$6}
101+/Power On Hours:/{gsub("[^0-9]","",$4); print "hours_on="$4}
102+/Serial Number:/{print "serial="$3}
103+/Power Cycles:/{print "pwr_cyc="$3}
104+
105+# NVMe specific
106+/Media and Data Integrity Errors:/{print "nvme_err="$6}
107+
108 END {ORS="\n"; print ""}
109 ');
110 fi
111@@ -94,6 +109,8 @@ smart)
112 scripts="temp|health|r_ucor|w_ucor"
113 elif [ "$type" = "ATA" ] ; then
114 scripts="temp|health|ata_err|realloc|rep_ucor|cmd_to|pend_sec|off_ucor"
115+ elif [ "$type" = "NVMe" ] ; then
116+ scripts="temp|health|nvme_err"
117 fi
118 ;;
119 smartx)
120@@ -102,6 +119,8 @@ smartx)
121 scripts="hours_on|defect|nonmed|r_proc|w_proc"
122 elif [ "$type" = "ATA" ] ; then
123 scripts="hours_on|pwr_cyc"
124+ elif [ "$type" = "NVMe" ] ; then
125+ scripts="hours_on|pwr_cyc"
126 fi
127 ;;
128 *)
129--
1302.14.2
131