fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
66328dd3ff7c6b3566c06478698593e061733076ahrens * Common Development and Distribution License (the "License").
66328dd3ff7c6b3566c06478698593e061733076ahrens * You may not use this file except in compliance with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or http://www.opensolaris.org/os/licensing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens * Copyright (c) 2012, 2016 by Delphix. All rights reserved.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifndef _SYS_ZAP_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define _SYS_ZAP_H
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ZAP - ZFS Attribute Processor
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * The ZAP is a module which sits on top of the DMU (Data Management
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Unit) and implements a higher-level storage primitive using DMU
fa9e4066f08beec538e775443c5be79dd423fcabahrens * objects. Its primary consumer is the ZPL (ZFS Posix Layer).
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * A "zapobj" is a DMU object which the ZAP uses to stores attributes.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Users should use only zap routines to access a zapobj - they should
fa9e4066f08beec538e775443c5be79dd423fcabahrens * not access the DMU object directly using DMU routines.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The attributes stored in a zapobj are name-value pairs. The name is
66328dd3ff7c6b3566c06478698593e061733076ahrens * a zero-terminated string of up to ZAP_MAXNAMELEN bytes (including
66328dd3ff7c6b3566c06478698593e061733076ahrens * terminating NULL). The value is an array of integers, which may be
66328dd3ff7c6b3566c06478698593e061733076ahrens * 1, 2, 4, or 8 bytes long. The total space used by the array (number
66328dd3ff7c6b3566c06478698593e061733076ahrens * of integers * integer length) can be up to ZAP_MAXVALUELEN bytes.
66328dd3ff7c6b3566c06478698593e061733076ahrens * Note that an 8-byte integer value can be used to store the location
66328dd3ff7c6b3566c06478698593e061733076ahrens * (object number) of another dmu object (which may be itself a zapobj).
66328dd3ff7c6b3566c06478698593e061733076ahrens * Note that you can use a zero-length attribute to store a single bit
66328dd3ff7c6b3566c06478698593e061733076ahrens * of information - the attribute is present or not.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The ZAP routines are thread-safe. However, you must observe the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * DMU's restriction that a transaction may not be operated on
fa9e4066f08beec538e775443c5be79dd423fcabahrens * concurrently.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Any of the routines that return an int may return an I/O error (EIO
fa9e4066f08beec538e775443c5be79dd423fcabahrens * or ECHECKSUM).
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Implementation / Performance Notes:
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The ZAP is intended to operate most efficiently on attributes with
66328dd3ff7c6b3566c06478698593e061733076ahrens * short (49 bytes or less) names and single 8-byte values, for which
66328dd3ff7c6b3566c06478698593e061733076ahrens * the microzap will be used. The ZAP should be efficient enough so
66328dd3ff7c6b3566c06478698593e061733076ahrens * that the user does not need to cache these attributes.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The ZAP's locking scheme makes its routines thread-safe. Operations
fa9e4066f08beec538e775443c5be79dd423fcabahrens * on different zapobjs will be processed concurrently. Operations on
fa9e4066f08beec538e775443c5be79dd423fcabahrens * the same zapobj which only read data will be processed concurrently.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Operations on the same zapobj which modify data will be processed
fa9e4066f08beec538e775443c5be79dd423fcabahrens * concurrently when there are many attributes in the zapobj (because
66328dd3ff7c6b3566c06478698593e061733076ahrens * the ZAP uses per-block locking - more than 128 * (number of cpus)
fa9e4066f08beec538e775443c5be79dd423fcabahrens * small attributes will suffice).
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * We're using zero-terminated byte strings (ie. ASCII or UTF-8 C
fa9e4066f08beec538e775443c5be79dd423fcabahrens * strings) for the names of attributes, rather than a byte string
fa9e4066f08beec538e775443c5be79dd423fcabahrens * bounded by an explicit length. If some day we want to support names
fa9e4066f08beec538e775443c5be79dd423fcabahrens * in character sets which have embedded zeros (eg. UTF-16, UTF-32),
fa9e4066f08beec538e775443c5be79dd423fcabahrens * we'll have to add routines for using length-bounded strings.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#include <sys/dmu.h>
0c779ad424a92a84d1e07d47cab7f8009189202bMatthew Ahrens#include <sys/refcount.h>
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw/*
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * Specifies matching criteria for ZAP lookups.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwtypedef enum matchtype
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw{
f7170741490edba9d1d9c697c177c887172bc741Will Andrews /* Only find an exact match (non-normalized) */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MT_EXACT,
f7170741490edba9d1d9c697c177c887172bc741Will Andrews /*
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * If there is an exact match, find that, otherwise find the
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * first normalized match.
f7170741490edba9d1d9c697c177c887172bc741Will Andrews */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MT_BEST,
f7170741490edba9d1d9c697c177c887172bc741Will Andrews /*
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * Find the "first" normalized (case and Unicode form) match;
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * the designated "first" match will not change as long as the
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * set of entries with this normalization doesn't change.
f7170741490edba9d1d9c697c177c887172bc741Will Andrews */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw MT_FIRST
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw} matchtype_t;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwicktypedef enum zap_flags {
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick /* Use 64-bit hash value (serialized cursors will always use 64-bits) */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick ZAP_FLAG_HASH64 = 1 << 0,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick /* Key is binary, not string (zap_add_uint64() can be used) */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick ZAP_FLAG_UINT64_KEY = 1 << 1,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick /*
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * First word of key (which must be an array of uint64) is
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick * already randomly distributed.
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick ZAP_FLAG_PRE_HASHED_KEY = 1 << 2,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick} zap_flags_t;
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Create a new zapobj with no attributes and return its object number.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * MT_EXACT will cause the zap object to only support MT_EXACT lookups,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * otherwise any matchtype can be used for lookups.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * normflags specifies what normalization will be done. values are:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * 0: no normalization (legacy on-disk format, supports MT_EXACT matching
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * only)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * U8_TEXTPREP_TOLOWER: case normalization will be performed.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * MT_FIRST/MT_BEST matching will find entries that match without
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * regard to case (eg. looking for "foo" can find an entry "Foo").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Eventually, other flags will permit unicode normalization as well.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensuint64_t zap_create(objset_t *ds, dmu_object_type_t ot,
fa9e4066f08beec538e775443c5be79dd423fcabahrens dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwuint64_t zap_create_norm(objset_t *ds, int normflags, dmu_object_type_t ot,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickuint64_t zap_create_flags(objset_t *os, int normflags, zap_flags_t flags,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dmu_object_type_t ot, int leaf_blockshift, int indirect_blockshift,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Sidenuint64_t zap_create_link(objset_t *os, dmu_object_type_t ot,
ad135b5d644628e791c3188a6ecbd9c257961ef8Christopher Siden uint64_t parent_obj, const char *name, dmu_tx_t *tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens/*
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * Initialize an already-allocated object.
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens */
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensvoid mzap_create_impl(objset_t *os, uint64_t obj, int normflags,
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens zap_flags_t flags, dmu_tx_t *tx);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Create a new zapobj with no attributes from the given (unallocated)
fa9e4066f08beec538e775443c5be79dd423fcabahrens * object number.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_create_claim(objset_t *ds, uint64_t obj, dmu_object_type_t ot,
fa9e4066f08beec538e775443c5be79dd423fcabahrens dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint zap_create_claim_norm(objset_t *ds, uint64_t obj,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw int normflags, dmu_object_type_t ot,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The zapobj passed in must be a valid ZAP object for all of the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * following routines.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Destroy this zapobj and all its attributes.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Frees the object number using dmu_object_free.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_destroy(objset_t *ds, uint64_t zapobj, dmu_tx_t *tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Manipulate attributes.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * 'integer_size' is in bytes, and must be 1, 2, 4, or 8.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Retrieve the contents of the attribute with the given name.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If the requested attribute does not exist, the call will fail and
fa9e4066f08beec538e775443c5be79dd423fcabahrens * return ENOENT.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If 'integer_size' is smaller than the attribute's integer size, the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * call will fail and return EINVAL.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If 'integer_size' is equal to or larger than the attribute's integer
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * size, the call will succeed and return 0.
f7170741490edba9d1d9c697c177c887172bc741Will Andrews *
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * When converting to a larger integer size, the integers will be treated as
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * unsigned (ie. no sign-extension will be performed).
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * 'num_integers' is the length (in integers) of 'buf'.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If the attribute is longer than the buffer, as many integers as will
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fit will be transferred to 'buf'. If the entire attribute was not
fa9e4066f08beec538e775443c5be79dd423fcabahrens * transferred, the call will return EOVERFLOW.
f7170741490edba9d1d9c697c177c887172bc741Will Andrews */
f7170741490edba9d1d9c697c177c887172bc741Will Andrewsint zap_lookup(objset_t *ds, uint64_t zapobj, const char *name,
f7170741490edba9d1d9c697c177c887172bc741Will Andrews uint64_t integer_size, uint64_t num_integers, void *buf);
f7170741490edba9d1d9c697c177c887172bc741Will Andrews
f7170741490edba9d1d9c697c177c887172bc741Will Andrews/*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If rn_len is nonzero, realname will be set to the name of the found
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * entry (which may be different from the requested name if matchtype is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * not MT_EXACT).
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw *
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * If normalization_conflictp is not NULL, it will be set if there is
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * another name with the same case/unicode normalized form.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint zap_lookup_norm(objset_t *ds, uint64_t zapobj, const char *name,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw uint64_t integer_size, uint64_t num_integers, void *buf,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw matchtype_t mt, char *realname, int rn_len,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw boolean_t *normalization_conflictp);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint zap_lookup_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int key_numints, uint64_t integer_size, uint64_t num_integers, void *buf);
92241e0b80813d0b83c08e730a29b9d1831794fcTom Ericksonint zap_contains(objset_t *ds, uint64_t zapobj, const char *name);
c7cd242109c82107ec2e50013369e92be9d77702George Wilsonint zap_prefetch_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
c7cd242109c82107ec2e50013369e92be9d77702George Wilson int key_numints);
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrensint zap_lookup_by_dnode(dnode_t *dn, const char *name,
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens uint64_t integer_size, uint64_t num_integers, void *buf);
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrensint zap_lookup_norm_by_dnode(dnode_t *dn, const char *name,
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens uint64_t integer_size, uint64_t num_integers, void *buf,
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens matchtype_t mt, char *realname, int rn_len,
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens boolean_t *ncp);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrensint zap_count_write_by_dnode(dnode_t *dn, const char *name,
0c779ad424a92a84d1e07d47cab7f8009189202bMatthew Ahrens int add, refcount_t *towrite, refcount_t *tooverwrite);
3d6926289465757c3da780cea696825b0d730283Sanjeev Bagewadi
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Create an attribute with the given name and value.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If an attribute with the given name already exists, the call will
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fail and return EEXIST.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint zap_add(objset_t *ds, uint64_t zapobj, const char *key,
fa9e4066f08beec538e775443c5be79dd423fcabahrens int integer_size, uint64_t num_integers,
fa9e4066f08beec538e775443c5be79dd423fcabahrens const void *val, dmu_tx_t *tx);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint zap_add_uint64(objset_t *ds, uint64_t zapobj, const uint64_t *key,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int key_numints, int integer_size, uint64_t num_integers,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick const void *val, dmu_tx_t *tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Set the attribute with the given name to the given value. If an
fa9e4066f08beec538e775443c5be79dd423fcabahrens * attribute with the given name does not exist, it will be created. If
fa9e4066f08beec538e775443c5be79dd423fcabahrens * an attribute with the given name already exists, the previous value
fa9e4066f08beec538e775443c5be79dd423fcabahrens * will be overwritten. The integer_size may be different from the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * existing attribute's integer size, in which case the attribute's
fa9e4066f08beec538e775443c5be79dd423fcabahrens * integer size will be updated to the new value.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_update(objset_t *ds, uint64_t zapobj, const char *name,
fa9e4066f08beec538e775443c5be79dd423fcabahrens int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint zap_update_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int key_numints,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int integer_size, uint64_t num_integers, const void *val, dmu_tx_t *tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Get the length (in integers) and the integer size of the specified
fa9e4066f08beec538e775443c5be79dd423fcabahrens * attribute.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If the requested attribute does not exist, the call will fail and
fa9e4066f08beec538e775443c5be79dd423fcabahrens * return ENOENT.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_length(objset_t *ds, uint64_t zapobj, const char *name,
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t *integer_size, uint64_t *num_integers);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint zap_length_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int key_numints, uint64_t *integer_size, uint64_t *num_integers);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Remove the specified attribute.
fa9e4066f08beec538e775443c5be79dd423fcabahrens *
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If the specified attribute does not exist, the call will fail and
fa9e4066f08beec538e775443c5be79dd423fcabahrens * return ENOENT.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_remove(objset_t *ds, uint64_t zapobj, const char *name, dmu_tx_t *tx);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwint zap_remove_norm(objset_t *ds, uint64_t zapobj, const char *name,
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw matchtype_t mt, dmu_tx_t *tx);
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwickint zap_remove_uint64(objset_t *os, uint64_t zapobj, const uint64_t *key,
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick int key_numints, dmu_tx_t *tx);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Returns (in *count) the number of attributes in the specified zap
fa9e4066f08beec538e775443c5be79dd423fcabahrens * object.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_count(objset_t *ds, uint64_t zapobj, uint64_t *count);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
e7437265dc2a4920c197ed4337665539d358b22cahrens * Returns (in name) the name of the entry whose (value & mask)
fa9e4066f08beec538e775443c5be79dd423fcabahrens * (za_first_integer) is value, or ENOENT if not found. The string
e7437265dc2a4920c197ed4337665539d358b22cahrens * pointed to by name must be at least 256 bytes long. If mask==0, the
e7437265dc2a4920c197ed4337665539d358b22cahrens * match must be exact (ie, same as mask=-1ULL).
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
e7437265dc2a4920c197ed4337665539d358b22cahrensint zap_value_search(objset_t *os, uint64_t zapobj,
e7437265dc2a4920c197ed4337665539d358b22cahrens uint64_t value, uint64_t mask, char *name);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
088f389458728c464569a5506b58070254fa4f7dahrens/*
088f389458728c464569a5506b58070254fa4f7dahrens * Transfer all the entries from fromobj into intoobj. Only works on
088f389458728c464569a5506b58070254fa4f7dahrens * int_size=8 num_integers=1 values. Fails if there are any duplicated
088f389458728c464569a5506b58070254fa4f7dahrens * entries.
088f389458728c464569a5506b58070254fa4f7dahrens */
088f389458728c464569a5506b58070254fa4f7dahrensint zap_join(objset_t *os, uint64_t fromobj, uint64_t intoobj, dmu_tx_t *tx);
088f389458728c464569a5506b58070254fa4f7dahrens
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling/* Same as zap_join, but set the values to 'value'. */
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint zap_join_key(objset_t *os, uint64_t fromobj, uint64_t intoobj,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling uint64_t value, dmu_tx_t *tx);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling/* Same as zap_join, but add together any duplicated entries. */
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint zap_join_increment(objset_t *os, uint64_t fromobj, uint64_t intoobj,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling dmu_tx_t *tx);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling
088f389458728c464569a5506b58070254fa4f7dahrens/*
088f389458728c464569a5506b58070254fa4f7dahrens * Manipulate entries where the name + value are the "same" (the name is
088f389458728c464569a5506b58070254fa4f7dahrens * a stringified version of the value).
088f389458728c464569a5506b58070254fa4f7dahrens */
088f389458728c464569a5506b58070254fa4f7dahrensint zap_add_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx);
088f389458728c464569a5506b58070254fa4f7dahrensint zap_remove_int(objset_t *os, uint64_t obj, uint64_t value, dmu_tx_t *tx);
088f389458728c464569a5506b58070254fa4f7dahrensint zap_lookup_int(objset_t *os, uint64_t obj, uint64_t value);
9966ca11f4a1481acce85f690fa59e4084050627Matthew Ahrensint zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta,
9966ca11f4a1481acce85f690fa59e4084050627Matthew Ahrens dmu_tx_t *tx);
088f389458728c464569a5506b58070254fa4f7dahrens
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling/* Here the key is an int and the value is a different int. */
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint zap_add_int_key(objset_t *os, uint64_t obj,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling uint64_t key, uint64_t value, dmu_tx_t *tx);
f17457368189aa911f774c38c1f21875a568bdcaMatthew Ahrensint zap_update_int_key(objset_t *os, uint64_t obj,
f17457368189aa911f774c38c1f21875a568bdcaMatthew Ahrens uint64_t key, uint64_t value, dmu_tx_t *tx);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint zap_lookup_int_key(objset_t *os, uint64_t obj,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling uint64_t key, uint64_t *valuep);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Lingint zap_increment(objset_t *os, uint64_t obj, const char *name, int64_t delta,
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling dmu_tx_t *tx);
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling
87e5029a3226958edab1512d6182bc74d8d80c9aahrensstruct zap;
87e5029a3226958edab1512d6182bc74d8d80c9aahrensstruct zap_leaf;
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct zap_cursor {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /* This structure is opaque! */
fa9e4066f08beec538e775443c5be79dd423fcabahrens objset_t *zc_objset;
87e5029a3226958edab1512d6182bc74d8d80c9aahrens struct zap *zc_zap;
87e5029a3226958edab1512d6182bc74d8d80c9aahrens struct zap_leaf *zc_leaf;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zc_zapobj;
b24ab6762772a3f6a89393947930c7fa61306783Jeff Bonwick uint64_t zc_serialized;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zc_hash;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint32_t zc_cd;
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zap_cursor_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct {
fa9e4066f08beec538e775443c5be79dd423fcabahrens int za_integer_length;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /*
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * za_normalization_conflict will be set if there are additional
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * entries with this normalized form (eg, "foo" and "Foo").
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw */
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw boolean_t za_normalization_conflict;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t za_num_integers;
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t za_first_integer; /* no sign extension for <8byte ints */
9adfa60d484ce2435f5af77cc99dcd4e692b6660Matthew Ahrens char za_name[ZAP_MAXNAMELEN];
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zap_attribute_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The interface for listing all the attributes of a zapobj can be
fa9e4066f08beec538e775443c5be79dd423fcabahrens * thought of as cursor moving down a list of the attributes one by
fa9e4066f08beec538e775443c5be79dd423fcabahrens * one. The cookie returned by the zap_cursor_serialize routine is
fa9e4066f08beec538e775443c5be79dd423fcabahrens * persistent across system calls (and across reboot, even).
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Initialize a zap cursor, pointing to the "first" attribute of the
87e5029a3226958edab1512d6182bc74d8d80c9aahrens * zapobj. You must _fini the cursor when you are done with it.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid zap_cursor_init(zap_cursor_t *zc, objset_t *ds, uint64_t zapobj);
87e5029a3226958edab1512d6182bc74d8d80c9aahrensvoid zap_cursor_fini(zap_cursor_t *zc);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Get the attribute currently pointed to by the cursor. Returns
fa9e4066f08beec538e775443c5be79dd423fcabahrens * ENOENT if at the end of the attributes.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_cursor_retrieve(zap_cursor_t *zc, zap_attribute_t *za);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Advance the cursor to the next attribute.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid zap_cursor_advance(zap_cursor_t *zc);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Get a persistent cookie pointing to the current position of the zap
fa9e4066f08beec538e775443c5be79dd423fcabahrens * cursor. The low 4 bits in the cookie are always zero, and thus can
fa9e4066f08beec538e775443c5be79dd423fcabahrens * be used as to differentiate a serialized cookie from a different type
fa9e4066f08beec538e775443c5be79dd423fcabahrens * of value. The cookie will be less than 2^32 as long as there are
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fewer than 2^22 (4.2 million) entries in the zap object.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensuint64_t zap_cursor_serialize(zap_cursor_t *zc);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Initialize a zap cursor pointing to the position recorded by
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zap_cursor_serialize (in the "serialized" argument). You can also
fa9e4066f08beec538e775443c5be79dd423fcabahrens * use a "serialized" argument of 0 to start at the beginning of the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zapobj (ie. zap_cursor_init_serialized(..., 0) is equivalent to
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zap_cursor_init(...).)
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensvoid zap_cursor_init_serialized(zap_cursor_t *zc, objset_t *ds,
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zapobj, uint64_t serialized);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define ZAP_HISTOGRAM_SIZE 10
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrenstypedef struct zap_stats {
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Size of the pointer table (in number of entries).
fa9e4066f08beec538e775443c5be79dd423fcabahrens * This is always a power of 2, or zero if it's a microzap.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * In general, it should be considerably greater than zs_num_leafs.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_ptrtbl_len;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_blocksize; /* size of zap blocks */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The number of blocks used. Note that some blocks may be
fa9e4066f08beec538e775443c5be79dd423fcabahrens * wasted because old ptrtbl's and large name/value blocks are
fa9e4066f08beec538e775443c5be79dd423fcabahrens * not reused. (Although their space is reclaimed, we don't
fa9e4066f08beec538e775443c5be79dd423fcabahrens * reuse those offsets in the object.)
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_num_blocks;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
8248818d5849649ef734d62da097e90222a23763nd /*
8248818d5849649ef734d62da097e90222a23763nd * Pointer table values from zap_ptrtbl in the zap_phys_t
8248818d5849649ef734d62da097e90222a23763nd */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_ptrtbl_nextblk; /* next (larger) copy start block */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_ptrtbl_blks_copied; /* number source blocks copied */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_ptrtbl_zt_blk; /* starting block number */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_ptrtbl_zt_numblks; /* number of blocks */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_ptrtbl_zt_shift; /* bits to index it */
8248818d5849649ef734d62da097e90222a23763nd
8248818d5849649ef734d62da097e90222a23763nd /*
8248818d5849649ef734d62da097e90222a23763nd * Values of the other members of the zap_phys_t
8248818d5849649ef734d62da097e90222a23763nd */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_block_type; /* ZBT_HEADER */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_magic; /* ZAP_MAGIC */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_num_leafs; /* The number of leaf blocks */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_num_entries; /* The number of zap entries */
8248818d5849649ef734d62da097e90222a23763nd uint64_t zs_salt; /* salt to stir into hash function */
8248818d5849649ef734d62da097e90222a23763nd
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Histograms. For all histograms, the last index
fa9e4066f08beec538e775443c5be79dd423fcabahrens * (ZAP_HISTOGRAM_SIZE-1) includes any values which are greater
fa9e4066f08beec538e775443c5be79dd423fcabahrens * than what can be represented. For example
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_leafs_with_n5_entries[ZAP_HISTOGRAM_SIZE-1] is the number
fa9e4066f08beec538e775443c5be79dd423fcabahrens * of leafs with more than 45 entries.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_leafs_with_n_pointers[n] is the number of leafs with
fa9e4066f08beec538e775443c5be79dd423fcabahrens * 2^n pointers to it.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_leafs_with_2n_pointers[ZAP_HISTOGRAM_SIZE];
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_leafs_with_n_entries[n] is the number of leafs with
fa9e4066f08beec538e775443c5be79dd423fcabahrens * [n*5, (n+1)*5) entries. In the current implementation, there
fa9e4066f08beec538e775443c5be79dd423fcabahrens * can be at most 55 entries in any block, but there may be
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fewer if the name or value is large, or the block is not
fa9e4066f08beec538e775443c5be79dd423fcabahrens * completely full.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_blocks_with_n5_entries[ZAP_HISTOGRAM_SIZE];
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_leafs_n_tenths_full[n] is the number of leafs whose
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fullness is in the range [n/10, (n+1)/10).
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_blocks_n_tenths_full[ZAP_HISTOGRAM_SIZE];
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_entries_using_n_chunks[n] is the number of entries which
fa9e4066f08beec538e775443c5be79dd423fcabahrens * consume n 24-byte chunks. (Note, large names/values only use
fa9e4066f08beec538e775443c5be79dd423fcabahrens * one chunk, but contribute to zs_num_blocks_large.)
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_entries_using_n_chunks[ZAP_HISTOGRAM_SIZE];
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens /*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_buckets_with_n_entries[n] is the number of buckets (each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * leaf has 64 buckets) with n entries.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_buckets_with_n_entries[1] should be very close to
fa9e4066f08beec538e775443c5be79dd423fcabahrens * zs_num_entries.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint64_t zs_buckets_with_n_entries[ZAP_HISTOGRAM_SIZE];
fa9e4066f08beec538e775443c5be79dd423fcabahrens} zap_stats_t;
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens/*
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Get statistics about a ZAP object. Note: you need to be aware of the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * internal implementation of the ZAP to correctly interpret some of the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * statistics. This interface shouldn't be relied on unless you really
fa9e4066f08beec538e775443c5be79dd423fcabahrens * know what you're doing.
fa9e4066f08beec538e775443c5be79dd423fcabahrens */
fa9e4066f08beec538e775443c5be79dd423fcabahrensint zap_get_stats(objset_t *ds, uint64_t zapobj, zap_stats_t *zs);
fa9e4066f08beec538e775443c5be79dd423fcabahrens
fa9e4066f08beec538e775443c5be79dd423fcabahrens#ifdef __cplusplus
fa9e4066f08beec538e775443c5be79dd423fcabahrens}
fa9e4066f08beec538e775443c5be79dd423fcabahrens#endif
fa9e4066f08beec538e775443c5be79dd423fcabahrens
8248818d5849649ef734d62da097e90222a23763nd#endif /* _SYS_ZAP_H */