Print this page
3752 want more verifiable dbuf user eviction
Submitted by: Justin Gibbs <justing@spectralogic.com>
Submitted by: Will Andrews <willa@spectralogic.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/zfs/sys/dsl_dir.h
+++ new/usr/src/uts/common/fs/zfs/sys/dsl_dir.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright (c) 2012 by Delphix. All rights reserved.
24 24 */
25 25
26 26 #ifndef _SYS_DSL_DIR_H
27 27 #define _SYS_DSL_DIR_H
28 28
29 29 #include <sys/dmu.h>
30 30 #include <sys/dsl_pool.h>
31 31 #include <sys/dsl_synctask.h>
32 32 #include <sys/refcount.h>
33 33 #include <sys/zfs_context.h>
34 34
35 35 #ifdef __cplusplus
36 36 extern "C" {
37 37 #endif
38 38
39 39 struct dsl_dataset;
40 40
41 41 typedef enum dd_used {
42 42 DD_USED_HEAD,
43 43 DD_USED_SNAP,
44 44 DD_USED_CHILD,
45 45 DD_USED_CHILD_RSRV,
46 46 DD_USED_REFRSRV,
47 47 DD_USED_NUM
48 48 } dd_used_t;
49 49
50 50 #define DD_FLAG_USED_BREAKDOWN (1<<0)
51 51
52 52 typedef struct dsl_dir_phys {
53 53 uint64_t dd_creation_time; /* not actually used */
54 54 uint64_t dd_head_dataset_obj;
55 55 uint64_t dd_parent_obj;
56 56 uint64_t dd_origin_obj;
57 57 uint64_t dd_child_dir_zapobj;
58 58 /*
59 59 * how much space our children are accounting for; for leaf
60 60 * datasets, == physical space used by fs + snaps
61 61 */
62 62 uint64_t dd_used_bytes;
63 63 uint64_t dd_compressed_bytes;
64 64 uint64_t dd_uncompressed_bytes;
65 65 /* Administrative quota setting */
66 66 uint64_t dd_quota;
↓ open down ↓ |
66 lines elided |
↑ open up ↑ |
67 67 /* Administrative reservation setting */
68 68 uint64_t dd_reserved;
69 69 uint64_t dd_props_zapobj;
70 70 uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
71 71 uint64_t dd_flags;
72 72 uint64_t dd_used_breakdown[DD_USED_NUM];
73 73 uint64_t dd_clones; /* dsl_dir objects */
74 74 uint64_t dd_pad[13]; /* pad out to 256 bytes for good measure */
75 75 } dsl_dir_phys_t;
76 76
77 +typedef struct dsl_dir_dbuf {
78 + uint8_t dddb_pad[offsetof(dmu_buf_t, db_data)];
79 + dsl_dir_phys_t *dddb_data;
80 +} dsl_dir_dbuf_t;
81 +
77 82 struct dsl_dir {
83 + dmu_buf_user_t db_evict;
84 +
78 85 /* These are immutable; no lock needed: */
79 86 uint64_t dd_object;
80 - dsl_dir_phys_t *dd_phys;
81 - dmu_buf_t *dd_dbuf;
87 + union {
88 + dmu_buf_t *dd_dmu_db;
89 + dsl_dir_dbuf_t *dd_db;
90 + } dd_db_u;
82 91 dsl_pool_t *dd_pool;
83 92
84 93 /* protected by lock on pool's dp_dirty_dirs list */
85 94 txg_node_t dd_dirty_link;
86 95
87 96 /* protected by dp_config_rwlock */
88 97 dsl_dir_t *dd_parent;
89 98
90 99 /* Protected by dd_lock */
91 100 kmutex_t dd_lock;
92 101 list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
93 102 timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
94 103 uint64_t dd_origin_txg;
↓ open down ↓ |
3 lines elided |
↑ open up ↑ |
95 104
96 105 /* gross estimate of space used by in-flight tx's */
97 106 uint64_t dd_tempreserved[TXG_SIZE];
98 107 /* amount of space we expect to write; == amount of dirty data */
99 108 int64_t dd_space_towrite[TXG_SIZE];
100 109
101 110 /* protected by dd_lock; keep at end of struct for better locality */
102 111 char dd_myname[MAXNAMELEN];
103 112 };
104 113
114 +/* See sys/dmu.h:dmu_buf_user_t for why we have these. */
115 +#define dd_dbuf dd_db_u.dd_dmu_db
116 +#define dd_phys dd_db_u.dd_db->dddb_data
117 +
105 118 void dsl_dir_rele(dsl_dir_t *dd, void *tag);
106 119 int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
107 120 dsl_dir_t **, const char **tail);
108 121 int dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
109 122 const char *tail, void *tag, dsl_dir_t **);
110 123 void dsl_dir_name(dsl_dir_t *dd, char *buf);
111 124 int dsl_dir_namelen(dsl_dir_t *dd);
112 125 uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
113 126 const char *name, dmu_tx_t *tx);
114 127 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
115 128 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
116 129 dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
117 130 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
118 131 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
119 132 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
120 133 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
121 134 dmu_tx_t *tx);
122 135 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
123 136 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
124 137 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
125 138 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
126 139 void dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
127 140 dd_used_t oldtype, dd_used_t newtype, dmu_tx_t *tx);
128 141 int dsl_dir_set_quota(const char *ddname, zprop_source_t source,
129 142 uint64_t quota);
130 143 int dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
131 144 uint64_t reservation);
132 145 int dsl_dir_rename(const char *oldname, const char *newname);
133 146 int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd, uint64_t space);
134 147 boolean_t dsl_dir_is_clone(dsl_dir_t *dd);
135 148 void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds,
136 149 uint64_t reservation, cred_t *cr, dmu_tx_t *tx);
137 150 void dsl_dir_snap_cmtime_update(dsl_dir_t *dd);
138 151 timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
139 152 void dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd, uint64_t value,
140 153 dmu_tx_t *tx);
141 154
142 155 /* internal reserved dir name */
143 156 #define MOS_DIR_NAME "$MOS"
144 157 #define ORIGIN_DIR_NAME "$ORIGIN"
145 158 #define XLATION_DIR_NAME "$XLATION"
146 159 #define FREE_DIR_NAME "$FREE"
147 160
148 161 #ifdef ZFS_DEBUG
149 162 #define dprintf_dd(dd, fmt, ...) do { \
150 163 if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
151 164 char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
152 165 KM_SLEEP); \
153 166 dsl_dir_name(dd, __ds_name); \
154 167 dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
155 168 kmem_free(__ds_name, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1); \
156 169 } \
157 170 _NOTE(CONSTCOND) } while (0)
158 171 #else
159 172 #define dprintf_dd(dd, fmt, ...)
160 173 #endif
161 174
162 175 #ifdef __cplusplus
163 176 }
164 177 #endif
165 178
166 179 #endif /* _SYS_DSL_DIR_H */
↓ open down ↓ |
52 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX