Print this page
4171 clean up spa_feature_*() interfaces
4172 implement extensible_dataset feature for use by other zpool features
Reviewed by: Max Grossman <max.grossman@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dmu_object.c
          +++ new/usr/src/uts/common/fs/zfs/dmu_object.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2013 by Delphix. All rights reserved.
  24   24   */
  25   25  
  26   26  #include <sys/dmu.h>
  27   27  #include <sys/dmu_objset.h>
  28   28  #include <sys/dmu_tx.h>
  29   29  #include <sys/dnode.h>
       30 +#include <sys/zap.h>
       31 +#include <sys/zfeature.h>
  30   32  
  31   33  uint64_t
  32   34  dmu_object_alloc(objset_t *os, dmu_object_type_t ot, int blocksize,
  33   35      dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx)
  34   36  {
  35   37          uint64_t object;
  36   38          uint64_t L2_dnode_count = DNODES_PER_BLOCK <<
  37   39              (DMU_META_DNODE(os)->dn_indblkshift - SPA_BLKPTRSHIFT);
  38   40          dnode_t *dn = NULL;
  39   41          int restarted = B_FALSE;
↓ open down ↓ 147 lines elided ↑ open up ↑
 187  189  {
 188  190          uint64_t offset = (*objectp + 1) << DNODE_SHIFT;
 189  191          int error;
 190  192  
 191  193          error = dnode_next_offset(DMU_META_DNODE(os),
 192  194              (hole ? DNODE_FIND_HOLE : 0), &offset, 0, DNODES_PER_BLOCK, txg);
 193  195  
 194  196          *objectp = offset >> DNODE_SHIFT;
 195  197  
 196  198          return (error);
      199 +}
      200 +
      201 +/*
      202 + * Turn this object from old_type into DMU_OTN_ZAP_METADATA, and bump the
      203 + * refcount on SPA_FEATURE_EXTENSIBLE_DATASET.
      204 + *
      205 + * Only for use from syncing context, on MOS objects.
      206 + */
      207 +void
      208 +dmu_object_zapify(objset_t *mos, uint64_t object, dmu_object_type_t old_type,
      209 +    dmu_tx_t *tx)
      210 +{
      211 +        dnode_t *dn;
      212 +
      213 +        ASSERT(dmu_tx_is_syncing(tx));
      214 +
      215 +        VERIFY0(dnode_hold(mos, object, FTAG, &dn));
      216 +        if (dn->dn_type == DMU_OTN_ZAP_METADATA) {
      217 +                dnode_rele(dn, FTAG);
      218 +                return;
      219 +        }
      220 +        ASSERT3U(dn->dn_type, ==, old_type);
      221 +        ASSERT0(dn->dn_maxblkid);
      222 +        dn->dn_next_type[tx->tx_txg & TXG_MASK] = dn->dn_type =
      223 +            DMU_OTN_ZAP_METADATA;
      224 +        dnode_setdirty(dn, tx);
      225 +        dnode_rele(dn, FTAG);
      226 +
      227 +        mzap_create_impl(mos, object, 0, 0, tx);
      228 +
      229 +        spa_feature_incr(dmu_objset_spa(mos),
      230 +            SPA_FEATURE_EXTENSIBLE_DATASET, tx);
      231 +}
      232 +
      233 +void
      234 +dmu_object_free_zapified(objset_t *mos, uint64_t object, dmu_tx_t *tx)
      235 +{
      236 +        dnode_t *dn;
      237 +        dmu_object_type_t t;
      238 +
      239 +        ASSERT(dmu_tx_is_syncing(tx));
      240 +
      241 +        VERIFY0(dnode_hold(mos, object, FTAG, &dn));
      242 +        t = dn->dn_type;
      243 +        dnode_rele(dn, FTAG);
      244 +
      245 +        if (t == DMU_OTN_ZAP_METADATA) {
      246 +                spa_feature_decr(dmu_objset_spa(mos),
      247 +                    SPA_FEATURE_EXTENSIBLE_DATASET, tx);
      248 +        }
      249 +        VERIFY0(dmu_object_free(mos, object, tx));
 197  250  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX