Module Name:src
Committed By: martin
Date: Sun Mar 5 14:37:14 UTC 2023
Modified Files:
src/sbin/nvmectl [netbsd-10]: logpage.c nvmectl.h util.c
Log Message:
Pull up following revision(s) (requested by mlelstv in ticket #112):
sbin/nvmectl/nvmectl.h: revision 1.10
sbin/nvmectl/logpage.c: revision 1.11
sbin/nvmectl/util.c: revision 1.3
Data units read/written are counted in 1000s of 512 bytes.
Convert to human-readable value.
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.10.2.1 src/sbin/nvmectl/logpage.c
cvs rdiff -u -r1.9 -r1.9.6.1 src/sbin/nvmectl/nvmectl.h
cvs rdiff -u -r1.2 -r1.2.16.1 src/sbin/nvmectl/util.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/nvmectl/logpage.c
diff -u src/sbin/nvmectl/logpage.c:1.10 src/sbin/nvmectl/logpage.c:1.10.2.1
--- src/sbin/nvmectl/logpage.c:1.10 Sun Jul 31 13:49:23 2022
+++ src/sbin/nvmectl/logpage.c Sun Mar 5 14:37:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: logpage.c,v 1.10 2022/07/31 13:49:23 mlelstv Exp $ */
+/* $NetBSD: logpage.c,v 1.10.2.1 2023/03/05 14:37:14 martin Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -33,7 +33,7 @@
#include
#ifndef lint
-__RCSID("$NetBSD: logpage.c,v 1.10 2022/07/31 13:49:23 mlelstv Exp $");
+__RCSID("$NetBSD: logpage.c,v 1.10.2.1 2023/03/05 14:37:14 martin Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/logpage.c 329824 2018-02-22 13:32:31Z wma $");
#endif
@@ -263,9 +263,9 @@ print_log_health(const struct nvm_identi
printf("Percentage used:%u\n",
health->percentage_used);
- print_bignum("Data units (512 byte) read:", health->data_units_read, "");
- print_bignum("Data units (512 byte) written:", health->data_units_written,
- "");
+ print_bignum1("Data units read:", health->data_units_read, "", "B", 512000);
+ print_bignum1("Data units written:", health->data_units_written,
+ "", "B", 512000);
print_bignum("Host read commands:", health->host_read_commands, "");
print_bignum("Host write commands:", health->host_write_commands, "");
print_bignum("Controller busy time (minutes):", health->controller_busy_time,
Index: src/sbin/nvmectl/nvmectl.h
diff -u src/sbin/nvmectl/nvmectl.h:1.9 src/sbin/nvmectl/nvmectl.h:1.9.6.1
--- src/sbin/nvmectl/nvmectl.h:1.9 Sun Sep 27 18:17:35 2020
+++ src/sbin/nvmectl/nvmectl.h Sun Mar 5 14:37:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmectl.h,v 1.9 2020/09/27 18:17:35 jdolecek Exp $ */
+/* $NetBSD: nvmectl.h,v 1.9.6.1 2023/03/05 14:37:14 martin Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -109,6 +109,7 @@ __dead void dispatch(int argc, char *arg
/* Utility Routines */
void nvme_strvis(uint8_t *, int, const uint8_t *, int);
void print_bignum(const char *, uint64_t v[2], const char *);
+void print_bignum1(const char *, uint64_t v[2], const char *, const char *, long);
uint64_t le48dec(const void *);
#endif /* __NVMECTL_H__ */
Index: src/sbin/nvmectl/util.c
diff -u src/sbin/nvmectl/util.c:1.2 src/sbin/nvmectl/util.c:1.2.16.1
--- src/sbin/nvmectl/util.c:1.2 Wed Apr 18 10:11:44 2018
+++ src/sbin/nvmectl/util.c Sun Mar 5 14:37:14 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.2 2018/04/18 10:11:44 nonaka Exp $ */
+/* $NetBSD: util.c,v 1.2.16.1 2023/03/05 14:37:14 martin Exp $ */
/*-
* Copyright (c) 2017 Netflix, Inc
@@ -28,7 +28,7 @@
#include
#ifndef lint
-__RCSID("$NetBSD: util.c,v 1.2 2018/04/18 10:11:44 nonaka Exp $");
+__RCSID("$NetBSD: util.c,v 1.2.16.1 2023/03/05 14:37:14 martin Exp $");
#if 0
__FBSDID("$FreeBSD: head/sbin/nvmecontrol/util.c 320423 2017-06-27 20:24:25Z imp $");
#endif
@@ -84,10 +84,47 @@ nvme_strvis(u_char *dst, int dlen, const
#define METRIX_PREFIX_BUFSIZ 17
#define NO_METRIX_PREFIX_BUFSIZ 42
+static void
+unit_string(BIGNUM *bn, const char *unit, long scale, char *out, size_t len)
+{
+ size_t ulen = strlen(unit);
+ uint8_t tmp[4];
+ BN_CTX *ctx;
+ BIGNUM *sn;
+
+ if (6 + ulen + 3 >= len)
+ return;
+
+ if (scale > 1) {
+ ctx = BN_CTX_new();
+ if (ctx == NULL)
+ return;
+
+ tmp[0] = (scale >> 24) & 0xff;
+ tmp[1] = (scale >> 16) & 0xff;
+ tmp[2] = (scale >> 8) & 0xff;
+ tmp[3] = scale & 0xff;
+
+ sn = BN_bin2bn(tmp, sizeof(tmp), NULL);
+ if (sn != NULL) {
+ BN_mul(bn, bn, sn, ctx);
+ BN_free(sn);
+ }
+
+ BN_CTX_free(ctx);
+ }
+
+ strncpy(out, " (", len);
+ humanize_bignum(out+2, 6 + ulen, bn, unit, HN_AUTOSCALE, HN_DECIMAL);
+ strncat(out, ")", len);
+}
+
void
-print_bignum(const char *title, uint64_t v[2], const char *suffix)
+print_bignum1(const char *title, uint64_t v[2], const char *suffix,
+const char *unit, long scale)
{
char buf[64];
+ char buf2[64];
uint8_t tmp[16];
uint64_t h, l;
@@ -119,15 +156,25 @@ print_bignum(const char *title, uint64_t
#endif
buf[0] = '\0';
+ buf2[0] = '\0';
+
BIGNUM *bn = BN_bin2bn(tmp, sizeof(tmp), NULL);
if (bn != NULL) {
humanize_b