From owner-svn-src-vendor@freebsd.org Wed Aug 12 23:39:03 2015 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 40CAE9A0BCF; Wed, 12 Aug 2015 23:39:03 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 24F4EB20; Wed, 12 Aug 2015 23:39:03 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7CNd3cg098232; Wed, 12 Aug 2015 23:39:03 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7CNd2YF098227; Wed, 12 Aug 2015 23:39:02 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201508122339.t7CNd2YF098227@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 12 Aug 2015 23:39:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r286707 - vendor-sys/illumos/dist/common/zfs vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zdb vendor/illumos/dist/cmd/... X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Aug 2015 23:39:03 -0000 Author: mav Date: Wed Aug 12 23:38:58 2015 New Revision: 286707 URL: https://svnweb.freebsd.org/changeset/base/286707 Log: 5959 clean up per-dataset feature count code Reviewed by: Toomas Soome Reviewed by: George Wilson Reviewed by: Alex Reece Approved by: Richard Lowe Author: Matthew Ahrens illumos/illumos-gate@ca0cc3918a1789fa839194af2a9245f801a06b1a A ZFS feature flags (large blocks) tracks its refcounts as the number of datasets that have ever used the feature. Several features of this type are planned to be added (new checksum functions). This code should be made common infrastructure rather than duplicating the code for each feature. Modified: vendor/illumos/dist/cmd/zdb/zdb.c vendor/illumos/dist/cmd/zhack/zhack.c vendor/illumos/dist/cmd/zpool/zpool_main.c Changes in other areas also in this revision: Modified: vendor-sys/illumos/dist/common/zfs/zfeature_common.c vendor-sys/illumos/dist/common/zfs/zfeature_common.h vendor-sys/illumos/dist/uts/common/fs/zfs/dbuf.c vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_send.c vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_dataset.c vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_destroy.c vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dsl_dataset.h vendor-sys/illumos/dist/uts/common/fs/zfs/zfeature.c Modified: vendor/illumos/dist/cmd/zdb/zdb.c ============================================================================== --- vendor/illumos/dist/cmd/zdb/zdb.c Wed Aug 12 22:51:08 2015 (r286706) +++ vendor/illumos/dist/cmd/zdb/zdb.c Wed Aug 12 23:38:58 2015 (r286707) @@ -21,7 +21,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. */ #include @@ -2198,7 +2198,7 @@ dump_label(const char *dev) (void) close(fd); } -static uint64_t num_large_blocks; +static uint64_t dataset_feature_count[SPA_FEATURES]; /*ARGSUSED*/ static int @@ -2212,8 +2212,15 @@ dump_one_dir(const char *dsname, void *a (void) printf("Could not open %s, error %d\n", dsname, error); return (0); } - if (dmu_objset_ds(os)->ds_large_blocks) - num_large_blocks++; + + for (spa_feature_t f = 0; f < SPA_FEATURES; f++) { + if (!dmu_objset_ds(os)->ds_feature_inuse[f]) + continue; + ASSERT(spa_feature_table[f].fi_flags & + ZFEATURE_FLAG_PER_DATASET); + dataset_feature_count[f]++; + } + dump_dir(os); dmu_objset_disown(os, FTAG); fuid_table_destroy(); @@ -3010,7 +3017,6 @@ dump_zpool(spa_t *spa) dump_metaslab_groups(spa); if (dump_opt['d'] || dump_opt['i']) { - uint64_t refcount; dump_dir(dp->dp_meta_objset); if (dump_opt['d'] >= 3) { dump_full_bpobj(&spa->spa_deferred_bpobj, @@ -3032,17 +3038,29 @@ dump_zpool(spa_t *spa) (void) dmu_objset_find(spa_name(spa), dump_one_dir, NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN); - (void) feature_get_refcount(spa, - &spa_feature_table[SPA_FEATURE_LARGE_BLOCKS], &refcount); - if (num_large_blocks != refcount) { - (void) printf("large_blocks feature refcount mismatch: " - "expected %lld != actual %lld\n", - (longlong_t)num_large_blocks, - (longlong_t)refcount); - rc = 2; - } else { - (void) printf("Verified large_blocks feature refcount " - "is correct (%llu)\n", (longlong_t)refcount); + for (spa_feature_t f = 0; f < SPA_FEATURES; f++) { + uint64_t refcount; + + if (!(spa_feature_table[f].fi_flags & + ZFEATURE_FLAG_PER_DATASET)) { + ASSERT0(dataset_feature_count[f]); + continue; + } + (void) feature_get_refcount(spa, + &spa_feature_table[f], &refcount); + if (dataset_feature_count[f] != refcount) { + (void) printf("%s feature refcount mismatch: " + "%lld datasets != %lld refcount\n", + spa_feature_table[f].fi_uname, + (longlong_t)dataset_feature_count[f], + (longlong_t)refcount); + rc = 2; + } else { + (void) printf("Verified %s feature refcount " + "of %llu is correct\n", + spa_feature_table[f].fi_uname, + (longlong_t)refcount); + } } } if (rc == 0 && (dump_opt['b'] || dump_opt['c'])) Modified: vendor/illumos/dist/cmd/zhack/zhack.c ============================================================================== --- vendor/illumos/dist/cmd/zhack/zhack.c Wed Aug 12 22:51:08 2015 (r286706) +++ vendor/illumos/dist/cmd/zhack/zhack.c Wed Aug 12 23:38:58 2015 (r286707) @@ -20,7 +20,7 @@ */ /* - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. */ @@ -294,8 +294,8 @@ zhack_feature_enable_sync(void *arg, dmu feature_enable_sync(spa, feature, tx); spa_history_log_internal(spa, "zhack enable feature", tx, - "guid=%s can_readonly=%u", - feature->fi_guid, feature->fi_can_readonly); + "guid=%s flags=%x", + feature->fi_guid, feature->fi_flags); } static void @@ -314,9 +314,7 @@ zhack_do_feature_enable(int argc, char * */ desc = NULL; feature.fi_uname = "zhack"; - feature.fi_mos = B_FALSE; - feature.fi_can_readonly = B_FALSE; - feature.fi_activate_on_enable = B_FALSE; + feature.fi_flags = 0; feature.fi_depends = nodeps; feature.fi_feature = SPA_FEATURE_NONE; @@ -324,7 +322,7 @@ zhack_do_feature_enable(int argc, char * while ((c = getopt(argc, argv, "rmd:")) != -1) { switch (c) { case 'r': - feature.fi_can_readonly = B_TRUE; + feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT; break; case 'd': desc = strdup(optarg); @@ -413,7 +411,7 @@ zhack_do_feature_ref(int argc, char **ar * disk later. */ feature.fi_uname = "zhack"; - feature.fi_mos = B_FALSE; + feature.fi_flags = 0; feature.fi_desc = NULL; feature.fi_depends = nodeps; feature.fi_feature = SPA_FEATURE_NONE; @@ -422,7 +420,7 @@ zhack_do_feature_ref(int argc, char **ar while ((c = getopt(argc, argv, "md")) != -1) { switch (c) { case 'm': - feature.fi_mos = B_TRUE; + feature.fi_flags |= ZFEATURE_FLAG_MOS; break; case 'd': decr = B_TRUE; @@ -455,10 +453,10 @@ zhack_do_feature_ref(int argc, char **ar if (0 == zap_contains(mos, spa->spa_feat_for_read_obj, feature.fi_guid)) { - feature.fi_can_readonly = B_FALSE; + feature.fi_flags &= ~ZFEATURE_FLAG_READONLY_COMPAT; } else if (0 == zap_contains(mos, spa->spa_feat_for_write_obj, feature.fi_guid)) { - feature.fi_can_readonly = B_TRUE; + feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT; } else { fatal(spa, FTAG, "feature is not enabled: %s", feature.fi_guid); } Modified: vendor/illumos/dist/cmd/zpool/zpool_main.c ============================================================================== --- vendor/illumos/dist/cmd/zpool/zpool_main.c Wed Aug 12 22:51:08 2015 (r286706) +++ vendor/illumos/dist/cmd/zpool/zpool_main.c Wed Aug 12 23:38:58 2015 (r286707) @@ -22,7 +22,7 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2011 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2011, 2014 by Delphix. All rights reserved. + * Copyright (c) 2011, 2015 by Delphix. All rights reserved. * Copyright (c) 2012 by Frederik Wessels. All rights reserved. * Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved. */ @@ -4714,7 +4714,8 @@ zpool_do_upgrade(int argc, char **argv) "---------------\n"); for (i = 0; i < SPA_FEATURES; i++) { zfeature_info_t *fi = &spa_feature_table[i]; - const char *ro = fi->fi_can_readonly ? + const char *ro = + (fi->fi_flags & ZFEATURE_FLAG_READONLY_COMPAT) ? " (read-only compatible)" : ""; (void) printf("%-37s%s\n", fi->fi_uname, ro);