53089ab7c84db6fb76c16ca50076c147cda11757eschrock/*
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * CDDL HEADER START
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * The contents of this file are subject to the terms of the
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * Common Development and Distribution License (the "License").
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * You may not use this file except in compliance with the License.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * or http://www.opensolaris.org/os/licensing.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * See the License for the specific language governing permissions
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * and limitations under the License.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * When distributing Covered Code, include this CDDL HEADER in each
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * If applicable, add the following below this CDDL HEADER, with the
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * fields enclosed by brackets "[]" replaced with your own identifying
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * information: Portions Copyright [yyyy] [name of copyright owner]
53089ab7c84db6fb76c16ca50076c147cda11757eschrock *
53089ab7c84db6fb76c16ca50076c147cda11757eschrock * CDDL HEADER END
53089ab7c84db6fb76c16ca50076c147cda11757eschrock */
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock/*
0713e232b7712cd27d99e1e935ebb8d5de61c57dGeorge Wilson * Copyright (c) 2013 by Delphix. All rights reserved.
53089ab7c84db6fb76c16ca50076c147cda11757eschrock */
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#ifndef _SYS_ZFEATURE_H
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#define _SYS_ZFEATURE_H
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#include <sys/nvpair.h>
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens#include <sys/txg.h>
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#include "zfeature_common.h"
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#ifdef __cplusplus
53089ab7c84db6fb76c16ca50076c147cda11757eschrockextern "C" {
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#endif
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman#define VALID_FEATURE_FID(fid) ((fid) >= 0 && (fid) < SPA_FEATURES)
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman#define VALID_FEATURE_OR_NONE(fid) ((fid) == SPA_FEATURE_NONE || \
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman VALID_FEATURE_FID(fid))
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensstruct spa;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensstruct dmu_tx;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensstruct objset;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrensextern void spa_feature_create_zap_objects(struct spa *, struct dmu_tx *);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern void spa_feature_enable(struct spa *, spa_feature_t,
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens struct dmu_tx *);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern void spa_feature_incr(struct spa *, spa_feature_t, struct dmu_tx *);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern void spa_feature_decr(struct spa *, spa_feature_t, struct dmu_tx *);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern boolean_t spa_feature_is_enabled(struct spa *, spa_feature_t);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern boolean_t spa_feature_is_active(struct spa *, spa_feature_t);
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossmanextern boolean_t spa_feature_enabled_txg(spa_t *spa, spa_feature_t fid,
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman uint64_t *txg);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern uint64_t spa_feature_refcount(spa_t *, spa_feature_t, uint64_t);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern boolean_t spa_features_check(spa_t *, boolean_t, nvlist_t *, nvlist_t *);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens/*
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * These functions are only exported for zhack and zdb; normal callers should
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens * use the above interfaces.
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens */
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern int feature_get_refcount(struct spa *, zfeature_info_t *, uint64_t *);
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossmanextern int feature_get_refcount_from_disk(spa_t *spa, zfeature_info_t *feature,
43466aae47bfcd2ad9bf501faec8e75c08095e4fMax Grossman uint64_t *res);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern void feature_enable_sync(struct spa *, zfeature_info_t *,
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrens struct dmu_tx *);
2acef22db7808606888f8f92715629ff3ba555b9Matthew Ahrensextern void feature_sync(struct spa *, zfeature_info_t *, uint64_t,
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens struct dmu_tx *);
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#ifdef __cplusplus
53089ab7c84db6fb76c16ca50076c147cda11757eschrock}
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#endif
53089ab7c84db6fb76c16ca50076c147cda11757eschrock
53089ab7c84db6fb76c16ca50076c147cda11757eschrock#endif /* _SYS_ZFEATURE_H */