aboutsummaryrefslogtreecommitdiffstats
path: root/uts/common/fs/zfs/dmu_object.c
diff options
context:
space:
mode:
authorAndriy Gapon <avg@FreeBSD.org>2013-11-20 10:54:06 +0000
committerAndriy Gapon <avg@FreeBSD.org>2013-11-20 10:54:06 +0000
commita1d7a45c43aec85ccdf658ee53c9652d32c790eb (patch)
tree156986ec2bfd5cbbb534a4950b94bd01021f9f3d /uts/common/fs/zfs/dmu_object.c
parentaad25bd4159c3323f76a7a9fbc11aeea011a40c4 (diff)
downloadsrc-a1d7a45c43aec85ccdf658ee53c9652d32c790eb.tar.gz
src-a1d7a45c43aec85ccdf658ee53c9652d32c790eb.zip
4171 clean up spa_feature_*() interfaces
4172 implement extensible_dataset feature for use by other zpool features illumos/illumos-gate@2acef22db7808606888f8f92715629ff3ba555b9
Notes
Notes: svn path=/vendor-sys/illumos/dist/; revision=258374
Diffstat (limited to 'uts/common/fs/zfs/dmu_object.c')
-rw-r--r--uts/common/fs/zfs/dmu_object.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/uts/common/fs/zfs/dmu_object.c b/uts/common/fs/zfs/dmu_object.c
index 11561f27ca64..5b512ad24e3c 100644
--- a/uts/common/fs/zfs/dmu_object.c
+++ b/uts/common/fs/zfs/dmu_object.c
@@ -27,6 +27,8 @@
#include <sys/dmu_objset.h>
#include <sys/dmu_tx.h>
#include <sys/dnode.h>
+#include <sys/zap.h>
+#include <sys/zfeature.h>
uint64_t
dmu_object_alloc(objset_t *os, dmu_object_type_t ot, int blocksize,
@@ -195,3 +197,54 @@ dmu_object_next(objset_t *os, uint64_t *objectp, boolean_t hole, uint64_t txg)
return (error);
}
+
+/*
+ * Turn this object from old_type into DMU_OTN_ZAP_METADATA, and bump the
+ * refcount on SPA_FEATURE_EXTENSIBLE_DATASET.
+ *
+ * Only for use from syncing context, on MOS objects.
+ */
+void
+dmu_object_zapify(objset_t *mos, uint64_t object, dmu_object_type_t old_type,
+ dmu_tx_t *tx)
+{
+ dnode_t *dn;
+
+ ASSERT(dmu_tx_is_syncing(tx));
+
+ VERIFY0(dnode_hold(mos, object, FTAG, &dn));
+ if (dn->dn_type == DMU_OTN_ZAP_METADATA) {
+ dnode_rele(dn, FTAG);
+ return;
+ }
+ ASSERT3U(dn->dn_type, ==, old_type);
+ ASSERT0(dn->dn_maxblkid);
+ dn->dn_next_type[tx->tx_txg & TXG_MASK] = dn->dn_type =
+ DMU_OTN_ZAP_METADATA;
+ dnode_setdirty(dn, tx);
+ dnode_rele(dn, FTAG);
+
+ mzap_create_impl(mos, object, 0, 0, tx);
+
+ spa_feature_incr(dmu_objset_spa(mos),
+ SPA_FEATURE_EXTENSIBLE_DATASET, tx);
+}
+
+void
+dmu_object_free_zapified(objset_t *mos, uint64_t object, dmu_tx_t *tx)
+{
+ dnode_t *dn;
+ dmu_object_type_t t;
+
+ ASSERT(dmu_tx_is_syncing(tx));
+
+ VERIFY0(dnode_hold(mos, object, FTAG, &dn));
+ t = dn->dn_type;
+ dnode_rele(dn, FTAG);
+
+ if (t == DMU_OTN_ZAP_METADATA) {
+ spa_feature_decr(dmu_objset_spa(mos),
+ SPA_FEATURE_EXTENSIBLE_DATASET, tx);
+ }
+ VERIFY0(dmu_object_free(mos, object, tx));
+}