Print this page
5056 ZFS deadlock on db_mtx and dn_holds
Reviewed by: Will Andrews <willa@spectralogic.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.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.
|
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
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) 2013 by Delphix. All rights reserved.
24 24 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
25 + * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
25 26 */
26 27
27 28 #ifndef _SYS_DSL_DIR_H
28 29 #define _SYS_DSL_DIR_H
29 30
30 31 #include <sys/dmu.h>
31 32 #include <sys/dsl_pool.h>
32 33 #include <sys/dsl_synctask.h>
33 34 #include <sys/refcount.h>
34 35 #include <sys/zfs_context.h>
35 36
36 37 #ifdef __cplusplus
37 38 extern "C" {
38 39 #endif
39 40
40 41 struct dsl_dataset;
41 42
42 43 /*
43 44 * DD_FIELD_* are strings that are used in the "extensified" dsl_dir zap object.
44 45 * They should be of the format <reverse-dns>:<field>.
45 46 */
46 47
47 48 #define DD_FIELD_FILESYSTEM_COUNT "com.joyent:filesystem_count"
48 49 #define DD_FIELD_SNAPSHOT_COUNT "com.joyent:snapshot_count"
49 50
50 51 typedef enum dd_used {
51 52 DD_USED_HEAD,
52 53 DD_USED_SNAP,
53 54 DD_USED_CHILD,
54 55 DD_USED_CHILD_RSRV,
55 56 DD_USED_REFRSRV,
56 57 DD_USED_NUM
57 58 } dd_used_t;
58 59
59 60 #define DD_FLAG_USED_BREAKDOWN (1<<0)
60 61
61 62 typedef struct dsl_dir_phys {
62 63 uint64_t dd_creation_time; /* not actually used */
63 64 uint64_t dd_head_dataset_obj;
64 65 uint64_t dd_parent_obj;
65 66 uint64_t dd_origin_obj;
66 67 uint64_t dd_child_dir_zapobj;
67 68 /*
68 69 * how much space our children are accounting for; for leaf
69 70 * datasets, == physical space used by fs + snaps
70 71 */
71 72 uint64_t dd_used_bytes;
72 73 uint64_t dd_compressed_bytes;
73 74 uint64_t dd_uncompressed_bytes;
74 75 /* Administrative quota setting */
75 76 uint64_t dd_quota;
76 77 /* Administrative reservation setting */
|
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
77 78 uint64_t dd_reserved;
78 79 uint64_t dd_props_zapobj;
79 80 uint64_t dd_deleg_zapobj; /* dataset delegation permissions */
80 81 uint64_t dd_flags;
81 82 uint64_t dd_used_breakdown[DD_USED_NUM];
82 83 uint64_t dd_clones; /* dsl_dir objects */
83 84 uint64_t dd_pad[13]; /* pad out to 256 bytes for good measure */
84 85 } dsl_dir_phys_t;
85 86
86 87 struct dsl_dir {
88 + dmu_buf_user_t dd_dbu;
89 +
87 90 /* These are immutable; no lock needed: */
88 91 uint64_t dd_object;
89 92 dsl_pool_t *dd_pool;
90 93
91 94 /* Stable until user eviction; no lock needed: */
92 95 dmu_buf_t *dd_dbuf;
93 96
94 97 /* protected by lock on pool's dp_dirty_dirs list */
95 98 txg_node_t dd_dirty_link;
96 99
97 100 /* protected by dp_config_rwlock */
98 101 dsl_dir_t *dd_parent;
99 102
100 103 /* Protected by dd_lock */
101 104 kmutex_t dd_lock;
102 105 list_t dd_prop_cbs; /* list of dsl_prop_cb_record_t's */
103 106 timestruc_t dd_snap_cmtime; /* last time snapshot namespace changed */
104 107 uint64_t dd_origin_txg;
105 108
106 109 /* gross estimate of space used by in-flight tx's */
107 110 uint64_t dd_tempreserved[TXG_SIZE];
108 111 /* amount of space we expect to write; == amount of dirty data */
109 112 int64_t dd_space_towrite[TXG_SIZE];
110 113
111 114 /* protected by dd_lock; keep at end of struct for better locality */
|
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
112 115 char dd_myname[MAXNAMELEN];
113 116 };
114 117
115 118 inline dsl_dir_phys_t *
116 119 dsl_dir_phys(dsl_dir_t *dd)
117 120 {
118 121 return (dd->dd_dbuf->db_data);
119 122 }
120 123
121 124 void dsl_dir_rele(dsl_dir_t *dd, void *tag);
125 +void dsl_dir_async_rele(dsl_dir_t *dd, void *tag);
122 126 int dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
123 127 dsl_dir_t **, const char **tail);
124 128 int dsl_dir_hold_obj(dsl_pool_t *dp, uint64_t ddobj,
125 129 const char *tail, void *tag, dsl_dir_t **);
126 130 void dsl_dir_name(dsl_dir_t *dd, char *buf);
127 131 int dsl_dir_namelen(dsl_dir_t *dd);
128 132 uint64_t dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds,
129 133 const char *name, dmu_tx_t *tx);
130 134 void dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv);
131 135 uint64_t dsl_dir_space_available(dsl_dir_t *dd,
132 136 dsl_dir_t *ancestor, int64_t delta, int ondiskonly);
133 137 void dsl_dir_dirty(dsl_dir_t *dd, dmu_tx_t *tx);
134 138 void dsl_dir_sync(dsl_dir_t *dd, dmu_tx_t *tx);
135 139 int dsl_dir_tempreserve_space(dsl_dir_t *dd, uint64_t mem,
136 140 uint64_t asize, uint64_t fsize, uint64_t usize, void **tr_cookiep,
137 141 dmu_tx_t *tx);
138 142 void dsl_dir_tempreserve_clear(void *tr_cookie, dmu_tx_t *tx);
139 143 void dsl_dir_willuse_space(dsl_dir_t *dd, int64_t space, dmu_tx_t *tx);
140 144 void dsl_dir_diduse_space(dsl_dir_t *dd, dd_used_t type,
141 145 int64_t used, int64_t compressed, int64_t uncompressed, dmu_tx_t *tx);
142 146 void dsl_dir_transfer_space(dsl_dir_t *dd, int64_t delta,
143 147 dd_used_t oldtype, dd_used_t newtype, dmu_tx_t *tx);
144 148 int dsl_dir_set_quota(const char *ddname, zprop_source_t source,
145 149 uint64_t quota);
146 150 int dsl_dir_set_reservation(const char *ddname, zprop_source_t source,
147 151 uint64_t reservation);
148 152 int dsl_dir_activate_fs_ss_limit(const char *);
149 153 int dsl_fs_ss_limit_check(dsl_dir_t *, uint64_t, zfs_prop_t, dsl_dir_t *,
150 154 cred_t *);
151 155 void dsl_fs_ss_count_adjust(dsl_dir_t *, int64_t, const char *, dmu_tx_t *);
152 156 int dsl_dir_rename(const char *oldname, const char *newname);
153 157 int dsl_dir_transfer_possible(dsl_dir_t *sdd, dsl_dir_t *tdd,
154 158 uint64_t fs_cnt, uint64_t ss_cnt, uint64_t space, cred_t *);
155 159 boolean_t dsl_dir_is_clone(dsl_dir_t *dd);
156 160 void dsl_dir_new_refreservation(dsl_dir_t *dd, struct dsl_dataset *ds,
157 161 uint64_t reservation, cred_t *cr, dmu_tx_t *tx);
158 162 void dsl_dir_snap_cmtime_update(dsl_dir_t *dd);
159 163 timestruc_t dsl_dir_snap_cmtime(dsl_dir_t *dd);
160 164 void dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd, uint64_t value,
161 165 dmu_tx_t *tx);
162 166 void dsl_dir_zapify(dsl_dir_t *dd, dmu_tx_t *tx);
163 167 boolean_t dsl_dir_is_zapified(dsl_dir_t *dd);
164 168
165 169 /* internal reserved dir name */
166 170 #define MOS_DIR_NAME "$MOS"
167 171 #define ORIGIN_DIR_NAME "$ORIGIN"
168 172 #define XLATION_DIR_NAME "$XLATION"
169 173 #define FREE_DIR_NAME "$FREE"
170 174 #define LEAK_DIR_NAME "$LEAK"
171 175
172 176 #ifdef ZFS_DEBUG
173 177 #define dprintf_dd(dd, fmt, ...) do { \
174 178 if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
175 179 char *__ds_name = kmem_alloc(MAXNAMELEN + strlen(MOS_DIR_NAME) + 1, \
176 180 KM_SLEEP); \
177 181 dsl_dir_name(dd, __ds_name); \
178 182 dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
179 183 kmem_free(__ds_name, MAXNAMELEN + strlen(MOS_DIR_NAME) + 1); \
180 184 } \
181 185 _NOTE(CONSTCOND) } while (0)
182 186 #else
183 187 #define dprintf_dd(dd, fmt, ...)
184 188 #endif
185 189
186 190 #ifdef __cplusplus
187 191 }
188 192 #endif
189 193
190 194 #endif /* _SYS_DSL_DIR_H */
|
↓ open down ↓ |
59 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX