1c1cb2cd8Shaad /* 2c1cb2cd8Shaad * CDDL HEADER START 3c1cb2cd8Shaad * 4c1cb2cd8Shaad * The contents of this file are subject to the terms of the 5c1cb2cd8Shaad * Common Development and Distribution License (the "License"). 6c1cb2cd8Shaad * You may not use this file except in compliance with the License. 7c1cb2cd8Shaad * 8c1cb2cd8Shaad * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9c1cb2cd8Shaad * or http://www.opensolaris.org/os/licensing. 10c1cb2cd8Shaad * See the License for the specific language governing permissions 11c1cb2cd8Shaad * and limitations under the License. 12c1cb2cd8Shaad * 13c1cb2cd8Shaad * When distributing Covered Code, include this CDDL HEADER in each 14c1cb2cd8Shaad * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c1cb2cd8Shaad * If applicable, add the following below this CDDL HEADER, with the 16c1cb2cd8Shaad * fields enclosed by brackets "[]" replaced with your own identifying 17c1cb2cd8Shaad * information: Portions Copyright [yyyy] [name of copyright owner] 18c1cb2cd8Shaad * 19c1cb2cd8Shaad * CDDL HEADER END 20c1cb2cd8Shaad */ 21c1cb2cd8Shaad /* 22*93f3d2b8Schs * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23*93f3d2b8Schs * Copyright (c) 2012 by Delphix. All rights reserved. 24c1cb2cd8Shaad */ 25c1cb2cd8Shaad 26c1cb2cd8Shaad #ifndef _SYS_DSL_PROP_H 27c1cb2cd8Shaad #define _SYS_DSL_PROP_H 28c1cb2cd8Shaad 29c1cb2cd8Shaad #include <sys/dmu.h> 30c1cb2cd8Shaad #include <sys/dsl_pool.h> 31c1cb2cd8Shaad #include <sys/zfs_context.h> 32f59c7639Shaad #include <sys/dsl_synctask.h> 33c1cb2cd8Shaad 34c1cb2cd8Shaad #ifdef __cplusplus 35c1cb2cd8Shaad extern "C" { 36c1cb2cd8Shaad #endif 37c1cb2cd8Shaad 38c1cb2cd8Shaad struct dsl_dataset; 39c1cb2cd8Shaad struct dsl_dir; 40c1cb2cd8Shaad 41c1cb2cd8Shaad /* The callback func may not call into the DMU or DSL! */ 42c1cb2cd8Shaad typedef void (dsl_prop_changed_cb_t)(void *arg, uint64_t newval); 43c1cb2cd8Shaad 44*93f3d2b8Schs typedef struct dsl_prop_record { 45*93f3d2b8Schs list_node_t pr_node; /* link on dd_props */ 46*93f3d2b8Schs const char *pr_propname; 47*93f3d2b8Schs list_t pr_cbs; 48*93f3d2b8Schs } dsl_prop_record_t; 49*93f3d2b8Schs 50c1cb2cd8Shaad typedef struct dsl_prop_cb_record { 51*93f3d2b8Schs list_node_t cbr_pr_node; /* link on pr_cbs */ 52*93f3d2b8Schs list_node_t cbr_ds_node; /* link on ds_prop_cbs */ 53*93f3d2b8Schs dsl_prop_record_t *cbr_pr; 54c1cb2cd8Shaad struct dsl_dataset *cbr_ds; 55c1cb2cd8Shaad dsl_prop_changed_cb_t *cbr_func; 56c1cb2cd8Shaad void *cbr_arg; 57c1cb2cd8Shaad } dsl_prop_cb_record_t; 58c1cb2cd8Shaad 59f59c7639Shaad typedef struct dsl_props_arg { 60f59c7639Shaad nvlist_t *pa_props; 61f59c7639Shaad zprop_source_t pa_source; 62f59c7639Shaad } dsl_props_arg_t; 63f59c7639Shaad 64*93f3d2b8Schs void dsl_prop_init(dsl_dir_t *dd); 65*93f3d2b8Schs void dsl_prop_fini(dsl_dir_t *dd); 66c1cb2cd8Shaad int dsl_prop_register(struct dsl_dataset *ds, const char *propname, 67c1cb2cd8Shaad dsl_prop_changed_cb_t *callback, void *cbarg); 68*93f3d2b8Schs void dsl_prop_unregister_all(struct dsl_dataset *ds, void *cbarg); 69*93f3d2b8Schs void dsl_prop_notify_all(struct dsl_dir *dd); 70*93f3d2b8Schs boolean_t dsl_prop_hascb(struct dsl_dataset *ds); 71c1cb2cd8Shaad 72c1cb2cd8Shaad int dsl_prop_get(const char *ddname, const char *propname, 73c1cb2cd8Shaad int intsz, int numints, void *buf, char *setpoint); 74c1cb2cd8Shaad int dsl_prop_get_integer(const char *ddname, const char *propname, 75c1cb2cd8Shaad uint64_t *valuep, char *setpoint); 76f59c7639Shaad int dsl_prop_get_all(objset_t *os, nvlist_t **nvp); 77*93f3d2b8Schs int dsl_prop_get_received(const char *dsname, nvlist_t **nvp); 78c1cb2cd8Shaad int dsl_prop_get_ds(struct dsl_dataset *ds, const char *propname, 79c1cb2cd8Shaad int intsz, int numints, void *buf, char *setpoint); 80*93f3d2b8Schs int dsl_prop_get_int_ds(struct dsl_dataset *ds, const char *propname, 81*93f3d2b8Schs uint64_t *valuep); 82c1cb2cd8Shaad int dsl_prop_get_dd(struct dsl_dir *dd, const char *propname, 83f59c7639Shaad int intsz, int numints, void *buf, char *setpoint, 84f59c7639Shaad boolean_t snapshot); 85c1cb2cd8Shaad 86*93f3d2b8Schs void dsl_props_set_sync_impl(struct dsl_dataset *ds, zprop_source_t source, 87*93f3d2b8Schs nvlist_t *props, dmu_tx_t *tx); 88*93f3d2b8Schs void dsl_prop_set_sync_impl(struct dsl_dataset *ds, const char *propname, 89*93f3d2b8Schs zprop_source_t source, int intsz, int numints, const void *value, 90*93f3d2b8Schs dmu_tx_t *tx); 91f59c7639Shaad int dsl_props_set(const char *dsname, zprop_source_t source, nvlist_t *nvl); 92*93f3d2b8Schs int dsl_prop_set_int(const char *dsname, const char *propname, 93*93f3d2b8Schs zprop_source_t source, uint64_t value); 94*93f3d2b8Schs int dsl_prop_set_string(const char *dsname, const char *propname, 95*93f3d2b8Schs zprop_source_t source, const char *value); 96*93f3d2b8Schs int dsl_prop_inherit(const char *dsname, const char *propname, 97*93f3d2b8Schs zprop_source_t source); 98c1cb2cd8Shaad 99*93f3d2b8Schs int dsl_prop_predict(dsl_dir_t *dd, const char *propname, 100*93f3d2b8Schs zprop_source_t source, uint64_t value, uint64_t *newvalp); 101f59c7639Shaad 102f59c7639Shaad /* flag first receive on or after SPA_VERSION_RECVD_PROPS */ 103*93f3d2b8Schs boolean_t dsl_prop_get_hasrecvd(const char *dsname); 104*93f3d2b8Schs int dsl_prop_set_hasrecvd(const char *dsname); 105*93f3d2b8Schs void dsl_prop_unset_hasrecvd(const char *dsname); 106f59c7639Shaad 107c1cb2cd8Shaad void dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value); 108c1cb2cd8Shaad void dsl_prop_nvlist_add_string(nvlist_t *nv, 109c1cb2cd8Shaad zfs_prop_t prop, const char *value); 110c1cb2cd8Shaad 111c1cb2cd8Shaad #ifdef __cplusplus 112c1cb2cd8Shaad } 113c1cb2cd8Shaad #endif 114c1cb2cd8Shaad 115c1cb2cd8Shaad #endif /* _SYS_DSL_PROP_H */ 116