Skip to content

Commit

Permalink
2619 asynchronous destruction of ZFS file systems
Browse files Browse the repository at this point in the history
2747 SPA versioning with zfs feature flags
Reviewed by: Matt Ahrens <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Richard Lowe <[email protected]>
Reviewed by: Dan Kruchinin <[email protected]>
Approved by: Eric Schrock <[email protected]>
  • Loading branch information
Christopher Siden committed May 21, 2012
1 parent dded083 commit ad135b5
Show file tree
Hide file tree
Showing 70 changed files with 2,680 additions and 696 deletions.
2 changes: 2 additions & 0 deletions usr/src/Makefile.lint
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#

# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.

# include global definitions
include Makefile.master
Expand Down Expand Up @@ -324,6 +325,7 @@ COMMON_SUBDIRS = \
cmd/zdb \
cmd/zdump \
cmd/zfs \
cmd/zhack \
cmd/zinject \
cmd/zlogin \
cmd/zoneadm \
Expand Down
2 changes: 2 additions & 0 deletions usr/src/cmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
# Copyright 2011 Joyent, Inc. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.

include ../Makefile.master

Expand Down Expand Up @@ -454,6 +455,7 @@ COMMON_SUBDIRS= \
zdb \
zdump \
zfs \
zhack \
zic \
zinject \
zlogin \
Expand Down
10 changes: 8 additions & 2 deletions usr/src/cmd/mdb/common/modules/zfs/zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

/* Portions Copyright 2010 Robert Milkowski */
Expand Down Expand Up @@ -1237,6 +1238,9 @@ do_print_vdev(uintptr_t addr, int flags, int depth, int stats,
case VDEV_AUX_VERSION_OLDER:
aux = "VERS_OLDER";
break;
case VDEV_AUX_UNSUP_FEAT:
aux = "UNSUP_FEAT";
break;
case VDEV_AUX_SPARED:
aux = "SPARED";
break;
Expand Down Expand Up @@ -2182,7 +2186,7 @@ zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);
}

tzb = &stats.zab_type[DN_MAX_LEVELS][DMU_OT_NUMTYPES];
tzb = &stats.zab_type[DN_MAX_LEVELS][DMU_OT_TOTAL];
if (tzb->zb_gangs != 0) {
mdb_printf("Ganged blocks: %llu\n",
(longlong_t)tzb->zb_gangs);
Expand All @@ -2198,7 +2202,7 @@ zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf("\nBlocks\tLSIZE\tPSIZE\tASIZE"
"\t avg\t comp\t%%Total\tType\n");

for (t = 0; t <= DMU_OT_NUMTYPES; t++) {
for (t = 0; t <= DMU_OT_TOTAL; t++) {
char csize[NICENUM_BUFLEN], lsize[NICENUM_BUFLEN];
char psize[NICENUM_BUFLEN], asize[NICENUM_BUFLEN];
char avg[NICENUM_BUFLEN];
Expand All @@ -2209,6 +2213,8 @@ zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)

if (t == DMU_OT_DEFERRED)
strcpy(typename, "deferred free");
else if (t == DMU_OT_OTHER)
strcpy(typename, "other");
else if (t == DMU_OT_TOTAL)
strcpy(typename, "Total");
else if (mdb_readstr(typename, sizeof (typename),
Expand Down
72 changes: 65 additions & 7 deletions usr/src/cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/

/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
*/

#include <stdio.h>
Expand Down Expand Up @@ -54,6 +56,7 @@
#include <sys/zfs_fuid.h>
#include <sys/arc.h>
#include <sys/ddt.h>
#include <sys/zfeature.h>
#undef ZFS_MAXNAMELEN
#undef verify
#include <libzfs.h>
Expand All @@ -63,7 +66,8 @@
#define ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ? \
zio_checksum_table[(idx)].ci_name : "UNKNOWN")
#define ZDB_OT_NAME(idx) ((idx) < DMU_OT_NUMTYPES ? \
dmu_ot[(idx)].ot_name : "UNKNOWN")
dmu_ot[(idx)].ot_name : DMU_OT_IS_VALID(idx) ? \
dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
#define ZDB_OT_TYPE(idx) ((idx) < DMU_OT_NUMTYPES ? (idx) : DMU_OT_NUMTYPES)

#ifndef lint
Expand Down Expand Up @@ -1088,7 +1092,7 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)

ASSERT(size == sizeof (*ds));
crtime = ds->ds_creation_time;
zdb_nicenum(ds->ds_used_bytes, used);
zdb_nicenum(ds->ds_referenced_bytes, used);
zdb_nicenum(ds->ds_compressed_bytes, compressed);
zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed);
zdb_nicenum(ds->ds_unique_bytes, unique);
Expand Down Expand Up @@ -1130,6 +1134,44 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)
(void) printf("\t\tbp = %s\n", blkbuf);
}

