1 // SPDX-License-Identifier: CDDL-1.0 2 /* 3 * This file and its contents are supplied under the terms of the 4 * Common Development and Distribution License ("CDDL"), version 1.0. 5 * You may only use this file in accordance with the terms of version 6 * 1.0 of the CDDL. 7 * 8 * A full copy of the text of the CDDL should have accompanied this 9 * source. A copy of the CDDL is also available via the Internet at 10 * https://opensource.org/license/CDDL-1.0. 11 */ 12 /* 13 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 14 * Copyright (c) 2012 by Delphix. All rights reserved. 15 * Copyright 2019 Joyent, Inc. 16 */ 17 18 #ifndef _SYS_DSL_PROP_H 19 #define _SYS_DSL_PROP_H 20 21 #include <sys/dmu.h> 22 #include <sys/dsl_pool.h> 23 #include <sys/zfs_context.h> 24 #include <sys/dsl_synctask.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 struct dsl_dataset; 31 struct dsl_dir; 32 33 /* The callback func may not call into the DMU or DSL! */ 34 typedef void (dsl_prop_changed_cb_t)(void *arg, uint64_t newval); 35 36 typedef struct dsl_prop_record { 37 list_node_t pr_node; /* link on dd_props */ 38 const char *pr_propname; 39 list_t pr_cbs; 40 } dsl_prop_record_t; 41 42 typedef struct dsl_prop_cb_record { 43 list_node_t cbr_pr_node; /* link on pr_cbs */ 44 list_node_t cbr_ds_node; /* link on ds_prop_cbs */ 45 dsl_prop_record_t *cbr_pr; 46 struct dsl_dataset *cbr_ds; 47 dsl_prop_changed_cb_t *cbr_func; 48 void *cbr_arg; 49 } dsl_prop_cb_record_t; 50 51 typedef struct dsl_props_arg { 52 nvlist_t *pa_props; 53 zprop_source_t pa_source; 54 } dsl_props_arg_t; 55 56 typedef struct dsl_props_set_arg { 57 const char *dpsa_dsname; 58 zprop_source_t dpsa_source; 59 nvlist_t *dpsa_props; 60 } dsl_props_set_arg_t; 61 62 void dsl_prop_init(dsl_dir_t *dd); 63 void dsl_prop_fini(dsl_dir_t *dd); 64 int dsl_prop_register(struct dsl_dataset *ds, const char *propname, 65 dsl_prop_changed_cb_t *callback, void *cbarg); 66 int dsl_prop_unregister(struct dsl_dataset *ds, const char *propname, 67 dsl_prop_changed_cb_t *callback, void *cbarg); 68 void dsl_prop_unregister_all(struct dsl_dataset *ds, void *cbarg); 69 void dsl_prop_notify_all(struct dsl_dir *dd); 70 boolean_t dsl_prop_hascb(struct dsl_dataset *ds); 71 72 int dsl_prop_get(const char *ddname, const char *propname, 73 int intsz, int numints, void *buf, char *setpoint); 74 int dsl_prop_get_integer(const char *ddname, const char *propname, 75 uint64_t *valuep, char *setpoint); 76 int dsl_prop_get_all(objset_t *os, nvlist_t **nvp); 77 int dsl_prop_get_received(const char *dsname, nvlist_t **nvp); 78 int dsl_prop_get_ds(struct dsl_dataset *ds, const char *propname, 79 int intsz, int numints, void *buf, char *setpoint); 80 int dsl_prop_get_int_ds(struct dsl_dataset *ds, const char *propname, 81 uint64_t *valuep); 82 int dsl_prop_get_dd(struct dsl_dir *dd, const char *propname, 83 int intsz, int numints, void *buf, char *setpoint, 84 boolean_t snapshot); 85 86 int dsl_props_set_check(void *arg, dmu_tx_t *tx); 87 void dsl_props_set_sync(void *arg, dmu_tx_t *tx); 88 void dsl_props_set_sync_impl(struct dsl_dataset *ds, zprop_source_t source, 89 nvlist_t *props, dmu_tx_t *tx); 90 void dsl_prop_set_sync_impl(struct dsl_dataset *ds, const char *propname, 91 zprop_source_t source, int intsz, int numints, const void *value, 92 dmu_tx_t *tx); 93 int dsl_props_set(const char *dsname, zprop_source_t source, nvlist_t *nvl); 94 int dsl_prop_set_int(const char *dsname, const char *propname, 95 zprop_source_t source, uint64_t value); 96 int dsl_prop_set_string(const char *dsname, const char *propname, 97 zprop_source_t source, const char *value); 98 int dsl_prop_inherit(const char *dsname, const char *propname, 99 zprop_source_t source); 100 101 int dsl_prop_predict(dsl_dir_t *dd, const char *propname, 102 zprop_source_t source, uint64_t value, uint64_t *newvalp); 103 104 /* flag first receive on or after SPA_VERSION_RECVD_PROPS */ 105 boolean_t dsl_prop_get_hasrecvd(const char *dsname); 106 int dsl_prop_set_hasrecvd(const char *dsname); 107 void dsl_prop_unset_hasrecvd(const char *dsname); 108 109 void dsl_prop_nvlist_add_uint64(nvlist_t *nv, zfs_prop_t prop, uint64_t value); 110 void dsl_prop_nvlist_add_string(nvlist_t *nv, 111 zfs_prop_t prop, const char *value); 112 113 #ifdef __cplusplus 114 } 115 #endif 116 117 #endif /* _SYS_DSL_PROP_H */ 118