Print this page
2619 asynchronous destruction of ZFS file systems
2747 SPA versioning with zfs feature flags
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <gwilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/sys/dmu.h
          +++ new/usr/src/uts/common/fs/zfs/sys/dmu.h
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
  22   23   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright (c) 2011 by Delphix. All rights reserved.
  24      - */
  25      -/*
       24 + * Copyright (c) 2012 by Delphix. All rights reserved.
  26   25   * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  27   26   * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  28   27   */
  29   28  
  30   29  /* Portions Copyright 2010 Robert Milkowski */
  31   30  
  32   31  #ifndef _SYS_DMU_H
  33   32  #define _SYS_DMU_H
  34   33  
  35   34  /*
↓ open down ↓ 32 lines elided ↑ open up ↑
  68   67  struct spa;
  69   68  struct nvlist;
  70   69  struct arc_buf;
  71   70  struct zio_prop;
  72   71  struct sa_handle;
  73   72  
  74   73  typedef struct objset objset_t;
  75   74  typedef struct dmu_tx dmu_tx_t;
  76   75  typedef struct dsl_dir dsl_dir_t;
  77   76  
       77 +typedef enum dmu_object_byteswap {
       78 +        DMU_BSWAP_UINT8,
       79 +        DMU_BSWAP_UINT16,
       80 +        DMU_BSWAP_UINT32,
       81 +        DMU_BSWAP_UINT64,
       82 +        DMU_BSWAP_ZAP,
       83 +        DMU_BSWAP_DNODE,
       84 +        DMU_BSWAP_OBJSET,
       85 +        DMU_BSWAP_ZNODE,
       86 +        DMU_BSWAP_OLDACL,
       87 +        DMU_BSWAP_ACL,
       88 +        /*
       89 +         * Allocating a new byteswap type number makes the on-disk format
       90 +         * incompatible with any other format that uses the same number.
       91 +         *
       92 +         * Data can usually be structured to work with one of the
       93 +         * DMU_BSWAP_UINT* or DMU_BSWAP_ZAP types.
       94 +         */
       95 +        DMU_BSWAP_NUMFUNCS
       96 +} dmu_object_byteswap_t;
       97 +
       98 +#define DMU_OT_NEWTYPE 0x80
       99 +#define DMU_OT_METADATA 0x40
      100 +#define DMU_OT_BYTESWAP_MASK 0x3f
      101 +
      102 +/*
      103 + * Defines a uint8_t object type. Object types specify if the data
      104 + * in the object is metadata (boolean) and how to byteswap the data
      105 + * (dmu_object_byteswap_t).
      106 + */
      107 +#define DMU_OT(byteswap, metadata) \
      108 +        (DMU_OT_NEWTYPE | \
      109 +        ((metadata) ? DMU_OT_METADATA : 0) | \
      110 +        ((byteswap) & DMU_OT_BYTESWAP_MASK))
      111 +
      112 +#define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \
      113 +        ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \
      114 +        (ot) < DMU_OT_NUMTYPES)
      115 +
      116 +#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
      117 +        ((ot) & DMU_OT_METADATA) : \
      118 +        dmu_ot[(ot)].ot_metadata)
      119 +
      120 +#define DMU_OT_BYTESWAP(ot) (((ot) & DMU_OT_NEWTYPE) ? \
      121 +        ((ot) & DMU_OT_BYTESWAP_MASK) : \
      122 +        dmu_ot[(ot)].ot_byteswap)
      123 +
  78  124  typedef enum dmu_object_type {
  79  125          DMU_OT_NONE,
  80  126          /* general: */
  81  127          DMU_OT_OBJECT_DIRECTORY,        /* ZAP */
  82  128          DMU_OT_OBJECT_ARRAY,            /* UINT64 */
  83  129          DMU_OT_PACKED_NVLIST,           /* UINT8 (XDR by nvlist_pack/unpack) */
  84  130          DMU_OT_PACKED_NVLIST_SIZE,      /* UINT64 */
  85  131          DMU_OT_BPOBJ,                   /* UINT64 */
  86  132          DMU_OT_BPOBJ_HDR,               /* UINT64 */
  87  133          /* spa: */
↓ open down ↓ 44 lines elided ↑ open up ↑
 132  178          DMU_OT_SA,                      /* System attr */
 133  179          DMU_OT_SA_MASTER_NODE,          /* ZAP */
 134  180          DMU_OT_SA_ATTR_REGISTRATION,    /* ZAP */
 135  181          DMU_OT_SA_ATTR_LAYOUTS,         /* ZAP */
 136  182          DMU_OT_SCAN_XLATE,              /* ZAP */
 137  183          DMU_OT_DEDUP,                   /* fake dedup BP from ddt_bp_create() */
 138  184          DMU_OT_DEADLIST,                /* ZAP */
 139  185          DMU_OT_DEADLIST_HDR,            /* UINT64 */
 140  186          DMU_OT_DSL_CLONES,              /* ZAP */
 141  187          DMU_OT_BPOBJ_SUBOBJ,            /* UINT64 */
 142      -        DMU_OT_NUMTYPES
      188 +        /*
      189 +         * Do not allocate new object types here. Doing so makes the on-disk
      190 +         * format incompatible with any other format that uses the same object
      191 +         * type number.
      192 +         *
      193 +         * When creating an object which does not have one of the above types
      194 +         * use the DMU_OTN_* type with the correct byteswap and metadata
      195 +         * values.
      196 +         *
      197 +         * The DMU_OTN_* types do not have entries in the dmu_ot table,
      198 +         * use the DMU_OT_IS_METDATA() and DMU_OT_BYTESWAP() macros instead
      199 +         * of indexing into dmu_ot directly (this works for both DMU_OT_* types
      200 +         * and DMU_OTN_* types).
      201 +         */
      202 +        DMU_OT_NUMTYPES,
      203 +
      204 +        /*
      205 +         * Names for valid types declared with DMU_OT().
      206 +         */
      207 +        DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE),
      208 +        DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE),
      209 +        DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE),
      210 +        DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE),
      211 +        DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE),
      212 +        DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE),
      213 +        DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE),
      214 +        DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE),
      215 +        DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE),
      216 +        DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE),
 143  217  } dmu_object_type_t;
 144  218  
 145  219  typedef enum dmu_objset_type {
 146  220          DMU_OST_NONE,
 147  221          DMU_OST_META,
 148  222          DMU_OST_ZFS,
 149  223          DMU_OST_ZVOL,
 150  224          DMU_OST_OTHER,                  /* For testing only! */
 151  225          DMU_OST_ANY,                    /* Be careful! */
 152  226          DMU_OST_NUMTYPES
↓ open down ↓ 59 lines elided ↑ open up ↑
 212  286          void *db_data;                  /* data in buffer */
 213  287  } dmu_buf_t;
 214  288  
 215  289  typedef void dmu_buf_evict_func_t(struct dmu_buf *db, void *user_ptr);
 216  290  
 217  291  /*
 218  292   * The names of zap entries in the DIRECTORY_OBJECT of the MOS.
 219  293   */
 220  294  #define DMU_POOL_DIRECTORY_OBJECT       1
 221  295  #define DMU_POOL_CONFIG                 "config"
      296 +#define DMU_POOL_FEATURES_FOR_WRITE     "features_for_write"
      297 +#define DMU_POOL_FEATURES_FOR_READ      "features_for_read"
      298 +#define DMU_POOL_FEATURE_DESCRIPTIONS   "feature_descriptions"
 222  299  #define DMU_POOL_ROOT_DATASET           "root_dataset"
 223  300  #define DMU_POOL_SYNC_BPOBJ             "sync_bplist"
 224  301  #define DMU_POOL_ERRLOG_SCRUB           "errlog_scrub"
 225  302  #define DMU_POOL_ERRLOG_LAST            "errlog_last"
 226  303  #define DMU_POOL_SPARES                 "spares"
 227  304  #define DMU_POOL_DEFLATE                "deflate"
 228  305  #define DMU_POOL_HISTORY                "history"
 229  306  #define DMU_POOL_PROPS                  "pool_props"
 230  307  #define DMU_POOL_L2CACHE                "l2cache"
 231  308  #define DMU_POOL_TMP_USERREFS           "tmp_userrefs"
 232  309  #define DMU_POOL_DDT                    "DDT-%s-%s-%s"
 233  310  #define DMU_POOL_DDT_STATS              "DDT-statistics"
 234  311  #define DMU_POOL_CREATION_VERSION       "creation_version"
 235  312  #define DMU_POOL_SCAN                   "scan"
 236  313  #define DMU_POOL_FREE_BPOBJ             "free_bpobj"
      314 +#define DMU_POOL_BPTREE_OBJ             "bptree_obj"
 237  315  
 238  316  /*
 239  317   * Allocate an object from this objset.  The range of object numbers
 240  318   * available is (0, DN_MAX_OBJECT).  Object 0 is the meta-dnode.
 241  319   *
 242  320   * The transaction must be assigned to a txg.  The newly allocated
 243  321   * object will be "held" in the transaction (ie. you can modify the
 244  322   * newly allocated object in this transaction).
 245  323   *
 246  324   * dmu_object_alloc() chooses an object and returns it in *objectp.
↓ open down ↓ 240 lines elided ↑ open up ↑
 487  565   * If there is any error which prevents the transaction from being committed to
 488  566   * disk, the callback will be called with a value of error != 0.
 489  567   */
 490  568  typedef void dmu_tx_callback_func_t(void *dcb_data, int error);
 491  569  
 492  570  void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *dcb_func,
 493  571      void *dcb_data);
 494  572  
 495  573  /*
 496  574   * Free up the data blocks for a defined range of a file.  If size is
 497      - * zero, the range from offset to end-of-file is freed.
      575 + * -1, the range from offset to end-of-file is freed.
 498  576   */
 499  577  int dmu_free_range(objset_t *os, uint64_t object, uint64_t offset,
 500  578          uint64_t size, dmu_tx_t *tx);
 501  579  int dmu_free_long_range(objset_t *os, uint64_t object, uint64_t offset,
 502  580          uint64_t size);
 503  581  int dmu_free_object(objset_t *os, uint64_t object);
 504  582  
 505  583  /*
 506  584   * Convenience functions.
 507  585   *
↓ open down ↓ 49 lines elided ↑ open up ↑
 557  635          uint8_t doi_compress;
 558  636          uint8_t doi_pad[5];
 559  637          uint64_t doi_physical_blocks_512;       /* data + metadata, 512b blks */
 560  638          uint64_t doi_max_offset;
 561  639          uint64_t doi_fill_count;                /* number of non-empty blocks */
 562  640  } dmu_object_info_t;
 563  641  
 564  642  typedef void arc_byteswap_func_t(void *buf, size_t size);
 565  643  
 566  644  typedef struct dmu_object_type_info {
 567      -        arc_byteswap_func_t     *ot_byteswap;
      645 +        dmu_object_byteswap_t   ot_byteswap;
 568  646          boolean_t               ot_metadata;
 569  647          char                    *ot_name;
 570  648  } dmu_object_type_info_t;
 571  649  
      650 +typedef struct dmu_object_byteswap_info {
      651 +        arc_byteswap_func_t     *ob_func;
      652 +        char                    *ob_name;
      653 +} dmu_object_byteswap_info_t;
      654 +
 572  655  extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES];
      656 +extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS];
 573  657  
 574  658  /*
 575  659   * Get information on a DMU object.
 576  660   *
 577  661   * Return 0 on success or ENOENT if object is not allocated.
 578  662   *
 579  663   * If doi is NULL, just indicates whether the object exists.
 580  664   */
 581  665  int dmu_object_info(objset_t *os, uint64_t object, dmu_object_info_t *doi);
 582  666  void dmu_object_info_from_dnode(struct dnode *dn, dmu_object_info_t *doi);
↓ open down ↓ 166 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX