From eb579553a1788914d8f36930e8f0345876559ee8 Mon Sep 17 00:00:00 2001 From: mm Date: Sat, 6 Apr 2013 07:43:50 +0000 Subject: Update vendor/illumos/dist to illumos-gate 13991:53e4f9da98a1 Illumos ZFS issues: 3641 want a histogram of compressed block sizes --- cmd/zdb/zdb.c | 89 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 24 deletions(-) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index b4b6150..d4d32b9 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -21,10 +21,11 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include +#include #include #include #include @@ -241,18 +242,18 @@ zdb_nicenum(uint64_t num, char *buf) nicenum(num, buf); } -const char dump_zap_stars[] = "****************************************"; -const int dump_zap_width = sizeof (dump_zap_stars) - 1; +const char histo_stars[] = "****************************************"; +const int histo_width = sizeof (histo_stars) - 1; static void -dump_zap_histogram(uint64_t histo[ZAP_HISTOGRAM_SIZE]) +dump_histogram(const uint64_t *histo, int size) { int i; - int minidx = ZAP_HISTOGRAM_SIZE - 1; + int minidx = size - 1; int maxidx = 0; uint64_t max = 0; - for (i = 0; i < ZAP_HISTOGRAM_SIZE; i++) { + for (i = 0; i < size; i++) { if (histo[i] > max) max = histo[i]; if (histo[i] > 0 && i > maxidx) @@ -261,12 +262,14 @@ dump_zap_histogram(uint64_t histo[ZAP_HISTOGRAM_SIZE]) minidx = i; } - if (max < dump_zap_width) - max = dump_zap_width; + if (max < histo_width) + max = histo_width; - for (i = minidx; i <= maxidx; i++) - (void) printf("\t\t\t%u: %6llu %s\n", i, (u_longlong_t)histo[i], - &dump_zap_stars[(max - histo[i]) * dump_zap_width / max]); + for (i = minidx; i <= maxidx; i++) { + (void) printf("\t\t\t%3u: %6llu %s\n", + i, (u_longlong_t)histo[i], + &histo_stars[(max - histo[i]) * histo_width / max]); + } } static void @@ -317,19 +320,19 @@ dump_zap_stats(objset_t *os, uint64_t object) (u_longlong_t)zs.zs_salt); (void) printf("\t\tLeafs with 2^n pointers:\n"); - dump_zap_histogram(zs.zs_leafs_with_2n_pointers); + dump_histogram(zs.zs_leafs_with_2n_pointers, ZAP_HISTOGRAM_SIZE); (void) printf("\t\tBlocks with n*5 entries:\n"); - dump_zap_histogram(zs.zs_blocks_with_n5_entries); + dump_histogram(zs.zs_blocks_with_n5_entries, ZAP_HISTOGRAM_SIZE); (void) printf("\t\tBlocks n/10 full:\n"); - dump_zap_histogram(zs.zs_blocks_n_tenths_full); + dump_histogram(zs.zs_blocks_n_tenths_full, ZAP_HISTOGRAM_SIZE); (void) printf("\t\tEntries with n chunks:\n"); - dump_zap_histogram(zs.zs_entries_using_n_chunks); + dump_histogram(zs.zs_entries_using_n_chunks, ZAP_HISTOGRAM_SIZE); (void) printf("\t\tBuckets with n entries:\n"); - dump_zap_histogram(zs.zs_buckets_with_n_entries); + dump_histogram(zs.zs_buckets_with_n_entries, ZAP_HISTOGRAM_SIZE); } /*ARGSUSED*/ @@ -949,7 +952,7 @@ sprintf_blkptr_compact(char *blkbuf, const blkptr_t *bp) const dva_t *dva = bp->blk_dva; int ndvas = dump_opt['d'] > 5 ? BP_GET_NDVAS(bp) : 1; - if (dump_opt['b'] >= 5) { + if (dump_opt['b'] >= 6) { sprintf_blkptr(blkbuf, bp); return; } @@ -1988,11 +1991,13 @@ dump_one_dir(const char *dsname, void *arg) /* * Block statistics. */ +#define PSIZE_HISTO_SIZE (SPA_MAXBLOCKSIZE / SPA_MINBLOCKSIZE + 1) typedef struct zdb_blkstats { - uint64_t zb_asize; - uint64_t zb_lsize; - uint64_t zb_psize; - uint64_t zb_count; + uint64_t zb_asize; + uint64_t zb_lsize; + uint64_t zb_psize; + uint64_t zb_count; + uint64_t zb_psize_histogram[PSIZE_HISTO_SIZE]; } zdb_blkstats_t; /* @@ -2016,6 +2021,9 @@ typedef struct zdb_cb { zdb_blkstats_t zcb_type[ZB_TOTAL + 1][ZDB_OT_TOTAL + 1]; uint64_t zcb_dedup_asize; uint64_t zcb_dedup_blocks; + uint64_t zcb_start; + uint64_t zcb_lastprint; + uint64_t zcb_totalasize; uint64_t zcb_errors[256]; int zcb_readfails; int zcb_haderrors; @@ -2042,6 +2050,7 @@ zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp, zb->zb_lsize += BP_GET_LSIZE(bp); zb->zb_psize += BP_GET_PSIZE(bp); zb->zb_count++; + zb->zb_psize_histogram[BP_GET_PSIZE(bp) >> SPA_MINBLOCKSHIFT]++; } if (dump_opt['L']) @@ -2151,7 +2160,7 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, zcb->zcb_readfails = 0; - if (dump_opt['b'] >= 4) { + if (dump_opt['b'] >= 5) { sprintf_blkptr(blkbuf, bp); (void) printf("objset %llu object %llu " "level %lld offset 0x%llx %s\n", @@ -2162,6 +2171,28 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, blkbuf); } + if (dump_opt['b'] < 5 && isatty(STDERR_FILENO) && + gethrtime() > zcb->zcb_lastprint + NANOSEC) { + uint64_t now = gethrtime(); + char buf[10]; + uint64_t bytes = zcb->zcb_type[ZB_TOTAL][ZDB_OT_TOTAL].zb_asize; + int kb_per_sec = + 1 + bytes / (1 + ((now - zcb->zcb_start) / 1000 / 1000)); + int sec_remaining = + (zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec; + + zfs_nicenum(bytes, buf, sizeof (buf)); + (void) fprintf(stderr, + "\r%5s completed (%4dMB/s) " + "estimated time remaining: %uhr %02umin %02usec ", + buf, kb_per_sec / 1024, + sec_remaining / 60 / 60, + sec_remaining / 60 % 60, + sec_remaining % 60); + + zcb->zcb_lastprint = now; + } + return (0); } @@ -2293,7 +2324,7 @@ count_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx) { zdb_cb_t *zcb = arg; - if (dump_opt['b'] >= 4) { + if (dump_opt['b'] >= 5) { char blkbuf[BP_SPRINTF_LEN]; sprintf_blkptr(blkbuf, bp); (void) printf("[%s] %s\n", @@ -2312,7 +2343,7 @@ dump_block_stats(spa_t *spa) int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD; int leaks = 0; - (void) printf("\nTraversing all blocks %s%s%s%s%s...\n", + (void) printf("\nTraversing all blocks %s%s%s%s%s...\n\n", (dump_opt['c'] || !dump_opt['L']) ? "to verify " : "", (dump_opt['c'] == 1) ? "metadata " : "", dump_opt['c'] ? "checksums " : "", @@ -2348,6 +2379,8 @@ dump_block_stats(spa_t *spa) if (dump_opt['c'] > 1) flags |= TRAVERSE_PREFETCH_DATA; + zcb.zcb_totalasize = metaslab_class_get_alloc(spa_normal_class(spa)); + zcb.zcb_start = zcb.zcb_lastprint = gethrtime(); zcb.zcb_haderrors |= traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb); /* @@ -2487,6 +2520,14 @@ dump_block_stats(spa_t *spa) else (void) printf(" L%d %s\n", level, typename); + + if (dump_opt['b'] >= 4) { + (void) printf("psize " + "(in 512-byte sectors): " + "number of blocks\n"); + dump_histogram(zb->zb_psize_histogram, + PSIZE_HISTO_SIZE); + } } } } -- cgit v1.1 From c4aa171c745b4c3081add13bb9a65bce5e8b255b Mon Sep 17 00:00:00 2001 From: mm Date: Sat, 6 Apr 2013 08:06:25 +0000 Subject: Update vendor/illumos/dist to illumos-gate 14004:dd91fed709a7 Illumos DTrace issues: 3675 DTrace print() should try to resolve function pointers 3676 dt_print_enum hardcodes a value of zero --- cmd/dtrace/test/tst/common/print/tst.enum.d | 33 ++++++++++++++++ cmd/dtrace/test/tst/common/print/tst.enum.d.out | 4 ++ lib/libdtrace/common/dt_print.c | 51 +++++++++++++++++++++++-- 3 files changed, 84 insertions(+), 4 deletions(-) create mode 100644 cmd/dtrace/test/tst/common/print/tst.enum.d create mode 100644 cmd/dtrace/test/tst/common/print/tst.enum.d.out diff --git a/cmd/dtrace/test/tst/common/print/tst.enum.d b/cmd/dtrace/test/tst/common/print/tst.enum.d new file mode 100644 index 0000000..f96af10 --- /dev/null +++ b/cmd/dtrace/test/tst/common/print/tst.enum.d @@ -0,0 +1,33 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ + +#pragma D option quiet + +enum simpson { + homer, + marge, + bart, + lisa, + maggie, + snowball_ii, + santas_little_helper +}; + +BEGIN +{ + print(bart); + print((enum simpson)4); + print(snowball_ii); + exit(0); +} diff --git a/cmd/dtrace/test/tst/common/print/tst.enum.d.out b/cmd/dtrace/test/tst/common/print/tst.enum.d.out new file mode 100644 index 0000000..979a5b7 --- /dev/null +++ b/cmd/dtrace/test/tst/common/print/tst.enum.d.out @@ -0,0 +1,4 @@ +enum simpson bart +enum simpson maggie +enum simpson snowball_ii + diff --git a/lib/libdtrace/common/dt_print.c b/lib/libdtrace/common/dt_print.c index 261fc8c..ccfa3da 100644 --- a/lib/libdtrace/common/dt_print.c +++ b/lib/libdtrace/common/dt_print.c @@ -25,6 +25,9 @@ /* * Copyright (c) 2011 by Delphix. All rights reserved. */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ /* * DTrace print() action @@ -93,6 +96,7 @@ * Print structure passed down recursively through printing algorithm. */ typedef struct dt_printarg { + dtrace_hdl_t *pa_dtp; /* libdtrace handle */ caddr_t pa_addr; /* base address of trace data */ ctf_file_t *pa_ctfp; /* CTF container */ int pa_depth; /* member depth */ @@ -303,8 +307,8 @@ dt_print_float(ctf_id_t base, ulong_t off, dt_printarg_t *pap) } /* - * A pointer is printed as a fixed-size integer. This is used both for - * pointers and functions. + * A pointer is generally printed as a fixed-size integer. If we have a + * function pointer, we try to look up its name. */ static void dt_print_ptr(ctf_id_t base, ulong_t off, dt_printarg_t *pap) @@ -313,8 +317,23 @@ dt_print_ptr(ctf_id_t base, ulong_t off, dt_printarg_t *pap) ctf_file_t *ctfp = pap->pa_ctfp; caddr_t addr = pap->pa_addr + off / NBBY; size_t size = ctf_type_size(ctfp, base); - - dt_print_hex(fp, addr, size); + ctf_id_t bid = ctf_type_reference(ctfp, base); + uint64_t pc; + dtrace_syminfo_t dts; + GElf_Sym sym; + + if (bid == CTF_ERR || ctf_type_kind(ctfp, bid) != CTF_K_FUNCTION) { + dt_print_hex(fp, addr, size); + } else { + /* LINTED - alignment */ + pc = *((uint64_t *)addr); + if (dtrace_lookup_by_addr(pap->pa_dtp, pc, &sym, &dts) != 0) { + dt_print_hex(fp, addr, size); + } else { + (void) fprintf(fp, "%s`%s", dts.dts_object, + dts.dts_name); + } + } } /* @@ -459,8 +478,31 @@ dt_print_enum(ctf_id_t base, ulong_t off, dt_printarg_t *pap) FILE *fp = pap->pa_file; ctf_file_t *ctfp = pap->pa_ctfp; const char *ename; + ssize_t size; + caddr_t addr = pap->pa_addr + off / NBBY; int value = 0; + /* + * The C standard says that an enum will be at most the sizeof (int). + * But if all the values are less than that, the compiler can use a + * smaller size. Thanks standards. + */ + size = ctf_type_size(ctfp, base); + switch (size) { + case sizeof (uint8_t): + value = *(uint8_t *)addr; + break; + case sizeof (uint16_t): + value = *(uint16_t *)addr; + break; + case sizeof (int32_t): + value = *(int32_t *)addr; + break; + default: + (void) fprintf(fp, "", (uint_t)size); + return; + } + if ((ename = ctf_enum_name(ctfp, base, value)) != NULL) (void) fprintf(fp, "%s", ename); else @@ -635,6 +677,7 @@ dtrace_print(dtrace_hdl_t *dtp, FILE *fp, const char *typename, } /* setup the print structure and kick off the main print routine */ + pa.pa_dtp = dtp; pa.pa_addr = addr; pa.pa_ctfp = dt_module_getctf(dtp, dmp); pa.pa_nest = 0; -- cgit v1.1 From b1ebd8692b32b3d5a53dba8e74f7c391f7f2ddab Mon Sep 17 00:00:00 2001 From: mm Date: Tue, 9 Apr 2013 06:33:03 +0000 Subject: Add missing file dt_pq.h that should have been committed in r239385 Reported by: Pedro Giffuni --- lib/libdtrace/common/dt_pq.h | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lib/libdtrace/common/dt_pq.h diff --git a/lib/libdtrace/common/dt_pq.h b/lib/libdtrace/common/dt_pq.h new file mode 100644 index 0000000..8184a90 --- /dev/null +++ b/lib/libdtrace/common/dt_pq.h @@ -0,0 +1,51 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + +/* + * Copyright (c) 2012 by Delphix. All rights reserved. + */ + +#ifndef _DT_PQ_H +#define _DT_PQ_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef uint64_t (*dt_pq_value_f)(void *, void *); + +typedef struct dt_pq { + dtrace_hdl_t *dtpq_hdl; /* dtrace handle */ + void **dtpq_items; /* array of elements */ + uint_t dtpq_size; /* count of allocated elements */ + uint_t dtpq_last; /* next free slot */ + dt_pq_value_f dtpq_value; /* callback to get the value */ + void *dtpq_arg; /* callback argument */ +} dt_pq_t; + +extern dt_pq_t *dt_pq_init(dtrace_hdl_t *, uint_t size, dt_pq_value_f, void *); +extern void dt_pq_fini(dt_pq_t *); + +extern void dt_pq_insert(dt_pq_t *, void *); +extern void *dt_pq_pop(dt_pq_t *); +extern void *dt_pq_walk(dt_pq_t *, uint_t *); + +#ifdef __cplusplus +} +#endif + +#endif /* _DT_PQ_H */ -- cgit v1.1