5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
25 */
26
27 #ifndef _SYS_DSL_DIR_H
28 #define _SYS_DSL_DIR_H
29
30 #include <sys/dmu.h>
31 #include <sys/dsl_pool.h>
32 #include <sys/dsl_synctask.h>
33 #include <sys/refcount.h>
34 #include <sys/zfs_context.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 struct dsl_dataset;
41
42 /*
43 * DD_FIELD_* are strings that are used in the "extensified" dsl_dir zap object.
44 * They should be of the format <reverse-dns>:<field>.
67 /*
68 * how much space our children are accounting for; for leaf
69 * datasets, == physical space used by fs + snaps
70 */
71 uint64_t dd_used_bytes;
72 uint64_t dd_compressed_bytes;
73 uint64_t dd_uncompressed_bytes;
74 /* Administrative quota setting */
75 uint64_t dd_quota;
76 /* Administrative reservation setting */
77 uint64_t dd_reserved;
78 uint64_t dd_props_zapobj;
79 uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
80 uint64_t dd_flags;
81 uint64_t dd_used_breakdown[DD_USED_NUM];
82 uint64_t dd_clones; /* dsl_dir objects */
83 uint64_t dd_pad[13]; /* pad out to 256 bytes for good measure */
84 } dsl_dir_phys_t;
85
86 struct dsl_dir {
87 /* These are immutable; no lock needed: */
88 uint64_t dd_object;
89 dsl_pool_t *dd_pool;
90
91 /* Stable until user eviction; no lock needed: */
92 dmu_buf_t *dd_dbuf;
93
94 /* protected by lock on pool's dp_dirty_dirs list */
95 txg_node_t dd_dirty_link;
96
97 /* protected by dp_config_rwlock */
98 dsl_dir_t *dd_parent;
99
100 /* Protected by dd_lock */
101 kmutex_t dd_lock;
102 list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
103 timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
104 uint64_t dd_origin_txg;
105
106 /* gross estimate of space used by in-flight tx's */
107 uint64_t dd_tempreserved[TXG_SIZE];
108 /* amount of space we expect to write; == amount of dirty data */
109 int64_t dd_space_towrite[TXG_SIZE];
110
111 /* protected by dd_lock; keep at end of struct for better locality */
112 char dd_myname[MAXNAMELEN];
113 };
114
115 inline dsl_dir_phys_t *
116 dsl_dir_phys(dsl_dir_t *dd)
117 {
118 return (dd->dd_dbuf->db_data);
119 }
120
121 void dsl_dir_rele(dsl_dir_t *dd, void *tag);
122 int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
123 dsl_dir_t **, const char **tail);
124 int dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
125 const char *tail, void *tag, dsl_dir_t **);
126 void dsl_dir_name(dsl_dir_t *dd, char *buf);
127 int dsl_dir_namelen(dsl_dir_t *dd);
128 uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
129 const char *name, dmu_tx_t *tx);
130 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
131 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
132 dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
133 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
134 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
135 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
136 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
137 dmu_tx_t *tx);
138 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
139 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
140 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
141 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
|
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2013 by Delphix. All rights reserved.
24 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
25 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
26 */
27
28 #ifndef _SYS_DSL_DIR_H
29 #define _SYS_DSL_DIR_H
30
31 #include <sys/dmu.h>
32 #include <sys/dsl_pool.h>
33 #include <sys/dsl_synctask.h>
34 #include <sys/refcount.h>
35 #include <sys/zfs_context.h>
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 struct dsl_dataset;
42
43 /*
44 * DD_FIELD_* are strings that are used in the "extensified" dsl_dir zap object.
45 * They should be of the format <reverse-dns>:<field>.
68 /*
69 * how much space our children are accounting for; for leaf
70 * datasets, == physical space used by fs + snaps
71 */
72 uint64_t dd_used_bytes;
73 uint64_t dd_compressed_bytes;
74 uint64_t dd_uncompressed_bytes;
75 /* Administrative quota setting */
76 uint64_t dd_quota;
77 /* Administrative reservation setting */
78 uint64_t dd_reserved;
79 uint64_t dd_props_zapobj;
80 uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
81 uint64_t dd_flags;
82 uint64_t dd_used_breakdown[DD_USED_NUM];
83 uint64_t dd_clones; /* dsl_dir objects */
84 uint64_t dd_pad[13]; /* pad out to 256 bytes for good measure */
85 } dsl_dir_phys_t;
86
87 struct dsl_dir {
88 dmu_buf_user_t dd_dbu;
89
90 /* These are immutable; no lock needed: */
91 uint64_t dd_object;
92 dsl_pool_t *dd_pool;
93
94 /* Stable until user eviction; no lock needed: */
95 dmu_buf_t *dd_dbuf;
96
97 /* protected by lock on pool's dp_dirty_dirs list */
98 txg_node_t dd_dirty_link;
99
100 /* protected by dp_config_rwlock */
101 dsl_dir_t *dd_parent;
102
103 /* Protected by dd_lock */
104 kmutex_t dd_lock;
105 list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
106 timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
107 uint64_t dd_origin_txg;
108
109 /* gross estimate of space used by in-flight tx's */
110 uint64_t dd_tempreserved[TXG_SIZE];
111 /* amount of space we expect to write; == amount of dirty data */
112 int64_t dd_space_towrite[TXG_SIZE];
113
114 /* protected by dd_lock; keep at end of struct for better locality */
115 char dd_myname[MAXNAMELEN];
116 };
117
118 inline dsl_dir_phys_t *
119 dsl_dir_phys(dsl_dir_t *dd)
120 {
121 return (dd->dd_dbuf->db_data);
122 }
123
124 void dsl_dir_rele(dsl_dir_t *dd, void *tag);
125 void dsl_dir_async_rele(dsl_dir_t *dd, void *tag);
126 int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
127 dsl_dir_t **, const char **tail);
128 int dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
129 const char *tail, void *tag, dsl_dir_t **);
130 void dsl_dir_name(dsl_dir_t *dd, char *buf);
131 int dsl_dir_namelen(dsl_dir_t *dd);
132 uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
133 const char *name, dmu_tx_t *tx);
134 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
135 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
136 dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
137 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
138 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
139 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
140 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
141 dmu_tx_t *tx);
142 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
143 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
144 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
145 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
|