xref: /onnv-gate/usr/src/uts/common/fs/zfs/sys/dsl_prop.h (revision 12296:7cf402a7f374)
1789Sahrens /*
2789Sahrens  * CDDL HEADER START
3789Sahrens  *
4789Sahrens  * The contents of this file are subject to the terms of the
52082Seschrock  * Common Development and Distribution License (the "License").
62082Seschrock  * You may not use this file except in compliance with the License.
7789Sahrens  *
8789Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9789Sahrens  * or http://www.opensolaris.org/os/licensing.
10789Sahrens  * See the License for the specific language governing permissions
11789Sahrens  * and limitations under the License.
12789Sahrens  *
13789Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14789Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15789Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16789Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17789Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18789Sahrens  *
19789Sahrens  * CDDL HEADER END
20789Sahrens  */
21789Sahrens /*
22*12296SLin.Ling@Sun.COM  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23789Sahrens  */
24789Sahrens 
25789Sahrens #ifndef	_SYS_DSL_PROP_H
26789Sahrens #define	_SYS_DSL_PROP_H
27789Sahrens 
28789Sahrens #include <sys/dmu.h>
29789Sahrens #include <sys/dsl_pool.h>
30789Sahrens #include <sys/zfs_context.h>
319355SMatthew.Ahrens@Sun.COM #include <sys/dsl_synctask.h>
32789Sahrens 
33789Sahrens #ifdef	__cplusplus
34789Sahrens extern "C" {
35789Sahrens #endif
36789Sahrens 
37789Sahrens struct dsl_dataset;
387265Sahrens struct dsl_dir;
39789Sahrens 
40789Sahrens /* The callback func may not call into the DMU or DSL! */
41789Sahrens typedef void (dsl_prop_changed_cb_t)(void *arg, uint64_t newval);
42789Sahrens 
43789Sahrens typedef struct dsl_prop_cb_record {
44789Sahrens 	list_node_t cbr_node; /* link on dd_prop_cbs */
452082Seschrock 	struct dsl_dataset *cbr_ds;
46789Sahrens 	const char *cbr_propname;
47789Sahrens 	dsl_prop_changed_cb_t *cbr_func;
48789Sahrens 	void *cbr_arg;
49789Sahrens } dsl_prop_cb_record_t;
50789Sahrens 
5111022STom.Erickson@Sun.COM typedef struct dsl_props_arg {
5211022STom.Erickson@Sun.COM 	nvlist_t *pa_props;
5311022STom.Erickson@Sun.COM 	zprop_source_t pa_source;
5411022STom.Erickson@Sun.COM } dsl_props_arg_t;
5511022STom.Erickson@Sun.COM 
5611022STom.Erickson@Sun.COM typedef struct dsl_prop_set_arg {
5711022STom.Erickson@Sun.COM 	const char *psa_name;
5811022STom.Erickson@Sun.COM 	zprop_source_t psa_source;
5911022STom.Erickson@Sun.COM 	int psa_intsz;
6011022STom.Erickson@Sun.COM 	int psa_numints;
6111022STom.Erickson@Sun.COM 	const void *psa_value;
6211022STom.Erickson@Sun.COM 
6311022STom.Erickson@Sun.COM 	/*
6411022STom.Erickson@Sun.COM 	 * Used to handle the special requirements of the quota and reservation
6511022STom.Erickson@Sun.COM 	 * properties.
6611022STom.Erickson@Sun.COM 	 */
6711022STom.Erickson@Sun.COM 	uint64_t psa_effective_value;
6811022STom.Erickson@Sun.COM } dsl_prop_setarg_t;
6911022STom.Erickson@Sun.COM 
70789Sahrens int dsl_prop_register(struct dsl_dataset *ds, const char *propname,
71789Sahrens     dsl_prop_changed_cb_t *callback, void *cbarg);
72789Sahrens int dsl_prop_unregister(struct dsl_dataset *ds, const char *propname,
73789Sahrens     dsl_prop_changed_cb_t *callback, void *cbarg);
742082Seschrock int dsl_prop_numcb(struct dsl_dataset *ds);
75789Sahrens 
76789Sahrens int dsl_prop_get(const char *ddname, const char *propname,
77789Sahrens     int intsz, int numints, void *buf, char *setpoint);
78789Sahrens int dsl_prop_get_integer(const char *ddname, const char *propname,
79789Sahrens     uint64_t *valuep, char *setpoint);
8011022STom.Erickson@Sun.COM int dsl_prop_get_all(objset_t *os, nvlist_t **nvp);
8111022STom.Erickson@Sun.COM int dsl_prop_get_received(objset_t *os, nvlist_t **nvp);
827265Sahrens int dsl_prop_get_ds(struct dsl_dataset *ds, const char *propname,
837265Sahrens     int intsz, int numints, void *buf, char *setpoint);
847265Sahrens int dsl_prop_get_dd(struct dsl_dir *dd, const char *propname,
8511022STom.Erickson@Sun.COM     int intsz, int numints, void *buf, char *setpoint,
8611022STom.Erickson@Sun.COM     boolean_t snapshot);
87789Sahrens 
889355SMatthew.Ahrens@Sun.COM dsl_syncfunc_t dsl_props_set_sync;
89789Sahrens int dsl_prop_set(const char *ddname, const char *propname,
9011022STom.Erickson@Sun.COM     zprop_source_t source, int intsz, int numints, const void *buf);
9111022STom.Erickson@Sun.COM int dsl_props_set(const char *dsname, zprop_source_t source, nvlist_t *nvl);
9210242Schris.kirby@sun.com void dsl_dir_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val,
93*12296SLin.Ling@Sun.COM     dmu_tx_t *tx);
942885Sahrens 
9511022STom.Erickson@Sun.COM void dsl_prop_setarg_init_uint64(dsl_prop_setarg_t *psa, const char *propname,
9611022STom.Erickson@Sun.COM     zprop_source_t source, uint64_t *value);
9711022STom.Erickson@Sun.COM int dsl_prop_predict_sync(dsl_dir_t *dd, dsl_prop_setarg_t *psa);
9811022STom.Erickson@Sun.COM #ifdef	ZFS_DEBUG
9911022STom.Erickson@Sun.COM void dsl_prop_check_prediction(dsl_dir_t *dd, dsl_prop_setarg_t *psa);
10011022STom.Erickson@Sun.COM #define	DSL_PROP_CHECK_PREDICTION(dd, psa)	\
10111022STom.Erickson@Sun.COM 	dsl_prop_check_prediction((dd), (psa))
10211022STom.Erickson@Sun.COM #else
10311022STom.Erickson@Sun.COM #define	DSL_PROP_CHECK_PREDICTION(dd, psa)	/* nothing */
10411022STom.Erickson@Sun.COM #endif
10511022STom.Erickson@Sun.COM 
10611022STom.Erickson@Sun.COM /* flag first receive on or after SPA_VERSION_RECVD_PROPS */
10711022STom.Erickson@Sun.COM boolean_t dsl_prop_get_hasrecvd(objset_t *os);
10811022STom.Erickson@Sun.COM void dsl_prop_set_hasrecvd(objset_t *os);
10911022STom.Erickson@Sun.COM void dsl_prop_unset_hasrecvd(objset_t *os);
11011022STom.Erickson@Sun.COM 
1112885Sahrens void dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value);
1122885Sahrens void dsl_prop_nvlist_add_string(nvlist_t *nv,
1132885Sahrens     zfs_prop_t prop, const char *value);
114789Sahrens 
115789Sahrens #ifdef	__cplusplus
116789Sahrens }
117789Sahrens #endif
118789Sahrens 
119789Sahrens #endif	/* _SYS_DSL_PROP_H */
120