Skip to contentSkip to conversation

nvme-print: fix smart log temperature output in json mode

PATCH In review Yi Zhang 2 participants 3 messages Jun 9, 2020 – Jun 10, 2020 NVMe

lore
Share & tools
lore

Yi Zhang

author
#0 lore raw

PATCH 1/1 nvme-print: fix smart log temperature output in json mode

---
 nvme-print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-print.c +1 -1
index 7414280..d63b402 100644
@@ -593,7 +593,7 @@ static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid,
 	char key[21];
 
 	unsigned int temperature = ((smart->temperature[1] << 8) |
-		smart->temperature[0]);
+		smart->temperature[0]) - 273;
 
 	long double data_units_read = int128_to_double(smart->data_units_read);
 	long double data_units_written = int128_to_double(smart->data_units_written);
Signature · 7 lines
2.21.0


_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
maintainer
#1 lore raw
Quoted 10 lines · Yi Zhang
---
 nvme-print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-print.c +0 -0
index 7414280..d63b402 100644

nvme-print.c static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, · line 596

Quoted 5 lines
nvme-print.c +1 -1
@@ -593,7 +593,7 @@ static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid,
 	char key[21];
 
 	unsigned int temperature = ((smart->temperature[1] << 8) |
-		smart->temperature[0]);
+		smart->temperature[0]) - 273;

I usually consider json output as something to be consumed by another program rather than by a human, so we've not done much manipulation from the spec defined units. It's just a serialized representation of the structure.

If you need a more human friendly output, we can add flags to refine the output, but we can't just change the default reporting from Kelvin to Celsius since that may break existing programs interpreting the current json.

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

author
#2 lore raw
Quoted 13 lines · Keith Busch
Quoted 12 lines · Yi Zhang
---
  nvme-print.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
nvme-print.c +0 -0
index 7414280..d63b402 100644
@@ -593,7 +593,7 @@ static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid,
  	char key[21];
 
Quoted 7 lines

nvme-print.c static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid, · line 596

Quoted 3 lines
nvme-print.c +1 -1
  	unsigned int temperature = ((smart->temperature[1] << 8) |
-		smart->temperature[0]);
+		smart->temperature[0]) - 273;

I usually consider json output as something to be consumed by another program rather than by a human, so we've not done much manipulation from the spec defined units. It's just a serialized representation of the structure.

I checked this field in the spec, it make sense to keep Kelvin here. So drop this patch, thanks.

Quoted 5 lines

If you need a more human friendly output, we can add flags to refine the output, but we can't just change the default reporting from Kelvin to Celsius since that may break existing programs interpreting the current json.

_______________________________________________
linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme