Skip to content

Commit ecb51ed

Browse files
Carl Moranigaw
Carl Moran
authored andcommitted
plugins/wdc: fix json output for vs-nand-stats
Running nvme wdc vs-nand-stats will change the values of the user data fields depending on output format used. In regular stdout, the ordering is TLC min, TLC Max, SLC Min, SLC Max. However in json, the values get reassigned, what was SLC Min in stdout will become TLC > Regular format (TLC Min, TLC Max, SLC Min, SLC Max) [root@ /tmp/]# nvme wdc vs-nand-stats /dev/nvme0n1 | grep User\ Data User Data Erase Counts - TLC Min 169 User Data Erase Counts - TLC Max 310 User Data Erase Counts - SLC Min 10719 User Data Erase Counts - SLC Max 11676 Json format (SLC Min, SLC Max, TLC Min, TLC Max) [root@ /tmp/]# nvme wdc vs-nand-stats /dev/nvme0n1 -o json | grep User\ Data "User Data Erase Counts - SLC Min" : 169, "User Data Erase Counts - SLC Max" : 310, "User Data Erase Counts - TLC Min" : 10719, "User Data Erase Counts - TLC Max" : 11676, The difference can be traced to how the array subscripts are being used in the two output formats stdout : https://t.ly/sRIDz tlc_min == 0 tlc_max == 1 slc_min == 2 slc_max == 3 json : https://t.ly/pmU-m slc_min = 0 slc_max = 1 tlc_min = 2 tlc_max = 3 With the patch, we rename the fields to be the same for both stdout & json. Output comparison below Regular format (TLC Min, TLC Max, SLC Min, SLC Max) [root@ /tmp/]# ./nvme wdc vs-nand-stats /dev/nvme0n1 | grep User\ Data User Data Erase Counts - TLC Min 169 User Data Erase Counts - TLC Max 310 User Data Erase Counts - SLC Min 10719 User Data Erase Counts - SLC Max 11676 Json format (TLC Min, TLC Max, SLC Min, SLC Max) [root@ /tmp/]# ./nvme wdc vs-nand-stats /dev/nvme0n1 -o json | grep User\ Data "User Data Erase Counts - TLC Min":169, "User Data Erase Counts - TLC Max":310, "User Data Erase Counts - SLC Min":10719, "User Data Erase Counts - SLC Max":11676, Signed-off-by: Carl Moran<carl.moran1@meta.com>
1 parent 7cdd12e commit ecb51ed

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

plugins/wdc/wdc-nvme.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -10835,13 +10835,13 @@ static void wdc_print_nand_stats_json(__u16 version, void *data)
1083510835
le32_to_cpu(nand_stats_v3->ssd_correction_counts[12]));
1083610836
json_object_add_value_uint(root, "System data % life-used",
1083710837
nand_stats_v3->percent_life_used);
10838-
json_object_add_value_uint64(root, "User Data Erase Counts - SLC Min",
10838+
json_object_add_value_uint64(root, "User Data Erase Counts - TLC Min",
1083910839
le64_to_cpu(nand_stats_v3->user_data_erase_counts[0]));
10840-
json_object_add_value_uint64(root, "User Data Erase Counts - SLC Max",
10840+
json_object_add_value_uint64(root, "User Data Erase Counts - TLC Max",
1084110841
le64_to_cpu(nand_stats_v3->user_data_erase_counts[1]));
10842-
json_object_add_value_uint64(root, "User Data Erase Counts - TLC Min",
10842+
json_object_add_value_uint64(root, "User Data Erase Counts - SLC Min",
1084310843
le64_to_cpu(nand_stats_v3->user_data_erase_counts[2]));
10844-
json_object_add_value_uint64(root, "User Data Erase Counts - TLC Max",
10844+
json_object_add_value_uint64(root, "User Data Erase Counts - SLC Max",
1084510845
le64_to_cpu(nand_stats_v3->user_data_erase_counts[3]));
1084610846
temp_ptr = (__u64 *)nand_stats_v3->program_fail_count;
1084710847
temp_norm = (__u16)(*temp_ptr & 0x000000000000FFFF);

plugins/wdc/wdc-nvme.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#if !defined(WDC_NVME) || defined(CMD_HEADER_MULTI_READ)
66
#define WDC_NVME
77

8-
#define WDC_PLUGIN_VERSION "2.9.2"
8+
#define WDC_PLUGIN_VERSION "2.9.3"
99
#include "cmd.h"
1010

1111
PLUGIN(NAME("wdc", "Western Digital vendor specific extensions", WDC_PLUGIN_VERSION),

0 commit comments

Comments
 (0)