/* ARGSUSED */
static int
dump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
{
char blkbuf[BP_SPRINTF_LEN];

if (bp->blk_birth != 0) {
sprintf_blkptr(blkbuf, bp);
(void) printf("\t%s\n", blkbuf);
}
return (0);
}

static void
dump_bptree(objset_t *os, uint64_t obj, char *name)
{
char bytes[32];
bptree_phys_t *bt;
dmu_buf_t *db;

if (dump_opt['d'] < 3)
return;

VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
bt = db->db_data;
zdb_nicenum(bt->bt_bytes, bytes);
(void) printf("\n %s: %llu datasets, %s\n",
name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes);
dmu_buf_rele(db, FTAG);

if (dump_opt['d'] < 5)
return;

(void) printf("\n");

(void) bptree_iterate(os, obj, B_FALSE, dump_bptree_cb, NULL, NULL);
}

/* ARGSUSED */
static int
dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
Expand Down Expand Up @@ -1883,11 +1925,13 @@ typedef struct zdb_blkstats {
*/
#define ZDB_OT_DEFERRED (DMU_OT_NUMTYPES + 0)
#define ZDB_OT_DITTO (DMU_OT_NUMTYPES + 1)
#define ZDB_OT_TOTAL (DMU_OT_NUMTYPES + 2)
#define ZDB_OT_OTHER (DMU_OT_NUMTYPES + 2)
#define ZDB_OT_TOTAL (DMU_OT_NUMTYPES + 3)

static char *zdb_ot_extname[] = {
"deferred free",
"dedup ditto",
"other",
"Total",
};

Expand Down Expand Up @@ -1968,9 +2012,10 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,

type = BP_GET_TYPE(bp);

zdb_count_block(zcb, zilog, bp, type);
zdb_count_block(zcb, zilog, bp,
(type & DMU_OT_NEWTYPE) ? ZDB_OT_OTHER : type);

is_metadata = (BP_GET_LEVEL(bp) != 0 || dmu_ot[type].ot_metadata);
is_metadata = (BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type));

if (dump_opt['c'] > 1 || (dump_opt['c'] && is_metadata)) {
int ioerr;
Expand Down Expand Up @@ -2195,6 +2240,12 @@ dump_block_stats(spa_t *spa)
count_block_cb, &zcb, NULL);
(void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
count_block_cb, &zcb, NULL);
if (spa_feature_is_active(spa,
&spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
&zcb, NULL));
}

if (dump_opt['c'] > 1)
flags |= TRAVERSE_PREFETCH_DATA;
Expand Down Expand Up @@ -2371,7 +2422,7 @@ zdb_ddt_add_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
}

if (BP_IS_HOLE(bp) || BP_GET_CHECKSUM(bp) == ZIO_CHECKSUM_OFF ||
BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata)
BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))
return (0);

ddt_key_fill(&zdde_search.zdde_key, bp);
Expand Down Expand Up @@ -2476,7 +2527,14 @@ dump_zpool(spa_t *spa)
dump_bpobj(&spa->spa_deferred_bpobj, "Deferred frees");
if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
dump_bpobj(&spa->spa_dsl_pool->dp_free_bpobj,
"Pool frees");
"Pool snapshot frees");
}

if (spa_feature_is_active(spa,
&spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
dump_bptree(spa->spa_meta_objset,
spa->spa_dsl_pool->dp_bptree_obj,
"Pool dataset frees");
}
dump_dtl(spa->spa_root_vdev, 0);
}
Expand Down
Loading

0 comments on commit ad135b5

Please sign in to comment.