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>


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 #ifndef _SYS_ZAP_H
  26 #define _SYS_ZAP_H
  27 
  28 /*
  29  * ZAP - ZFS Attribute Processor
  30  *
  31  * The ZAP is a module which sits on top of the DMU (Data Management
  32  * Unit) and implements a higher-level storage primitive using DMU
  33  * objects.  Its primary consumer is the ZPL (ZFS Posix Layer).
  34  *
  35  * A "zapobj" is a DMU object which the ZAP uses to stores attributes.
  36  * Users should use only zap routines to access a zapobj - they should
  37  * not access the DMU object directly using DMU routines.
  38  *
  39  * The attributes stored in a zapobj are name-value pairs.  The name is
  40  * a zero-terminated string of up to ZAP_MAXNAMELEN bytes (including
  41  * terminating NULL).  The value is an array of integers, which may be
  42  * 1, 2, 4, or 8 bytes long.  The total space used by the array (number


 115 /*
 116  * Create a new zapobj with no attributes and return its object number.
 117  * MT_EXACT will cause the zap object to only support MT_EXACT lookups,
 118  * otherwise any matchtype can be used for lookups.
 119  *
 120  * normflags specifies what normalization will be done.  values are:
 121  * 0: no normalization (legacy on-disk format, supports MT_EXACT matching
 122  *     only)
 123  * U8_TEXTPREP_TOLOWER: case normalization will be performed.
 124  *     MT_FIRST/MT_BEST matching will find entries that match without
 125  *     regard to case (eg. looking for "foo" can find an entry "Foo").
 126  * Eventually, other flags will permit unicode normalization as well.
 127  */
 128 uint64_t zap_create(objset_t *ds, dmu_object_type_t ot,
 129     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 130 uint64_t zap_create_norm(objset_t *ds, int normflags, dmu_object_type_t ot,
 131     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 132 uint64_t zap_create_flags(objset_t *os, int normflags, zap_flags_t flags,
 133     dmu_object_type_t ot, int leaf_blockshift, int indirect_blockshift,
 134     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);


 135 
 136 /*
 137  * Create a new zapobj with no attributes from the given (unallocated)
 138  * object number.
 139  */
 140 int zap_create_claim(objset_t *ds, uint64_t obj, dmu_object_type_t ot,
 141     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 142 int zap_create_claim_norm(objset_t *ds, uint64_t obj,
 143     int normflags, dmu_object_type_t ot,
 144     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 145 
 146 /*
 147  * The zapobj passed in must be a valid ZAP object for all of the
 148  * following routines.
 149  */
 150 
 151 /*
 152  * Destroy this zapobj and all its attributes.
 153  *
 154  * Frees the object number using dmu_object_free.


 283 /* Same as zap_join, but add together any duplicated entries. */
 284 int zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj,
 285     dmu_tx_t *tx);
 286 
 287 /*
 288  * Manipulate entries where the name + value are the "same" (the name is
 289  * a stringified version of the value).
 290  */
 291 int zap_add_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx);
 292 int zap_remove_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx);
 293 int zap_lookup_int(objset_t *os, uint64_t obj, uint64_t value);
 294 int zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta,
 295     dmu_tx_t *tx);
 296 
 297 /* Here the key is an int and the value is a different int. */
 298 int zap_add_int_key(objset_t *os, uint64_t obj,
 299     uint64_t key, uint64_t value, dmu_tx_t *tx);
 300 int zap_lookup_int_key(objset_t *os, uint64_t obj,
 301     uint64_t key, uint64_t *valuep);
 302 
 303 /*
 304  * They name is a stringified version of key; increment its value by
 305  * delta.  Zero values will be zap_remove()-ed.
 306  */
 307 int zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta,
 308     dmu_tx_t *tx);
 309 int zap_increment(objset_t *os, uint64_t obj, const char *name, int64_t delta,
 310     dmu_tx_t *tx);
 311 
 312 struct zap;
 313 struct zap_leaf;
 314 typedef struct zap_cursor {
 315         /* This structure is opaque! */
 316         objset_t *zc_objset;
 317         struct zap *zc_zap;
 318         struct zap_leaf *zc_leaf;
 319         uint64_t zc_zapobj;
 320         uint64_t zc_serialized;
 321         uint64_t zc_hash;
 322         uint32_t zc_cd;
 323 } zap_cursor_t;
 324 
 325 typedef struct {
 326         int za_integer_length;
 327         /*
 328          * za_normalization_conflict will be set if there are additional




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  */
  25 
  26 #ifndef _SYS_ZAP_H
  27 #define _SYS_ZAP_H
  28 
  29 /*
  30  * ZAP - ZFS Attribute Processor
  31  *
  32  * The ZAP is a module which sits on top of the DMU (Data Management
  33  * Unit) and implements a higher-level storage primitive using DMU
  34  * objects.  Its primary consumer is the ZPL (ZFS Posix Layer).
  35  *
  36  * A "zapobj" is a DMU object which the ZAP uses to stores attributes.
  37  * Users should use only zap routines to access a zapobj - they should
  38  * not access the DMU object directly using DMU routines.
  39  *
  40  * The attributes stored in a zapobj are name-value pairs.  The name is
  41  * a zero-terminated string of up to ZAP_MAXNAMELEN bytes (including
  42  * terminating NULL).  The value is an array of integers, which may be
  43  * 1, 2, 4, or 8 bytes long.  The total space used by the array (number


 116 /*
 117  * Create a new zapobj with no attributes and return its object number.
 118  * MT_EXACT will cause the zap object to only support MT_EXACT lookups,
 119  * otherwise any matchtype can be used for lookups.
 120  *
 121  * normflags specifies what normalization will be done.  values are:
 122  * 0: no normalization (legacy on-disk format, supports MT_EXACT matching
 123  *     only)
 124  * U8_TEXTPREP_TOLOWER: case normalization will be performed.
 125  *     MT_FIRST/MT_BEST matching will find entries that match without
 126  *     regard to case (eg. looking for "foo" can find an entry "Foo").
 127  * Eventually, other flags will permit unicode normalization as well.
 128  */
 129 uint64_t zap_create(objset_t *ds, dmu_object_type_t ot,
 130     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 131 uint64_t zap_create_norm(objset_t *ds, int normflags, dmu_object_type_t ot,
 132     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 133 uint64_t zap_create_flags(objset_t *os, int normflags, zap_flags_t flags,
 134     dmu_object_type_t ot, int leaf_blockshift, int indirect_blockshift,
 135     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 136 uint64_t zap_create_link(objset_t *os, dmu_object_type_t ot,
 137     uint64_t parent_obj, const char *name, dmu_tx_t *tx);
 138 
 139 /*
 140  * Create a new zapobj with no attributes from the given (unallocated)
 141  * object number.
 142  */
 143 int zap_create_claim(objset_t *ds, uint64_t obj, dmu_object_type_t ot,
 144     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 145 int zap_create_claim_norm(objset_t *ds, uint64_t obj,
 146     int normflags, dmu_object_type_t ot,
 147     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 148 
 149 /*
 150  * The zapobj passed in must be a valid ZAP object for all of the
 151  * following routines.
 152  */
 153 
 154 /*
 155  * Destroy this zapobj and all its attributes.
 156  *
 157  * Frees the object number using dmu_object_free.


 286 /* Same as zap_join, but add together any duplicated entries. */
 287 int zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj,
 288     dmu_tx_t *tx);
 289 
 290 /*
 291  * Manipulate entries where the name + value are the "same" (the name is
 292  * a stringified version of the value).
 293  */
 294 int zap_add_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx);
 295 int zap_remove_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx);
 296 int zap_lookup_int(objset_t *os, uint64_t obj, uint64_t value);
 297 int zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta,
 298     dmu_tx_t *tx);
 299 
 300 /* Here the key is an int and the value is a different int. */
 301 int zap_add_int_key(objset_t *os, uint64_t obj,
 302     uint64_t key, uint64_t value, dmu_tx_t *tx);
 303 int zap_lookup_int_key(objset_t *os, uint64_t obj,
 304     uint64_t key, uint64_t *valuep);
 305 






 306 int zap_increment(objset_t *os, uint64_t obj, const char *name, int64_t delta,
 307     dmu_tx_t *tx);
 308 
 309 struct zap;
 310 struct zap_leaf;
 311 typedef struct zap_cursor {
 312         /* This structure is opaque! */
 313         objset_t *zc_objset;
 314         struct zap *zc_zap;
 315         struct zap_leaf *zc_leaf;
 316         uint64_t zc_zapobj;
 317         uint64_t zc_serialized;
 318         uint64_t zc_hash;
 319         uint32_t zc_cd;
 320 } zap_cursor_t;
 321 
 322 typedef struct {
 323         int za_integer_length;
 324         /*
 325          * za_normalization_conflict will be set if there are additional