3 *
4 * The contents of this file are subject to the terms of the
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 */
24
25 #ifndef _SYS_DSL_DIR_H
26 #define _SYS_DSL_DIR_H
27
28 #include <sys/dmu.h>
29 #include <sys/dsl_pool.h>
30 #include <sys/dsl_synctask.h>
31 #include <sys/refcount.h>
32 #include <sys/zfs_context.h>
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 struct dsl_dataset;
39
40 typedef enum dd_used {
41 DD_USED_HEAD,
42 DD_USED_SNAP,
53 uint64_t dd_head_dataset_obj;
54 uint64_t dd_parent_obj;
55 uint64_t dd_origin_obj;
56 uint64_t dd_child_dir_zapobj;
57 /*
58 * how much space our children are accounting for; for leaf
59 * datasets, == physical space used by fs + snaps
60 */
61 uint64_t dd_used_bytes;
62 uint64_t dd_compressed_bytes;
63 uint64_t dd_uncompressed_bytes;
64 /* Administrative quota setting */
65 uint64_t dd_quota;
66 /* Administrative reservation setting */
67 uint64_t dd_reserved;
68 uint64_t dd_props_zapobj;
69 uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
70 uint64_t dd_flags;
71 uint64_t dd_used_breakdown[DD_USED_NUM];
72 uint64_t dd_clones; /* dsl_dir objects */
73 uint64_t dd_pad[13]; /* pad out to 256 bytes for good measure */
74 } dsl_dir_phys_t;
75
76 struct dsl_dir {
77 /* These are immutable; no lock needed: */
78 uint64_t dd_object;
79 dsl_dir_phys_t *dd_phys;
80 dmu_buf_t *dd_dbuf;
81 dsl_pool_t *dd_pool;
82
83 /* protected by lock on pool's dp_dirty_dirs list */
84 txg_node_t dd_dirty_link;
85
86 /* protected by dp_config_rwlock */
87 dsl_dir_t *dd_parent;
88
89 /* Protected by dd_lock */
90 kmutex_t dd_lock;
91 list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
92 timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
93 uint64_t dd_origin_txg;
114 dsl_checkfunc_t dsl_dir_destroy_check;
115 dsl_syncfunc_t dsl_dir_destroy_sync;
116 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
117 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
118 dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
119 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
120 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
121 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
122 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
123 dmu_tx_t *tx);
124 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
125 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
126 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
127 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
128 void dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
129 dd_used_t oldtype, dd_used_t newtype, dmu_tx_t *tx);
130 int dsl_dir_set_quota(const char *ddname, zprop_source_t source,
131 uint64_t quota);
132 int dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
133 uint64_t reservation);
134 int dsl_dir_rename(dsl_dir_t *dd, const char *newname);
135 int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd, uint64_t space);
136 int dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx);
137 boolean_t dsl_dir_is_clone(dsl_dir_t *dd);
138 void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds,
139 uint64_t reservation, cred_t *cr, dmu_tx_t *tx);
140 void dsl_dir_snap_cmtime_update(dsl_dir_t *dd);
141 timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
142
143 /* internal reserved dir name */
144 #define MOS_DIR_NAME "$MOS"
145 #define ORIGIN_DIR_NAME "$ORIGIN"
146 #define XLATION_DIR_NAME "$XLATION"
147 #define FREE_DIR_NAME "$FREE"
148
149 #ifdef ZFS_DEBUG
150 #define dprintf_dd(dd, fmt, ...) do { \
151 if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
152 char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
153 KM_SLEEP); \
154 dsl_dir_name(dd, __ds_name); \
155 dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
|
3 *
4 * The contents of this file are subject to the terms of the
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) 2012, Joyent, Inc. All rights reserved.
24 */
25
26 #ifndef _SYS_DSL_DIR_H
27 #define _SYS_DSL_DIR_H
28
29 #include <sys/dmu.h>
30 #include <sys/dsl_pool.h>
31 #include <sys/dsl_synctask.h>
32 #include <sys/refcount.h>
33 #include <sys/zfs_context.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 struct dsl_dataset;
40
41 typedef enum dd_used {
42 DD_USED_HEAD,
43 DD_USED_SNAP,
54 uint64_t dd_head_dataset_obj;
55 uint64_t dd_parent_obj;
56 uint64_t dd_origin_obj;
57 uint64_t dd_child_dir_zapobj;
58 /*
59 * how much space our children are accounting for; for leaf
60 * datasets, == physical space used by fs + snaps
61 */
62 uint64_t dd_used_bytes;
63 uint64_t dd_compressed_bytes;
64 uint64_t dd_uncompressed_bytes;
65 /* Administrative quota setting */
66 uint64_t dd_quota;
67 /* Administrative reservation setting */
68 uint64_t dd_reserved;
69 uint64_t dd_props_zapobj;
70 uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
71 uint64_t dd_flags;
72 uint64_t dd_used_breakdown[DD_USED_NUM];
73 uint64_t dd_clones; /* dsl_dir objects */
74
75 uint64_t dd_filesystem_count;
76 uint64_t dd_snapshot_count;
77
78 uint64_t dd_pad[11]; /* pad out to 256 bytes for good measure */
79 } dsl_dir_phys_t;
80
81 struct dsl_dir {
82 /* These are immutable; no lock needed: */
83 uint64_t dd_object;
84 dsl_dir_phys_t *dd_phys;
85 dmu_buf_t *dd_dbuf;
86 dsl_pool_t *dd_pool;
87
88 /* protected by lock on pool's dp_dirty_dirs list */
89 txg_node_t dd_dirty_link;
90
91 /* protected by dp_config_rwlock */
92 dsl_dir_t *dd_parent;
93
94 /* Protected by dd_lock */
95 kmutex_t dd_lock;
96 list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
97 timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
98 uint64_t dd_origin_txg;
119 dsl_checkfunc_t dsl_dir_destroy_check;
120 dsl_syncfunc_t dsl_dir_destroy_sync;
121 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
122 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
123 dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
124 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
125 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
126 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
127 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
128 dmu_tx_t *tx);
129 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
130 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
131 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
132 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
133 void dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
134 dd_used_t oldtype, dd_used_t newtype, dmu_tx_t *tx);
135 int dsl_dir_set_quota(const char *ddname, zprop_source_t source,
136 uint64_t quota);
137 int dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
138 uint64_t reservation);
139 int dsl_dir_validate_fs_ss_limit(const char *, uint64_t, zfs_prop_t);
140 int dsl_secpolicy_write_prop(dsl_dir_t *, zfs_prop_t, cred_t *);
141 int dsl_dir_fscount_check(dsl_dir_t *, uint64_t, dsl_dir_t *, cred_t *);
142 void dsl_dir_fscount_adjust(dsl_dir_t *, dmu_tx_t *, int64_t, boolean_t);
143 int dsl_snapcount_check(dsl_dir_t *, uint64_t, dsl_dir_t *, cred_t *);
144 void dsl_snapcount_adjust(dsl_dir_t *, dmu_tx_t *, int64_t, boolean_t);
145 int dsl_dir_rename(dsl_dir_t *dd, const char *newname);
146 int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd,
147 dsl_dir_t *moving_dd, uint64_t space, cred_t *);
148 int dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx);
149 boolean_t dsl_dir_is_clone(dsl_dir_t *dd);
150 void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds,
151 uint64_t reservation, cred_t *cr, dmu_tx_t *tx);
152 void dsl_dir_snap_cmtime_update(dsl_dir_t *dd);
153 timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
154
155 /* internal reserved dir name */
156 #define MOS_DIR_NAME "$MOS"
157 #define ORIGIN_DIR_NAME "$ORIGIN"
158 #define XLATION_DIR_NAME "$XLATION"
159 #define FREE_DIR_NAME "$FREE"
160
161 #ifdef ZFS_DEBUG
162 #define dprintf_dd(dd, fmt, ...) do { \
163 if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
164 char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
165 KM_SLEEP); \
166 dsl_dir_name(dd, __ds_name); \
167 dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
|