aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zstreamdump
diff options
context:
space:
mode:
authorAllan Jude <[email protected]>2019-06-22 19:33:44 -0400
committerBrian Behlendorf <[email protected]>2019-06-22 16:33:44 -0700
commitfb6e6f1ffb2aa18711c8c3c825c1090bd97561f0 (patch)
tree0966b1caf146dd7f8f794f8dbc5a282b141e3e95 /cmd/zstreamdump
parent2b09628b59105a2b8da92f6db8da24c07e54ecb9 (diff)
zstreamdump: add per-record-type counters and an overhead counter
Count the bytes of payload for each replication record type Count the bytes of overhead (replication records themselves) Include these counters in the output summary at the end of the run. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matt Ahrens <[email protected]> Signed-off-by: Allan Jude <[email protected]> Sponsored-By: Klara Systems and Catalogic Closes #8432
Diffstat (limited to 'cmd/zstreamdump')
-rw-r--r--cmd/zstreamdump/zstreamdump.c63
1 files changed, 41 insertions, 22 deletions
diff --git a/cmd/zstreamdump/zstreamdump.c b/cmd/zstreamdump/zstreamdump.c
index ae8e5bf66..5f2813ce6 100644
--- a/cmd/zstreamdump/zstreamdump.c
+++ b/cmd/zstreamdump/zstreamdump.c
@@ -53,7 +53,6 @@
*/
#define DUMP_GROUPING 4
-uint64_t total_write_size = 0;
uint64_t total_stream_len = 0;
FILE *send_stream = 0;
boolean_t do_byteswap = B_FALSE;
@@ -219,6 +218,9 @@ main(int argc, char *argv[])
{
char *buf = safe_malloc(SPA_MAXBLOCKSIZE);
uint64_t drr_record_count[DRR_NUMTYPES] = { 0 };
+ uint64_t total_payload_size = 0;
+ uint64_t total_overhead_size = 0;
+ uint64_t drr_byte_count[DRR_NUMTYPES] = { 0 };
char salt[ZIO_DATA_SALT_LEN * 2 + 1];
char iv[ZIO_DATA_IV_LEN * 2 + 1];
char mac[ZIO_DATA_MAC_LEN * 2 + 1];
@@ -337,7 +339,9 @@ main(int argc, char *argv[])
}
drr_record_count[drr->drr_type]++;
+ total_overhead_size += sizeof (*drr);
total_records++;
+ payload_size = 0;
switch (drr->drr_type) {
case DRR_BEGIN:
@@ -391,6 +395,7 @@ main(int argc, char *argv[])
nvlist_print(stdout, nv);
nvlist_free(nv);
}
+ payload_size = sz;
}
break;
@@ -555,7 +560,6 @@ main(int argc, char *argv[])
if (dump) {
print_block(buf, payload_size);
}
- total_write_size += payload_size;
break;
case DRR_WRITE_BYREF:
@@ -684,6 +688,7 @@ main(int argc, char *argv[])
print_block(buf,
P2ROUNDUP(drrwe->drr_psize, 8));
}
+ payload_size = P2ROUNDUP(drrwe->drr_psize, 8);
break;
case DRR_OBJECT_RANGE:
if (do_byteswap) {
@@ -739,6 +744,8 @@ main(int argc, char *argv[])
(longlong_t)drrc->drr_checksum.zc_word[3]);
}
pcksum = zc;
+ drr_byte_count[drr->drr_type] += payload_size;
+ total_payload_size += payload_size;
}
free(buf);
fletcher_4_fini();
@@ -746,28 +753,40 @@ main(int argc, char *argv[])
/* Print final summary */
(void) printf("SUMMARY:\n");
- (void) printf("\tTotal DRR_BEGIN records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_BEGIN]);
- (void) printf("\tTotal DRR_END records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_END]);
- (void) printf("\tTotal DRR_OBJECT records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_OBJECT]);
- (void) printf("\tTotal DRR_FREEOBJECTS records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_FREEOBJECTS]);
- (void) printf("\tTotal DRR_WRITE records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_WRITE]);
- (void) printf("\tTotal DRR_WRITE_BYREF records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_WRITE_BYREF]);
- (void) printf("\tTotal DRR_WRITE_EMBEDDED records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_WRITE_EMBEDDED]);
- (void) printf("\tTotal DRR_FREE records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_FREE]);
- (void) printf("\tTotal DRR_SPILL records = %lld\n",
- (u_longlong_t)drr_record_count[DRR_SPILL]);
+ (void) printf("\tTotal DRR_BEGIN records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_BEGIN],
+ (u_longlong_t)drr_byte_count[DRR_BEGIN]);
+ (void) printf("\tTotal DRR_END records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_END],
+ (u_longlong_t)drr_byte_count[DRR_END]);
+ (void) printf("\tTotal DRR_OBJECT records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_OBJECT],
+ (u_longlong_t)drr_byte_count[DRR_OBJECT]);
+ (void) printf("\tTotal DRR_FREEOBJECTS records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_FREEOBJECTS],
+ (u_longlong_t)drr_byte_count[DRR_FREEOBJECTS]);
+ (void) printf("\tTotal DRR_WRITE records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_WRITE],
+ (u_longlong_t)drr_byte_count[DRR_WRITE]);
+ (void) printf("\tTotal DRR_WRITE_BYREF records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_WRITE_BYREF],
+ (u_longlong_t)drr_byte_count[DRR_WRITE_BYREF]);
+ (void) printf("\tTotal DRR_WRITE_EMBEDDED records = %lld (%llu "
+ "bytes)\n", (u_longlong_t)drr_record_count[DRR_WRITE_EMBEDDED],
+ (u_longlong_t)drr_byte_count[DRR_WRITE_EMBEDDED]);
+ (void) printf("\tTotal DRR_FREE records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_FREE],
+ (u_longlong_t)drr_byte_count[DRR_FREE]);
+ (void) printf("\tTotal DRR_SPILL records = %lld (%llu bytes)\n",
+ (u_longlong_t)drr_record_count[DRR_SPILL],
+ (u_longlong_t)drr_byte_count[DRR_SPILL]);
(void) printf("\tTotal records = %lld\n",
(u_longlong_t)total_records);
- (void) printf("\tTotal write size = %lld (0x%llx)\n",
- (u_longlong_t)total_write_size, (u_longlong_t)total_write_size);
+ (void) printf("\tTotal payload size = %lld (0x%llx)\n",
+ (u_longlong_t)total_payload_size, (u_longlong_t)total_payload_size);
+ (void) printf("\tTotal header overhead = %lld (0x%llx)\n",
+ (u_longlong_t)total_overhead_size,
+ (u_longlong_t)total_overhead_size);
(void) printf("\tTotal stream length = %lld (0x%llx)\n",
(u_longlong_t)total_stream_len, (u_longlong_t)total_stream_len);
return (0);