Skip to content

Commit

Permalink
5169 zdb should limit its ARC size
Browse files Browse the repository at this point in the history
5170 zdb -c should create more scrub i/os by default
5171 zdb should print status while loading metaslabs for leak detection
Reviewed by: Christopher Siden <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Paul Dagnelie <[email protected]>
Reviewed by: Bayard Bell <[email protected]>
Approved by: Robert Mustacchi <[email protected]>
  • Loading branch information
ahrens authored and Christopher Siden committed Oct 7, 2014
1 parent fe2e029 commit 06be980
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions usr/src/cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@

#ifndef lint
extern boolean_t zfs_recover;
extern uint64_t zfs_arc_max, zfs_arc_meta_limit;
#else
boolean_t zfs_recover;
uint64_t zfs_arc_max, zfs_arc_meta_limit;
#endif

const char cmdname[] = "zdb";
Expand All @@ -89,7 +91,7 @@ extern void dump_intent_log(zilog_t *);
uint64_t *zopt_object = NULL;
int zopt_objects = 0;
libzfs_handle_t *g_zfs;
uint64_t max_inflight = 200;
uint64_t max_inflight = 1000;

/*
* These libumem hooks provide a reasonable set of defaults for the allocator's
Expand Down Expand Up @@ -2353,7 +2355,7 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,

zcb->zcb_readfails = 0;

if (dump_opt['b'] < 5 && isatty(STDERR_FILENO) &&
if (dump_opt['b'] < 5 &&
gethrtime() > zcb->zcb_lastprint + NANOSEC) {
uint64_t now = gethrtime();
char buf[10];
Expand Down Expand Up @@ -2438,9 +2440,9 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)

if (!dump_opt['L']) {
vdev_t *rvd = spa->spa_root_vdev;
for (int c = 0; c < rvd->vdev_children; c++) {
for (uint64_t c = 0; c < rvd->vdev_children; c++) {
vdev_t *vd = rvd->vdev_child[c];
for (int m = 0; m < vd->vdev_ms_count; m++) {
for (uint64_t m = 0; m < vd->vdev_ms_count; m++) {
metaslab_t *msp = vd->vdev_ms[m];
mutex_enter(&msp->ms_lock);
metaslab_unload(msp);
Expand All @@ -2453,6 +2455,15 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)
* interfaces.
*/
if (msp->ms_sm != NULL) {
(void) fprintf(stderr,
"\rloading space map for "
"vdev %llu of %llu, "
"metaslab %llu of %llu ...",
(longlong_t)c,
(longlong_t)rvd->vdev_children,
(longlong_t)m,
(longlong_t)vd->vdev_ms_count);

msp->ms_ops = &zdb_metaslab_ops;
VERIFY0(space_map_load(msp->ms_sm,
msp->ms_tree, SM_ALLOC));
Expand All @@ -2461,6 +2472,7 @@ zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)
mutex_exit(&msp->ms_lock);
}
}
(void) fprintf(stderr, "\n");
}

spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
Expand Down Expand Up @@ -3460,6 +3472,12 @@ main(int argc, char **argv)
usage();
}

/*
* ZDB does not typically re-read blocks; therefore limit the ARC
* to 256 MB, which can be used entirely for metadata.
*/
zfs_arc_max = zfs_arc_meta_limit = 256 * 1024 * 1024;

kernel_init(FREAD);
g_zfs = libzfs_init();
ASSERT(g_zfs != NULL);
Expand Down

0 comments on commit 06be980

Please sign in to comment.