author | Lin Ling <Lin.Ling@Sun.COM> |
Mon, 22 Jun 2009 23:07:46 -0700 | |
changeset 9951 | a4895b3dd543 |
parent 9554 | 787363635b6a |
child 10242 | c40d075fbca6 |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 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 |
/* |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
22 |
* Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
4543 | 26 |
#include <sys/cred.h> |
789 | 27 |
#include <sys/zfs_context.h> |
28 |
#include <sys/dmu_objset.h> |
|
29 |
#include <sys/dsl_dir.h> |
|
30 |
#include <sys/dsl_dataset.h> |
|
31 |
#include <sys/dsl_prop.h> |
|
32 |
#include <sys/dsl_pool.h> |
|
2199 | 33 |
#include <sys/dsl_synctask.h> |
4543 | 34 |
#include <sys/dsl_deleg.h> |
789 | 35 |
#include <sys/dnode.h> |
36 |
#include <sys/dbuf.h> |
|
2885 | 37 |
#include <sys/zvol.h> |
789 | 38 |
#include <sys/dmu_tx.h> |
39 |
#include <sys/zio_checksum.h> |
|
40 |
#include <sys/zap.h> |
|
41 |
#include <sys/zil.h> |
|
42 |
#include <sys/dmu_impl.h> |
|
4543 | 43 |
#include <sys/zfs_ioctl.h> |
789 | 44 |
|
45 |
spa_t * |
|
46 |
dmu_objset_spa(objset_t *os) |
|
47 |
{ |
|
48 |
return (os->os->os_spa); |
|
49 |
} |
|
50 |
||
51 |
zilog_t * |
|
52 |
dmu_objset_zil(objset_t *os) |
|
53 |
{ |
|
54 |
return (os->os->os_zil); |
|
55 |
} |
|
56 |
||
57 |
dsl_pool_t * |
|
58 |
dmu_objset_pool(objset_t *os) |
|
59 |
{ |
|
60 |
dsl_dataset_t *ds; |
|
61 |
||
62 |
if ((ds = os->os->os_dsl_dataset) != NULL && ds->ds_dir) |
|
63 |
return (ds->ds_dir->dd_pool); |
|
64 |
else |
|
65 |
return (spa_get_dsl(os->os->os_spa)); |
|
66 |
} |
|
67 |
||
68 |
dsl_dataset_t * |
|
69 |
dmu_objset_ds(objset_t *os) |
|
70 |
{ |
|
71 |
return (os->os->os_dsl_dataset); |
|
72 |
} |
|
73 |
||
74 |
dmu_objset_type_t |
|
75 |
dmu_objset_type(objset_t *os) |
|
76 |
{ |
|
77 |
return (os->os->os_phys->os_type); |
|
78 |
} |
|
79 |
||
80 |
void |
|
81 |
dmu_objset_name(objset_t *os, char *buf) |
|
82 |
{ |
|
83 |
dsl_dataset_name(os->os->os_dsl_dataset, buf); |
|
84 |
} |
|
85 |
||
86 |
uint64_t |
|
87 |
dmu_objset_id(objset_t *os) |
|
88 |
{ |
|
89 |
dsl_dataset_t *ds = os->os->os_dsl_dataset; |
|
90 |
||
91 |
return (ds ? ds->ds_object : 0); |
|
92 |
} |
|
93 |
||
94 |
static void |
|
95 |
checksum_changed_cb(void *arg, uint64_t newval) |
|
96 |
{ |
|
97 |
objset_impl_t *osi = arg; |
|
98 |
||
99 |
/* |
|
100 |
* Inheritance should have been done by now. |
|
101 |
*/ |
|
102 |
ASSERT(newval != ZIO_CHECKSUM_INHERIT); |
|
103 |
||
104 |
osi->os_checksum = zio_checksum_select(newval, ZIO_CHECKSUM_ON_VALUE); |
|
105 |
} |
|
106 |
||
107 |
static void |
|
108 |
compression_changed_cb(void *arg, uint64_t newval) |
|
109 |
{ |
|
110 |
objset_impl_t *osi = arg; |
|
111 |
||
112 |
/* |
|
113 |
* Inheritance and range checking should have been done by now. |
|
114 |
*/ |
|
115 |
ASSERT(newval != ZIO_COMPRESS_INHERIT); |
|
116 |
||
117 |
osi->os_compress = zio_compress_select(newval, ZIO_COMPRESS_ON_VALUE); |
|
118 |
} |
|
119 |
||
3835 | 120 |
static void |
121 |
copies_changed_cb(void *arg, uint64_t newval) |
|
122 |
{ |
|
123 |
objset_impl_t *osi = arg; |
|
124 |
||
125 |
/* |
|
126 |
* Inheritance and range checking should have been done by now. |
|
127 |
*/ |
|
128 |
ASSERT(newval > 0); |
|
129 |
ASSERT(newval <= spa_max_replication(osi->os_spa)); |
|
130 |
||
131 |
osi->os_copies = newval; |
|
132 |
} |
|
133 |
||
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
134 |
static void |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
135 |
primary_cache_changed_cb(void *arg, uint64_t newval) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
136 |
{ |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
137 |
objset_impl_t *osi = arg; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
138 |
|
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
139 |
/* |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
140 |
* Inheritance and range checking should have been done by now. |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
141 |
*/ |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
142 |
ASSERT(newval == ZFS_CACHE_ALL || newval == ZFS_CACHE_NONE || |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
143 |
newval == ZFS_CACHE_METADATA); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
144 |
|
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
145 |
osi->os_primary_cache = newval; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
146 |
} |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
147 |
|
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
148 |
static void |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
149 |
secondary_cache_changed_cb(void *arg, uint64_t newval) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
150 |
{ |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
151 |
objset_impl_t *osi = arg; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
152 |
|
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
153 |
/* |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
154 |
* Inheritance and range checking should have been done by now. |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
155 |
*/ |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
156 |
ASSERT(newval == ZFS_CACHE_ALL || newval == ZFS_CACHE_NONE || |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
157 |
newval == ZFS_CACHE_METADATA); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
158 |
|
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
159 |
osi->os_secondary_cache = newval; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
160 |
} |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
161 |
|
789 | 162 |
void |
163 |
dmu_objset_byteswap(void *buf, size_t size) |
|
164 |
{ |
|
165 |
objset_phys_t *osp = buf; |
|
166 |
||
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
167 |
ASSERT(size == OBJSET_OLD_PHYS_SIZE || size == sizeof (objset_phys_t)); |
789 | 168 |
dnode_byteswap(&osp->os_meta_dnode); |
169 |
byteswap_uint64_array(&osp->os_zil_header, sizeof (zil_header_t)); |
|
170 |
osp->os_type = BSWAP_64(osp->os_type); |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
171 |
osp->os_flags = BSWAP_64(osp->os_flags); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
172 |
if (size == sizeof (objset_phys_t)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
173 |
dnode_byteswap(&osp->os_userused_dnode); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
174 |
dnode_byteswap(&osp->os_groupused_dnode); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
175 |
} |
789 | 176 |
} |
177 |
||
1544 | 178 |
int |
179 |
dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp, |
|
180 |
objset_impl_t **osip) |
|
789 | 181 |
{ |
4787 | 182 |
objset_impl_t *osi; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
183 |
int i, err; |
789 | 184 |
|
4787 | 185 |
ASSERT(ds == NULL || MUTEX_HELD(&ds->ds_opening_lock)); |
186 |
||
789 | 187 |
osi = kmem_zalloc(sizeof (objset_impl_t), KM_SLEEP); |
188 |
osi->os.os = osi; |
|
189 |
osi->os_dsl_dataset = ds; |
|
190 |
osi->os_spa = spa; |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
191 |
osi->os_rootbp = bp; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
192 |
if (!BP_IS_HOLE(osi->os_rootbp)) { |
2391 | 193 |
uint32_t aflags = ARC_WAIT; |
1544 | 194 |
zbookmark_t zb; |
195 |
zb.zb_objset = ds ? ds->ds_object : 0; |
|
196 |
zb.zb_object = 0; |
|
197 |
zb.zb_level = -1; |
|
198 |
zb.zb_blkid = 0; |
|
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
199 |
if (DMU_OS_IS_L2CACHEABLE(osi)) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
200 |
aflags |= ARC_L2CACHE; |
1544 | 201 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
202 |
dprintf_bp(osi->os_rootbp, "reading %s", ""); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
203 |
/* |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
204 |
* NB: when bprewrite scrub can change the bp, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
205 |
* and this is called from dmu_objset_open_ds_os, the bp |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
206 |
* could change, and we'll need a lock. |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
207 |
*/ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
208 |
err = arc_read_nolock(NULL, spa, osi->os_rootbp, |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
209 |
arc_getbuf_func, &osi->os_phys_buf, |
2391 | 210 |
ZIO_PRIORITY_SYNC_READ, ZIO_FLAG_CANFAIL, &aflags, &zb); |
1544 | 211 |
if (err) { |
212 |
kmem_free(osi, sizeof (objset_impl_t)); |
|
7294 | 213 |
/* convert checksum errors into IO errors */ |
214 |
if (err == ECKSUM) |
|
215 |
err = EIO; |
|
1544 | 216 |
return (err); |
217 |
} |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
218 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
219 |
/* Increase the blocksize if we are permitted. */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
220 |
if (spa_version(spa) >= SPA_VERSION_USERSPACE && |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
221 |
arc_buf_size(osi->os_phys_buf) < sizeof (objset_phys_t)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
222 |
arc_buf_t *buf = arc_buf_alloc(spa, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
223 |
sizeof (objset_phys_t), &osi->os_phys_buf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
224 |
ARC_BUFC_METADATA); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
225 |
bzero(buf->b_data, sizeof (objset_phys_t)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
226 |
bcopy(osi->os_phys_buf->b_data, buf->b_data, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
227 |
arc_buf_size(osi->os_phys_buf)); |
9554
787363635b6a
6837523 gnu xgettext's useless comments should be filtered
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
228 |
(void) arc_buf_remove_ref(osi->os_phys_buf, |
787363635b6a
6837523 gnu xgettext's useless comments should be filtered
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9396
diff
changeset
|
229 |
&osi->os_phys_buf); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
230 |
osi->os_phys_buf = buf; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
231 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
232 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
233 |
osi->os_phys = osi->os_phys_buf->b_data; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
234 |
osi->os_flags = osi->os_phys->os_flags; |
789 | 235 |
} else { |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
236 |
int size = spa_version(spa) >= SPA_VERSION_USERSPACE ? |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
237 |
sizeof (objset_phys_t) : OBJSET_OLD_PHYS_SIZE; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
238 |
osi->os_phys_buf = arc_buf_alloc(spa, size, |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
239 |
&osi->os_phys_buf, ARC_BUFC_METADATA); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
240 |
osi->os_phys = osi->os_phys_buf->b_data; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
241 |
bzero(osi->os_phys, size); |
789 | 242 |
} |
243 |
||
244 |
/* |
|
245 |
* Note: the changed_cb will be called once before the register |
|
246 |
* func returns, thus changing the checksum/compression from the |
|
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
247 |
* default (fletcher2/off). Snapshots don't need to know about |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
248 |
* checksum/compression/copies. |
789 | 249 |
*/ |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
250 |
if (ds) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
251 |
err = dsl_prop_register(ds, "primarycache", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
252 |
primary_cache_changed_cb, osi); |
1544 | 253 |
if (err == 0) |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
254 |
err = dsl_prop_register(ds, "secondarycache", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
255 |
secondary_cache_changed_cb, osi); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
256 |
if (!dsl_dataset_is_snapshot(ds)) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
257 |
if (err == 0) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
258 |
err = dsl_prop_register(ds, "checksum", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
259 |
checksum_changed_cb, osi); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
260 |
if (err == 0) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
261 |
err = dsl_prop_register(ds, "compression", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
262 |
compression_changed_cb, osi); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
263 |
if (err == 0) |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
264 |
err = dsl_prop_register(ds, "copies", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
265 |
copies_changed_cb, osi); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
266 |
} |
1544 | 267 |
if (err) { |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
268 |
VERIFY(arc_buf_remove_ref(osi->os_phys_buf, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
269 |
&osi->os_phys_buf) == 1); |
1544 | 270 |
kmem_free(osi, sizeof (objset_impl_t)); |
271 |
return (err); |
|
272 |
} |
|
2082 | 273 |
} else if (ds == NULL) { |
789 | 274 |
/* It's the meta-objset. */ |
275 |
osi->os_checksum = ZIO_CHECKSUM_FLETCHER_4; |
|
1544 | 276 |
osi->os_compress = ZIO_COMPRESS_LZJB; |
3835 | 277 |
osi->os_copies = spa_max_replication(spa); |
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
278 |
osi->os_primary_cache = ZFS_CACHE_ALL; |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
279 |
osi->os_secondary_cache = ZFS_CACHE_ALL; |
789 | 280 |
} |
281 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
282 |
osi->os_zil_header = osi->os_phys->os_zil_header; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
283 |
osi->os_zil = zil_alloc(&osi->os, &osi->os_zil_header); |
789 | 284 |
|
285 |
for (i = 0; i < TXG_SIZE; i++) { |
|
286 |
list_create(&osi->os_dirty_dnodes[i], sizeof (dnode_t), |
|
287 |
offsetof(dnode_t, dn_dirty_link[i])); |
|
288 |
list_create(&osi->os_free_dnodes[i], sizeof (dnode_t), |
|
289 |
offsetof(dnode_t, dn_dirty_link[i])); |
|
290 |
} |
|
291 |
list_create(&osi->os_dnodes, sizeof (dnode_t), |
|
292 |
offsetof(dnode_t, dn_link)); |
|
293 |
list_create(&osi->os_downgraded_dbufs, sizeof (dmu_buf_impl_t), |
|
294 |
offsetof(dmu_buf_impl_t, db_link)); |
|
295 |
||
2856 | 296 |
mutex_init(&osi->os_lock, NULL, MUTEX_DEFAULT, NULL); |
297 |
mutex_init(&osi->os_obj_lock, NULL, MUTEX_DEFAULT, NULL); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
298 |
mutex_init(&osi->os_user_ptr_lock, NULL, MUTEX_DEFAULT, NULL); |
2856 | 299 |
|
789 | 300 |
osi->os_meta_dnode = dnode_special_open(osi, |
301 |
&osi->os_phys->os_meta_dnode, DMU_META_DNODE_OBJECT); |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
302 |
if (arc_buf_size(osi->os_phys_buf) >= sizeof (objset_phys_t)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
303 |
osi->os_userused_dnode = dnode_special_open(osi, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
304 |
&osi->os_phys->os_userused_dnode, DMU_USERUSED_OBJECT); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
305 |
osi->os_groupused_dnode = dnode_special_open(osi, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
306 |
&osi->os_phys->os_groupused_dnode, DMU_GROUPUSED_OBJECT); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
307 |
} |
789 | 308 |
|
4787 | 309 |
/* |
310 |
* We should be the only thread trying to do this because we |
|
311 |
* have ds_opening_lock |
|
312 |
*/ |
|
313 |
if (ds) { |
|
314 |
VERIFY(NULL == dsl_dataset_set_user_ptr(ds, osi, |
|
315 |
dmu_objset_evict)); |
|
789 | 316 |
} |
317 |
||
1544 | 318 |
*osip = osi; |
319 |
return (0); |
|
789 | 320 |
} |
321 |
||
5367 | 322 |
static int |
323 |
dmu_objset_open_ds_os(dsl_dataset_t *ds, objset_t *os, dmu_objset_type_t type) |
|
324 |
{ |
|
325 |
objset_impl_t *osi; |
|
326 |
||
327 |
mutex_enter(&ds->ds_opening_lock); |
|
328 |
osi = dsl_dataset_get_user_ptr(ds); |
|
329 |
if (osi == NULL) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
330 |
int err; |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
331 |
|
5367 | 332 |
err = dmu_objset_open_impl(dsl_dataset_get_spa(ds), |
333 |
ds, &ds->ds_phys->ds_bp, &osi); |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
334 |
if (err) { |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
335 |
mutex_exit(&ds->ds_opening_lock); |
5367 | 336 |
return (err); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
337 |
} |
5367 | 338 |
} |
339 |
mutex_exit(&ds->ds_opening_lock); |
|
340 |
||
341 |
os->os = osi; |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
342 |
os->os_mode = DS_MODE_NOHOLD; |
5367 | 343 |
|
344 |
if (type != DMU_OST_ANY && type != os->os->os_phys->os_type) |
|
345 |
return (EINVAL); |
|
346 |
return (0); |
|
347 |
} |
|
348 |
||
349 |
int |
|
350 |
dmu_objset_open_ds(dsl_dataset_t *ds, dmu_objset_type_t type, objset_t **osp) |
|
351 |
{ |
|
352 |
objset_t *os; |
|
353 |
int err; |
|
354 |
||
355 |
os = kmem_alloc(sizeof (objset_t), KM_SLEEP); |
|
356 |
err = dmu_objset_open_ds_os(ds, os, type); |
|
357 |
if (err) |
|
358 |
kmem_free(os, sizeof (objset_t)); |
|
359 |
else |
|
360 |
*osp = os; |
|
361 |
return (err); |
|
362 |
} |
|
363 |
||
789 | 364 |
/* called from zpl */ |
365 |
int |
|
366 |
dmu_objset_open(const char *name, dmu_objset_type_t type, int mode, |
|
367 |
objset_t **osp) |
|
368 |
{ |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
369 |
objset_t *os; |
789 | 370 |
dsl_dataset_t *ds; |
371 |
int err; |
|
372 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
373 |
ASSERT(DS_MODE_TYPE(mode) == DS_MODE_USER || |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
374 |
DS_MODE_TYPE(mode) == DS_MODE_OWNER); |
5367 | 375 |
|
789 | 376 |
os = kmem_alloc(sizeof (objset_t), KM_SLEEP); |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
377 |
if (DS_MODE_TYPE(mode) == DS_MODE_USER) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
378 |
err = dsl_dataset_hold(name, os, &ds); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
379 |
else |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
380 |
err = dsl_dataset_own(name, mode, os, &ds); |
789 | 381 |
if (err) { |
382 |
kmem_free(os, sizeof (objset_t)); |
|
383 |
return (err); |
|
384 |
} |
|
385 |
||
5367 | 386 |
err = dmu_objset_open_ds_os(ds, os, type); |
387 |
if (err) { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
388 |
if (DS_MODE_TYPE(mode) == DS_MODE_USER) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
389 |
dsl_dataset_rele(ds, os); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
390 |
else |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
391 |
dsl_dataset_disown(ds, os); |
5367 | 392 |
kmem_free(os, sizeof (objset_t)); |
393 |
} else { |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
394 |
os->os_mode = mode; |
5367 | 395 |
*osp = os; |
789 | 396 |
} |
5367 | 397 |
return (err); |
789 | 398 |
} |
399 |
||
400 |
void |
|
401 |
dmu_objset_close(objset_t *os) |
|
402 |
{ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
403 |
ASSERT(DS_MODE_TYPE(os->os_mode) == DS_MODE_USER || |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
404 |
DS_MODE_TYPE(os->os_mode) == DS_MODE_OWNER || |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
405 |
DS_MODE_TYPE(os->os_mode) == DS_MODE_NOHOLD); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
406 |
|
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
407 |
if (DS_MODE_TYPE(os->os_mode) == DS_MODE_USER) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
408 |
dsl_dataset_rele(os->os->os_dsl_dataset, os); |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
409 |
else if (DS_MODE_TYPE(os->os_mode) == DS_MODE_OWNER) |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
410 |
dsl_dataset_disown(os->os->os_dsl_dataset, os); |
789 | 411 |
kmem_free(os, sizeof (objset_t)); |
412 |
} |
|
413 |
||
1646
b4e43ae19fff
6393443 Remove remaining txg_wait_synced() from zfs unmount path.
perrin
parents:
1596
diff
changeset
|
414 |
int |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4935
diff
changeset
|
415 |
dmu_objset_evict_dbufs(objset_t *os) |
1544 | 416 |
{ |
417 |
objset_impl_t *osi = os->os; |
|
418 |
dnode_t *dn; |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
419 |
|
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
420 |
mutex_enter(&osi->os_lock); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
421 |
|
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
422 |
/* process the mdn last, since the other dnodes have holds on it */ |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
423 |
list_remove(&osi->os_dnodes, osi->os_meta_dnode); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
424 |
list_insert_tail(&osi->os_dnodes, osi->os_meta_dnode); |
1544 | 425 |
|
426 |
/* |
|
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
427 |
* Find the first dnode with holds. We have to do this dance |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
428 |
* because dnode_add_ref() only works if you already have a |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
429 |
* hold. If there are no holds then it has no dbufs so OK to |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
430 |
* skip. |
1544 | 431 |
*/ |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
432 |
for (dn = list_head(&osi->os_dnodes); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4935
diff
changeset
|
433 |
dn && !dnode_add_ref(dn, FTAG); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
434 |
dn = list_next(&osi->os_dnodes, dn)) |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
435 |
continue; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
436 |
|
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
437 |
while (dn) { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
438 |
dnode_t *next_dn = dn; |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
439 |
|
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
440 |
do { |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
441 |
next_dn = list_next(&osi->os_dnodes, next_dn); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4935
diff
changeset
|
442 |
} while (next_dn && !dnode_add_ref(next_dn, FTAG)); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
443 |
|
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
444 |
mutex_exit(&osi->os_lock); |
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4935
diff
changeset
|
445 |
dnode_evict_dbufs(dn); |
1596
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
446 |
dnode_rele(dn, FTAG); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
447 |
mutex_enter(&osi->os_lock); |
2e2377ccbf85
6395371 ASSERT in dmu_tx_count_free: blkid + i < dn->dn_phys->dn_nblkptr
ahrens
parents:
1544
diff
changeset
|
448 |
dn = next_dn; |
1544 | 449 |
} |
450 |
mutex_exit(&osi->os_lock); |
|
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4935
diff
changeset
|
451 |
return (list_head(&osi->os_dnodes) != osi->os_meta_dnode); |
1544 | 452 |
} |
453 |
||
454 |
void |
|
789 | 455 |
dmu_objset_evict(dsl_dataset_t *ds, void *arg) |
456 |
{ |
|
457 |
objset_impl_t *osi = arg; |
|
1544 | 458 |
objset_t os; |
2082 | 459 |
int i; |
789 | 460 |
|
461 |
for (i = 0; i < TXG_SIZE; i++) { |
|
462 |
ASSERT(list_head(&osi->os_dirty_dnodes[i]) == NULL); |
|
463 |
ASSERT(list_head(&osi->os_free_dnodes[i]) == NULL); |
|
464 |
} |
|
465 |
||
7237
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
466 |
if (ds) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
467 |
if (!dsl_dataset_is_snapshot(ds)) { |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
468 |
VERIFY(0 == dsl_prop_unregister(ds, "checksum", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
469 |
checksum_changed_cb, osi)); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
470 |
VERIFY(0 == dsl_prop_unregister(ds, "compression", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
471 |
compression_changed_cb, osi)); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
472 |
VERIFY(0 == dsl_prop_unregister(ds, "copies", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
473 |
copies_changed_cb, osi)); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
474 |
} |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
475 |
VERIFY(0 == dsl_prop_unregister(ds, "primarycache", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
476 |
primary_cache_changed_cb, osi)); |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
477 |
VERIFY(0 == dsl_prop_unregister(ds, "secondarycache", |
f47d41541b14
PSARC 2008/393 zfs primarycache and secondarycache properties
ek110237
parents:
7046
diff
changeset
|
478 |
secondary_cache_changed_cb, osi)); |
789 | 479 |
} |
480 |
||
1544 | 481 |
/* |
482 |
* We should need only a single pass over the dnode list, since |
|
483 |
* nothing can be added to the list at this point. |
|
484 |
*/ |
|
485 |
os.os = osi; |
|
4944
96d96f8de974
6569719 panic dangling dbufs (dn=ffffffff28814d30, dbuf=ffffffff20756008)
maybee
parents:
4935
diff
changeset
|
486 |
(void) dmu_objset_evict_dbufs(&os); |
1544 | 487 |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
488 |
dnode_special_close(osi->os_meta_dnode); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
489 |
if (osi->os_userused_dnode) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
490 |
dnode_special_close(osi->os_userused_dnode); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
491 |
dnode_special_close(osi->os_groupused_dnode); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
492 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
493 |
zil_free(osi->os_zil); |
789 | 494 |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
495 |
ASSERT3P(list_head(&osi->os_dnodes), ==, NULL); |
789 | 496 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
497 |
VERIFY(arc_buf_remove_ref(osi->os_phys_buf, &osi->os_phys_buf) == 1); |
2856 | 498 |
mutex_destroy(&osi->os_lock); |
499 |
mutex_destroy(&osi->os_obj_lock); |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
500 |
mutex_destroy(&osi->os_user_ptr_lock); |
789 | 501 |
kmem_free(osi, sizeof (objset_impl_t)); |
502 |
} |
|
503 |
||
504 |
/* called from dsl for meta-objset */ |
|
505 |
objset_impl_t * |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
506 |
dmu_objset_create_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp, |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
507 |
dmu_objset_type_t type, dmu_tx_t *tx) |
789 | 508 |
{ |
509 |
objset_impl_t *osi; |
|
510 |
dnode_t *mdn; |
|
511 |
||
512 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
4787 | 513 |
if (ds) |
514 |
mutex_enter(&ds->ds_opening_lock); |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
515 |
VERIFY(0 == dmu_objset_open_impl(spa, ds, bp, &osi)); |
4787 | 516 |
if (ds) |
517 |
mutex_exit(&ds->ds_opening_lock); |
|
789 | 518 |
mdn = osi->os_meta_dnode; |
519 |
||
520 |
dnode_allocate(mdn, DMU_OT_DNODE, 1 << DNODE_BLOCK_SHIFT, |
|
521 |
DN_MAX_INDBLKSHIFT, DMU_OT_NONE, 0, tx); |
|
522 |
||
523 |
/* |
|
524 |
* We don't want to have to increase the meta-dnode's nlevels |
|
525 |
* later, because then we could do it in quescing context while |
|
526 |
* we are also accessing it in open context. |
|
527 |
* |
|
528 |
* This precaution is not necessary for the MOS (ds == NULL), |
|
529 |
* because the MOS is only updated in syncing context. |
|
530 |
* This is most fortunate: the MOS is the only objset that |
|
531 |
* needs to be synced multiple times as spa_sync() iterates |
|
532 |
* to convergence, so minimizing its dn_nlevels matters. |
|
533 |
*/ |
|
1544 | 534 |
if (ds != NULL) { |
535 |
int levels = 1; |
|
536 |
||
537 |
/* |
|
538 |
* Determine the number of levels necessary for the meta-dnode |
|
539 |
* to contain DN_MAX_OBJECT dnodes. |
|
540 |
*/ |
|
541 |
while ((uint64_t)mdn->dn_nblkptr << (mdn->dn_datablkshift + |
|
542 |
(levels - 1) * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT)) < |
|
543 |
DN_MAX_OBJECT * sizeof (dnode_phys_t)) |
|
544 |
levels++; |
|
545 |
||
789 | 546 |
mdn->dn_next_nlevels[tx->tx_txg & TXG_MASK] = |
1544 | 547 |
mdn->dn_nlevels = levels; |
548 |
} |
|
789 | 549 |
|
550 |
ASSERT(type != DMU_OST_NONE); |
|
551 |
ASSERT(type != DMU_OST_ANY); |
|
552 |
ASSERT(type < DMU_OST_NUMTYPES); |
|
553 |
osi->os_phys->os_type = type; |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
554 |
if (dmu_objset_userused_enabled(osi)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
555 |
osi->os_phys->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
556 |
osi->os_flags = osi->os_phys->os_flags; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
557 |
} |
789 | 558 |
|
559 |
dsl_dataset_dirty(ds, tx); |
|
560 |
||
561 |
return (osi); |
|
562 |
} |
|
563 |
||
564 |
struct oscarg { |
|
4543 | 565 |
void (*userfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx); |
789 | 566 |
void *userarg; |
567 |
dsl_dataset_t *clone_parent; |
|
568 |
const char *lastname; |
|
569 |
dmu_objset_type_t type; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
570 |
uint64_t flags; |
789 | 571 |
}; |
572 |
||
4543 | 573 |
/*ARGSUSED*/ |
789 | 574 |
static int |
2199 | 575 |
dmu_objset_create_check(void *arg1, void *arg2, dmu_tx_t *tx) |
789 | 576 |
{ |
2199 | 577 |
dsl_dir_t *dd = arg1; |
578 |
struct oscarg *oa = arg2; |
|
579 |
objset_t *mos = dd->dd_pool->dp_meta_objset; |
|
580 |
int err; |
|
581 |
uint64_t ddobj; |
|
582 |
||
583 |
err = zap_lookup(mos, dd->dd_phys->dd_child_dir_zapobj, |
|
584 |
oa->lastname, sizeof (uint64_t), 1, &ddobj); |
|
585 |
if (err != ENOENT) |
|
586 |
return (err ? err : EEXIST); |
|
587 |
||
588 |
if (oa->clone_parent != NULL) { |
|
589 |
/* |
|
590 |
* You can't clone across pools. |
|
591 |
*/ |
|
592 |
if (oa->clone_parent->ds_dir->dd_pool != dd->dd_pool) |
|
593 |
return (EXDEV); |
|
594 |
||
595 |
/* |
|
596 |
* You can only clone snapshots, not the head datasets. |
|
597 |
*/ |
|
598 |
if (oa->clone_parent->ds_phys->ds_num_children == 0) |
|
599 |
return (EINVAL); |
|
600 |
} |
|
4543 | 601 |
|
2199 | 602 |
return (0); |
603 |
} |
|
604 |
||
605 |
static void |
|
4543 | 606 |
dmu_objset_create_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
2199 | 607 |
{ |
608 |
dsl_dir_t *dd = arg1; |
|
609 |
struct oscarg *oa = arg2; |
|
789 | 610 |
dsl_dataset_t *ds; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
611 |
blkptr_t *bp; |
2199 | 612 |
uint64_t dsobj; |
789 | 613 |
|
614 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
615 |
||
2199 | 616 |
dsobj = dsl_dataset_create_sync(dd, oa->lastname, |
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
617 |
oa->clone_parent, oa->flags, cr, tx); |
789 | 618 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
619 |
VERIFY(0 == dsl_dataset_hold_obj(dd->dd_pool, dsobj, FTAG, &ds)); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
620 |
bp = dsl_dataset_get_blkptr(ds); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
621 |
if (BP_IS_HOLE(bp)) { |
789 | 622 |
objset_impl_t *osi; |
623 |
||
624 |
/* This is an empty dmu_objset; not a clone. */ |
|
625 |
osi = dmu_objset_create_impl(dsl_dataset_get_spa(ds), |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
626 |
ds, bp, oa->type, tx); |
789 | 627 |
|
628 |
if (oa->userfunc) |
|
4543 | 629 |
oa->userfunc(&osi->os, oa->userarg, cr, tx); |
789 | 630 |
} |
4543 | 631 |
|
632 |
spa_history_internal_log(LOG_DS_CREATE, dd->dd_pool->dp_spa, |
|
633 |
tx, cr, "dataset = %llu", dsobj); |
|
634 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
635 |
dsl_dataset_rele(ds, FTAG); |
789 | 636 |
} |
637 |
||
638 |
int |
|
639 |
dmu_objset_create(const char *name, dmu_objset_type_t type, |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
640 |
objset_t *clone_parent, uint64_t flags, |
4543 | 641 |
void (*func)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx), void *arg) |
789 | 642 |
{ |
2199 | 643 |
dsl_dir_t *pdd; |
789 | 644 |
const char *tail; |
645 |
int err = 0; |
|
2199 | 646 |
struct oscarg oa = { 0 }; |
789 | 647 |
|
2199 | 648 |
ASSERT(strchr(name, '@') == NULL); |
649 |
err = dsl_dir_open(name, FTAG, &pdd, &tail); |
|
1544 | 650 |
if (err) |
651 |
return (err); |
|
789 | 652 |
if (tail == NULL) { |
2199 | 653 |
dsl_dir_close(pdd, FTAG); |
789 | 654 |
return (EEXIST); |
655 |
} |
|
656 |
||
657 |
dprintf("name=%s\n", name); |
|
658 |
||
2199 | 659 |
oa.userfunc = func; |
660 |
oa.userarg = arg; |
|
661 |
oa.lastname = tail; |
|
662 |
oa.type = type; |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
663 |
oa.flags = flags; |
4543 | 664 |
|
2199 | 665 |
if (clone_parent != NULL) { |
789 | 666 |
/* |
2199 | 667 |
* You can't clone to a different type. |
789 | 668 |
*/ |
2199 | 669 |
if (clone_parent->os->os_phys->os_type != type) { |
670 |
dsl_dir_close(pdd, FTAG); |
|
671 |
return (EINVAL); |
|
789 | 672 |
} |
2199 | 673 |
oa.clone_parent = clone_parent->os->os_dsl_dataset; |
789 | 674 |
} |
2199 | 675 |
err = dsl_sync_task_do(pdd->dd_pool, dmu_objset_create_check, |
676 |
dmu_objset_create_sync, pdd, &oa, 5); |
|
677 |
dsl_dir_close(pdd, FTAG); |
|
789 | 678 |
return (err); |
679 |
} |
|
680 |
||
681 |
int |
|
682 |
dmu_objset_destroy(const char *name) |
|
683 |
{ |
|
684 |
objset_t *os; |
|
685 |
int error; |
|
686 |
||
687 |
/* |
|
688 |
* If it looks like we'll be able to destroy it, and there's |
|
689 |
* an unplayed replay log sitting around, destroy the log. |
|
690 |
* It would be nicer to do this in dsl_dataset_destroy_sync(), |
|
691 |
* but the replay log objset is modified in open context. |
|
692 |
*/ |
|
5367 | 693 |
error = dmu_objset_open(name, DMU_OST_ANY, |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
694 |
DS_MODE_OWNER|DS_MODE_READONLY|DS_MODE_INCONSISTENT, &os); |
789 | 695 |
if (error == 0) { |
5367 | 696 |
dsl_dataset_t *ds = os->os->os_dsl_dataset; |
1807
35c8b566d7af
6410711 intent log blocks don't get invited to pool parties
bonwick
parents:
1775
diff
changeset
|
697 |
zil_destroy(dmu_objset_zil(os), B_FALSE); |
5367 | 698 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
699 |
error = dsl_dataset_destroy(ds, os); |
5367 | 700 |
/* |
701 |
* dsl_dataset_destroy() closes the ds. |
|
702 |
*/ |
|
703 |
kmem_free(os, sizeof (objset_t)); |
|
789 | 704 |
} |
705 |
||
5367 | 706 |
return (error); |
789 | 707 |
} |
708 |
||
5446 | 709 |
/* |
710 |
* This will close the objset. |
|
711 |
*/ |
|
789 | 712 |
int |
5446 | 713 |
dmu_objset_rollback(objset_t *os) |
789 | 714 |
{ |
715 |
int err; |
|
5367 | 716 |
dsl_dataset_t *ds; |
789 | 717 |
|
5446 | 718 |
ds = os->os->os_dsl_dataset; |
4935
c80bf0e6f4aa
6534949 Stale need for range locking comment in zvol.c
perrin
parents:
4787
diff
changeset
|
719 |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
720 |
if (!dsl_dataset_tryown(ds, TRUE, os)) { |
5446 | 721 |
dmu_objset_close(os); |
722 |
return (EBUSY); |
|
723 |
} |
|
724 |
||
5367 | 725 |
err = dsl_dataset_rollback(ds, os->os->os_phys->os_type); |
4935
c80bf0e6f4aa
6534949 Stale need for range locking comment in zvol.c
perrin
parents:
4787
diff
changeset
|
726 |
|
5367 | 727 |
/* |
728 |
* NB: we close the objset manually because the rollback |
|
729 |
* actually implicitly called dmu_objset_evict(), thus freeing |
|
730 |
* the objset_impl_t. |
|
731 |
*/ |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
732 |
dsl_dataset_disown(ds, os); |
5367 | 733 |
kmem_free(os, sizeof (objset_t)); |
789 | 734 |
return (err); |
735 |
} |
|
736 |
||
2199 | 737 |
struct snaparg { |
738 |
dsl_sync_task_group_t *dstg; |
|
739 |
char *snapname; |
|
740 |
char failed[MAXPATHLEN]; |
|
4543 | 741 |
boolean_t checkperms; |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
742 |
nvlist_t *props; |
5367 | 743 |
}; |
744 |
||
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
745 |
static int |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
746 |
snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx) |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
747 |
{ |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
748 |
objset_t *os = arg1; |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
749 |
struct snaparg *sn = arg2; |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
750 |
|
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
751 |
/* The props have already been checked by zfs_check_userprops(). */ |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
752 |
|
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
753 |
return (dsl_dataset_snapshot_check(os->os->os_dsl_dataset, |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
754 |
sn->snapname, tx)); |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
755 |
} |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
756 |
|
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
757 |
static void |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
758 |
snapshot_sync(void *arg1, void *arg2, cred_t *cr, dmu_tx_t *tx) |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
759 |
{ |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
760 |
objset_t *os = arg1; |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
761 |
dsl_dataset_t *ds = os->os->os_dsl_dataset; |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
762 |
struct snaparg *sn = arg2; |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
763 |
|
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
764 |
dsl_dataset_snapshot_sync(ds, sn->snapname, cr, tx); |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
765 |
|
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
766 |
if (sn->props) |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
767 |
dsl_props_set_sync(ds->ds_prev, sn->props, cr, tx); |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
768 |
} |
2199 | 769 |
|
770 |
static int |
|
771 |
dmu_objset_snapshot_one(char *name, void *arg) |
|
772 |
{ |
|
773 |
struct snaparg *sn = arg; |
|
774 |
objset_t *os; |
|
775 |
int err; |
|
776 |
||
777 |
(void) strcpy(sn->failed, name); |
|
778 |
||
4543 | 779 |
/* |
780 |
* Check permissions only when requested. This only applies when |
|
781 |
* doing a recursive snapshot. The permission checks for the starting |
|
782 |
* dataset have already been performed in zfs_secpolicy_snapshot() |
|
783 |
*/ |
|
784 |
if (sn->checkperms == B_TRUE && |
|
785 |
(err = zfs_secpolicy_snapshot_perms(name, CRED()))) |
|
786 |
return (err); |
|
787 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
788 |
err = dmu_objset_open(name, DMU_OST_ANY, DS_MODE_USER, &os); |
2199 | 789 |
if (err != 0) |
790 |
return (err); |
|
791 |
||
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
792 |
/* If the objset is in an inconsistent state, return busy */ |
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6492
diff
changeset
|
793 |
if (os->os->os_dsl_dataset->ds_phys->ds_flags & DS_FLAG_INCONSISTENT) { |
3637
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
794 |
dmu_objset_close(os); |
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
795 |
return (EBUSY); |
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
796 |
} |
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
797 |
|
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
798 |
/* |
2199 | 799 |
* NB: we need to wait for all in-flight changes to get to disk, |
800 |
* so that we snapshot those changes. zil_suspend does this as |
|
801 |
* a side effect. |
|
802 |
*/ |
|
803 |
err = zil_suspend(dmu_objset_zil(os)); |
|
804 |
if (err == 0) { |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
805 |
dsl_sync_task_create(sn->dstg, snapshot_check, |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
806 |
snapshot_sync, os, sn, 3); |
3637
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
807 |
} else { |
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
808 |
dmu_objset_close(os); |
2199 | 809 |
} |
3637
526d8412c163
6402600 administrative actions while doing 'zfs recv' or 'zfs destroy' can cause confusing situation
rm160521
parents:
3547
diff
changeset
|
810 |
|
2199 | 811 |
return (err); |
812 |
} |
|
813 |
||
814 |
int |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
815 |
dmu_objset_snapshot(char *fsname, char *snapname, |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
816 |
nvlist_t *props, boolean_t recursive) |
2199 | 817 |
{ |
818 |
dsl_sync_task_t *dst; |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
819 |
struct snaparg sn; |
2199 | 820 |
spa_t *spa; |
821 |
int err; |
|
822 |
||
823 |
(void) strcpy(sn.failed, fsname); |
|
824 |
||
4603
c7840c367d00
6494569 zfs recv -d pool/<doesn't exist> core dumps for top-level filesystem backups
ahrens
parents:
4543
diff
changeset
|
825 |
err = spa_open(fsname, &spa, FTAG); |
2199 | 826 |
if (err) |
827 |
return (err); |
|
828 |
||
829 |
sn.dstg = dsl_sync_task_group_create(spa_get_dsl(spa)); |
|
830 |
sn.snapname = snapname; |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
831 |
sn.props = props; |
2199 | 832 |
|
2417 | 833 |
if (recursive) { |
4543 | 834 |
sn.checkperms = B_TRUE; |
2417 | 835 |
err = dmu_objset_find(fsname, |
836 |
dmu_objset_snapshot_one, &sn, DS_FIND_CHILDREN); |
|
837 |
} else { |
|
4543 | 838 |
sn.checkperms = B_FALSE; |
2199 | 839 |
err = dmu_objset_snapshot_one(fsname, &sn); |
2417 | 840 |
} |
2199 | 841 |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
842 |
if (err == 0) |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
843 |
err = dsl_sync_task_group_wait(sn.dstg); |
2199 | 844 |
|
845 |
for (dst = list_head(&sn.dstg->dstg_tasks); dst; |
|
846 |
dst = list_next(&sn.dstg->dstg_tasks, dst)) { |
|
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
847 |
objset_t *os = dst->dst_arg1; |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
848 |
dsl_dataset_t *ds = os->os->os_dsl_dataset; |
2199 | 849 |
if (dst->dst_err) |
5367 | 850 |
dsl_dataset_name(ds, sn.failed); |
9355
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
851 |
zil_resume(dmu_objset_zil(os)); |
09928982c591
6818183 zfs snapshot -r is slow due to set_snap_props() doing txg_wait_synced() for each new snapshot
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
8415
diff
changeset
|
852 |
dmu_objset_close(os); |
2199 | 853 |
} |
5367 | 854 |
|
2199 | 855 |
if (err) |
856 |
(void) strcpy(fsname, sn.failed); |
|
857 |
dsl_sync_task_group_destroy(sn.dstg); |
|
858 |
spa_close(spa, FTAG); |
|
859 |
return (err); |
|
860 |
} |
|
861 |
||
789 | 862 |
static void |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
863 |
dmu_objset_sync_dnodes(list_t *list, list_t *newlist, dmu_tx_t *tx) |
789 | 864 |
{ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
865 |
dnode_t *dn; |
789 | 866 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
867 |
while (dn = list_head(list)) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
868 |
ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
869 |
ASSERT(dn->dn_dbuf->db_data_pending); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
870 |
/* |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
871 |
* Initialize dn_zio outside dnode_sync() because the |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
872 |
* meta-dnode needs to set it ouside dnode_sync(). |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
873 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
874 |
dn->dn_zio = dn->dn_dbuf->db_data_pending->dr_zio; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
875 |
ASSERT(dn->dn_zio); |
789 | 876 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
877 |
ASSERT3U(dn->dn_nlevels, <=, DN_MAX_LEVELS); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
878 |
list_remove(list, dn); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
879 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
880 |
if (newlist) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
881 |
(void) dnode_add_ref(dn, newlist); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
882 |
list_insert_tail(newlist, dn); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
883 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
884 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
885 |
dnode_sync(dn, tx); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
886 |
} |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
887 |
} |
2981 | 888 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
889 |
/* ARGSUSED */ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
890 |
static void |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
891 |
ready(zio_t *zio, arc_buf_t *abuf, void *arg) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
892 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
893 |
blkptr_t *bp = zio->io_bp; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
894 |
blkptr_t *bp_orig = &zio->io_bp_orig; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
895 |
objset_impl_t *os = arg; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
896 |
dnode_phys_t *dnp = &os->os_phys->os_meta_dnode; |
2981 | 897 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
898 |
ASSERT(bp == os->os_rootbp); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
899 |
ASSERT(BP_GET_TYPE(bp) == DMU_OT_OBJSET); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
900 |
ASSERT(BP_GET_LEVEL(bp) == 0); |
5329 | 901 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
902 |
/* |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
903 |
* Update rootbp fill count: it should be the number of objects |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
904 |
* allocated in the object set (not counting the "special" |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
905 |
* objects that are stored in the objset_phys_t -- the meta |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
906 |
* dnode and user/group accounting objects). |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
907 |
*/ |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
908 |
bp->blk_fill = 0; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
909 |
for (int i = 0; i < dnp->dn_nblkptr; i++) |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
910 |
bp->blk_fill += dnp->dn_blkptr[i].blk_fill; |
5329 | 911 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
912 |
if (zio->io_flags & ZIO_FLAG_IO_REWRITE) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
913 |
ASSERT(DVA_EQUAL(BP_IDENTITY(bp), BP_IDENTITY(bp_orig))); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
914 |
} else { |
5329 | 915 |
if (zio->io_bp_orig.blk_birth == os->os_synctx->tx_txg) |
6992 | 916 |
(void) dsl_dataset_block_kill(os->os_dsl_dataset, |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
917 |
&zio->io_bp_orig, zio, os->os_synctx); |
5329 | 918 |
dsl_dataset_block_born(os->os_dsl_dataset, bp, os->os_synctx); |
919 |
} |
|
789 | 920 |
} |
921 |
||
922 |
/* called from dsl */ |
|
923 |
void |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
924 |
dmu_objset_sync(objset_impl_t *os, zio_t *pio, dmu_tx_t *tx) |
789 | 925 |
{ |
926 |
int txgoff; |
|
1544 | 927 |
zbookmark_t zb; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
928 |
writeprops_t wp = { 0 }; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
929 |
zio_t *zio; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
930 |
list_t *list; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
931 |
list_t *newlist = NULL; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
932 |
dbuf_dirty_record_t *dr; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
933 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
934 |
dprintf_ds(os->os_dsl_dataset, "txg=%llu\n", tx->tx_txg); |
789 | 935 |
|
936 |
ASSERT(dmu_tx_is_syncing(tx)); |
|
937 |
/* XXX the write_done callback should really give us the tx... */ |
|
938 |
os->os_synctx = tx; |
|
939 |
||
3882 | 940 |
if (os->os_dsl_dataset == NULL) { |
941 |
/* |
|
942 |
* This is the MOS. If we have upgraded, |
|
943 |
* spa_max_replication() could change, so reset |
|
944 |
* os_copies here. |
|
945 |
*/ |
|
946 |
os->os_copies = spa_max_replication(os->os_spa); |
|
947 |
} |
|
948 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
949 |
/* |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
950 |
* Create the root block IO |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
951 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
952 |
zb.zb_objset = os->os_dsl_dataset ? os->os_dsl_dataset->ds_object : 0; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
953 |
zb.zb_object = 0; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
954 |
zb.zb_level = -1; /* for block ordering; it's level 0 on disk */ |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
955 |
zb.zb_blkid = 0; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
956 |
|
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
957 |
wp.wp_type = DMU_OT_OBJSET; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
958 |
wp.wp_level = 0; /* on-disk BP level; see above */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
959 |
wp.wp_copies = os->os_copies; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
960 |
wp.wp_oschecksum = os->os_checksum; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
961 |
wp.wp_oscompress = os->os_compress; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
962 |
|
4787 | 963 |
if (BP_IS_OLDER(os->os_rootbp, tx->tx_txg)) { |
6992 | 964 |
(void) dsl_dataset_block_kill(os->os_dsl_dataset, |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
965 |
os->os_rootbp, pio, tx); |
4787 | 966 |
} |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
967 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
968 |
arc_release(os->os_phys_buf, &os->os_phys_buf); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
969 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
970 |
zio = arc_write(pio, os->os_spa, &wp, DMU_OS_IS_L2CACHEABLE(os), |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
971 |
tx->tx_txg, os->os_rootbp, os->os_phys_buf, ready, NULL, os, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
972 |
ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb); |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
973 |
|
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
974 |
/* |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
975 |
* Sync special dnodes - the parent IO for the sync is the root block |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
976 |
*/ |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
977 |
os->os_meta_dnode->dn_zio = zio; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
978 |
dnode_sync(os->os_meta_dnode, tx); |
789 | 979 |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
980 |
os->os_phys->os_flags = os->os_flags; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
981 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
982 |
if (os->os_userused_dnode && |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
983 |
os->os_userused_dnode->dn_type != DMU_OT_NONE) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
984 |
os->os_userused_dnode->dn_zio = zio; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
985 |
dnode_sync(os->os_userused_dnode, tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
986 |
os->os_groupused_dnode->dn_zio = zio; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
987 |
dnode_sync(os->os_groupused_dnode, tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
988 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
989 |
|
789 | 990 |
txgoff = tx->tx_txg & TXG_MASK; |
991 |
||
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
992 |
if (dmu_objset_userused_enabled(os)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
993 |
newlist = &os->os_synced_dnodes; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
994 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
995 |
* We must create the list here because it uses the |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
996 |
* dn_dirty_link[] of this txg. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
997 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
998 |
list_create(newlist, sizeof (dnode_t), |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
999 |
offsetof(dnode_t, dn_dirty_link[txgoff])); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1000 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1001 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1002 |
dmu_objset_sync_dnodes(&os->os_free_dnodes[txgoff], newlist, tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1003 |
dmu_objset_sync_dnodes(&os->os_dirty_dnodes[txgoff], newlist, tx); |
789 | 1004 |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1005 |
list = &os->os_meta_dnode->dn_dirty_records[txgoff]; |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1006 |
while (dr = list_head(list)) { |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1007 |
ASSERT(dr->dr_dbuf->db_level == 0); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1008 |
list_remove(list, dr); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1009 |
if (dr->dr_zio) |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1010 |
zio_nowait(dr->dr_zio); |
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1011 |
} |
789 | 1012 |
/* |
1013 |
* Free intent log blocks up to this tx. |
|
1014 |
*/ |
|
1015 |
zil_sync(os->os_zil, tx); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1016 |
os->os_phys->os_zil_header = os->os_zil_header; |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3290
diff
changeset
|
1017 |
zio_nowait(zio); |
789 | 1018 |
} |
1019 |
||
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1020 |
static objset_used_cb_t *used_cbs[DMU_OST_NUMTYPES]; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1021 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1022 |
void |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1023 |
dmu_objset_register_type(dmu_objset_type_t ost, objset_used_cb_t *cb) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1024 |
{ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1025 |
used_cbs[ost] = cb; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1026 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1027 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1028 |
boolean_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1029 |
dmu_objset_userused_enabled(objset_impl_t *os) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1030 |
{ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1031 |
return (spa_version(os->os_spa) >= SPA_VERSION_USERSPACE && |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1032 |
used_cbs[os->os_phys->os_type] && |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1033 |
os->os_userused_dnode); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1034 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1035 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1036 |
void |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1037 |
dmu_objset_do_userquota_callbacks(objset_impl_t *os, dmu_tx_t *tx) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1038 |
{ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1039 |
dnode_t *dn; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1040 |
list_t *list = &os->os_synced_dnodes; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1041 |
static const char zerobuf[DN_MAX_BONUSLEN] = {0}; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1042 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1043 |
ASSERT(list_head(list) == NULL || dmu_objset_userused_enabled(os)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1044 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1045 |
while (dn = list_head(list)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1046 |
dmu_object_type_t bonustype; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1047 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1048 |
ASSERT(!DMU_OBJECT_IS_SPECIAL(dn->dn_object)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1049 |
ASSERT(dn->dn_oldphys); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1050 |
ASSERT(dn->dn_phys->dn_type == DMU_OT_NONE || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1051 |
dn->dn_phys->dn_flags & |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1052 |
DNODE_FLAG_USERUSED_ACCOUNTED); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1053 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1054 |
/* Allocate the user/groupused objects if necessary. */ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1055 |
if (os->os_userused_dnode->dn_type == DMU_OT_NONE) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1056 |
VERIFY(0 == zap_create_claim(&os->os, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1057 |
DMU_USERUSED_OBJECT, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1058 |
DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1059 |
VERIFY(0 == zap_create_claim(&os->os, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1060 |
DMU_GROUPUSED_OBJECT, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1061 |
DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1062 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1063 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1064 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1065 |
* If the object was not previously |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1066 |
* accounted, pretend that it was free. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1067 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1068 |
if (!(dn->dn_oldphys->dn_flags & |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1069 |
DNODE_FLAG_USERUSED_ACCOUNTED)) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1070 |
bzero(dn->dn_oldphys, sizeof (dnode_phys_t)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1071 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1072 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1073 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1074 |
* If the object was freed, use the previous bonustype. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1075 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1076 |
bonustype = dn->dn_phys->dn_bonustype ? |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1077 |
dn->dn_phys->dn_bonustype : dn->dn_oldphys->dn_bonustype; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1078 |
ASSERT(dn->dn_phys->dn_type != 0 || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1079 |
(bcmp(DN_BONUS(dn->dn_phys), zerobuf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1080 |
DN_MAX_BONUSLEN) == 0 && |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1081 |
DN_USED_BYTES(dn->dn_phys) == 0)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1082 |
ASSERT(dn->dn_oldphys->dn_type != 0 || |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1083 |
(bcmp(DN_BONUS(dn->dn_oldphys), zerobuf, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1084 |
DN_MAX_BONUSLEN) == 0 && |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1085 |
DN_USED_BYTES(dn->dn_oldphys) == 0)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1086 |
used_cbs[os->os_phys->os_type](&os->os, bonustype, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1087 |
DN_BONUS(dn->dn_oldphys), DN_BONUS(dn->dn_phys), |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1088 |
DN_USED_BYTES(dn->dn_oldphys), |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1089 |
DN_USED_BYTES(dn->dn_phys), tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1090 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1091 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1092 |
* The mutex is needed here for interlock with dnode_allocate. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1093 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1094 |
mutex_enter(&dn->dn_mtx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1095 |
zio_buf_free(dn->dn_oldphys, sizeof (dnode_phys_t)); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1096 |
dn->dn_oldphys = NULL; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1097 |
mutex_exit(&dn->dn_mtx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1098 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1099 |
list_remove(list, dn); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1100 |
dnode_rele(dn, list); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1101 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1102 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1103 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1104 |
boolean_t |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1105 |
dmu_objset_userspace_present(objset_t *os) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1106 |
{ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1107 |
return (os->os->os_phys->os_flags & |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1108 |
OBJSET_FLAG_USERACCOUNTING_COMPLETE); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1109 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1110 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1111 |
int |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1112 |
dmu_objset_userspace_upgrade(objset_t *os) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1113 |
{ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1114 |
uint64_t obj; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1115 |
int err = 0; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1116 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1117 |
if (dmu_objset_userspace_present(os)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1118 |
return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1119 |
if (!dmu_objset_userused_enabled(os->os)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1120 |
return (ENOTSUP); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1121 |
if (dmu_objset_is_snapshot(os)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1122 |
return (EINVAL); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1123 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1124 |
/* |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1125 |
* We simply need to mark every object dirty, so that it will be |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1126 |
* synced out and now accounted. If this is called |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1127 |
* concurrently, or if we already did some work before crashing, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1128 |
* that's fine, since we track each object's accounted state |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1129 |
* independently. |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1130 |
*/ |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1131 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1132 |
for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE, 0)) { |
9951
a4895b3dd543
6842815 SUNWzfsu package dependency on SUNWPython is not captured
Lin Ling <Lin.Ling@Sun.COM>
parents:
9554
diff
changeset
|
1133 |
dmu_tx_t *tx; |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1134 |
dmu_buf_t *db; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1135 |
int objerr; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1136 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1137 |
if (issig(JUSTLOOKING) && issig(FORREAL)) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1138 |
return (EINTR); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1139 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1140 |
objerr = dmu_bonus_hold(os, obj, FTAG, &db); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1141 |
if (objerr) |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1142 |
continue; |
9951
a4895b3dd543
6842815 SUNWzfsu package dependency on SUNWPython is not captured
Lin Ling <Lin.Ling@Sun.COM>
parents:
9554
diff
changeset
|
1143 |
tx = dmu_tx_create(os); |
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1144 |
dmu_tx_hold_bonus(tx, obj); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1145 |
objerr = dmu_tx_assign(tx, TXG_WAIT); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1146 |
if (objerr) { |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1147 |
dmu_tx_abort(tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1148 |
continue; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1149 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1150 |
dmu_buf_will_dirty(db, tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1151 |
dmu_buf_rele(db, FTAG); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1152 |
dmu_tx_commit(tx); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1153 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1154 |
|
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1155 |
os->os->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE; |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1156 |
txg_wait_synced(dmu_objset_pool(os), 0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1157 |
return (0); |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1158 |
} |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1159 |
|
789 | 1160 |
void |
2885 | 1161 |
dmu_objset_space(objset_t *os, uint64_t *refdbytesp, uint64_t *availbytesp, |
1162 |
uint64_t *usedobjsp, uint64_t *availobjsp) |
|
1163 |
{ |
|
1164 |
dsl_dataset_space(os->os->os_dsl_dataset, refdbytesp, availbytesp, |
|
1165 |
usedobjsp, availobjsp); |
|
1166 |
} |
|
1167 |
||
1168 |
uint64_t |
|
1169 |
dmu_objset_fsid_guid(objset_t *os) |
|
1170 |
{ |
|
1171 |
return (dsl_dataset_fsid_guid(os->os->os_dsl_dataset)); |
|
1172 |
} |
|
1173 |
||
1174 |
void |
|
1175 |
dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat) |
|
789 | 1176 |
{ |
2885 | 1177 |
stat->dds_type = os->os->os_phys->os_type; |
1178 |
if (os->os->os_dsl_dataset) |
|
1179 |
dsl_dataset_fast_stat(os->os->os_dsl_dataset, stat); |
|
1180 |
} |
|
1181 |
||
1182 |
void |
|
1183 |
dmu_objset_stats(objset_t *os, nvlist_t *nv) |
|
1184 |
{ |
|
1185 |
ASSERT(os->os->os_dsl_dataset || |
|
1186 |
os->os->os_phys->os_type == DMU_OST_META); |
|
1187 |
||
1188 |
if (os->os->os_dsl_dataset != NULL) |
|
1189 |
dsl_dataset_stats(os->os->os_dsl_dataset, nv); |
|
1190 |
||
1191 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_TYPE, |
|
1192 |
os->os->os_phys->os_type); |
|
9396
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1193 |
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USERACCOUNTING, |
f41cf682d0d3
PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
9355
diff
changeset
|
1194 |
dmu_objset_userspace_present(os)); |
789 | 1195 |
} |
1196 |
||
1197 |
int |
|
1198 |
dmu_objset_is_snapshot(objset_t *os) |
|
1199 |
{ |
|
1200 |
if (os->os->os_dsl_dataset != NULL) |
|
1201 |
return (dsl_dataset_is_snapshot(os->os->os_dsl_dataset)); |
|
1202 |
else |
|
1203 |
return (B_FALSE); |
|
1204 |
} |
|
1205 |
||
1206 |
int |
|
6492
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1207 |
dmu_snapshot_realname(objset_t *os, char *name, char *real, int maxlen, |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1208 |
boolean_t *conflict) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1209 |
{ |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1210 |
dsl_dataset_t *ds = os->os->os_dsl_dataset; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1211 |
uint64_t ignored; |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1212 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1213 |
if (ds->ds_phys->ds_snapnames_zapobj == 0) |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1214 |
return (ENOENT); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1215 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1216 |
return (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset, |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1217 |
ds->ds_phys->ds_snapnames_zapobj, name, 8, 1, &ignored, MT_FIRST, |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1218 |
real, maxlen, conflict)); |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1219 |
} |
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1220 |
|
903545192033
6654808 FIGNORECASE lookups in a zfs xattr dir don't provide 'realname' data
timh
parents:
6174
diff
changeset
|
1221 |
int |
789 | 1222 |
dmu_snapshot_list_next(objset_t *os, int namelen, char *name, |
5663
029cc4273b57
6627223 gfs needs to support extended dirent flags
ck153898
parents:
5446
diff
changeset
|
1223 |
uint64_t *idp, uint64_t *offp, boolean_t *case_conflict) |
789 | 1224 |
{ |
1225 |
dsl_dataset_t *ds = os->os->os_dsl_dataset; |
|
1226 |
zap_cursor_t cursor; |
|
1227 |
zap_attribute_t attr; |
|
1228 |
||
1229 |
if (ds->ds_phys->ds_snapnames_zapobj == 0) |
|
1230 |
return (ENOENT); |
|
1231 |
||
1232 |
zap_cursor_init_serialized(&cursor, |
|
1233 |
ds->ds_dir->dd_pool->dp_meta_objset, |
|
1234 |
ds->ds_phys->ds_snapnames_zapobj, *offp); |
|
1235 |
||
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1236 |
if (zap_cursor_retrieve(&cursor, &attr) != 0) { |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1237 |
zap_cursor_fini(&cursor); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1238 |
return (ENOENT); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1239 |
} |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1240 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1241 |
if (strlen(attr.za_name) + 1 > namelen) { |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1242 |
zap_cursor_fini(&cursor); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1243 |
return (ENAMETOOLONG); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1244 |
} |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1245 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1246 |
(void) strcpy(name, attr.za_name); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1247 |
if (idp) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1248 |
*idp = attr.za_first_integer; |
5663
029cc4273b57
6627223 gfs needs to support extended dirent flags
ck153898
parents:
5446
diff
changeset
|
1249 |
if (case_conflict) |
029cc4273b57
6627223 gfs needs to support extended dirent flags
ck153898
parents:
5446
diff
changeset
|
1250 |
*case_conflict = attr.za_normalization_conflict; |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1251 |
zap_cursor_advance(&cursor); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1252 |
*offp = zap_cursor_serialize(&cursor); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1253 |
zap_cursor_fini(&cursor); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1254 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1255 |
return (0); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1256 |
} |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1257 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1258 |
int |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1259 |
dmu_dir_list_next(objset_t *os, int namelen, char *name, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1260 |
uint64_t *idp, uint64_t *offp) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1261 |
{ |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1262 |
dsl_dir_t *dd = os->os->os_dsl_dataset->ds_dir; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1263 |
zap_cursor_t cursor; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1264 |
zap_attribute_t attr; |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1265 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1266 |
/* there is no next dir on a snapshot! */ |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1267 |
if (os->os->os_dsl_dataset->ds_object != |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1268 |
dd->dd_phys->dd_head_dataset_obj) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1269 |
return (ENOENT); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1270 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1271 |
zap_cursor_init_serialized(&cursor, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1272 |
dd->dd_pool->dp_meta_objset, |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1273 |
dd->dd_phys->dd_child_dir_zapobj, *offp); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1274 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1275 |
if (zap_cursor_retrieve(&cursor, &attr) != 0) { |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1276 |
zap_cursor_fini(&cursor); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1277 |
return (ENOENT); |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1278 |
} |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1279 |
|
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1280 |
if (strlen(attr.za_name) + 1 > namelen) { |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1281 |
zap_cursor_fini(&cursor); |
789 | 1282 |
return (ENAMETOOLONG); |
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1283 |
} |
789 | 1284 |
|
1285 |
(void) strcpy(name, attr.za_name); |
|
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1286 |
if (idp) |
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1287 |
*idp = attr.za_first_integer; |
789 | 1288 |
zap_cursor_advance(&cursor); |
1289 |
*offp = zap_cursor_serialize(&cursor); |
|
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
1290 |
zap_cursor_fini(&cursor); |
789 | 1291 |
|
1292 |
return (0); |
|
1293 |
} |
|
1294 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1295 |
struct findarg { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1296 |
int (*func)(char *, void *); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1297 |
void *arg; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1298 |
}; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1299 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1300 |
/* ARGSUSED */ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1301 |
static int |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1302 |
findfunc(spa_t *spa, uint64_t dsobj, const char *dsname, void *arg) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1303 |
{ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1304 |
struct findarg *fa = arg; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1305 |
return (fa->func((char *)dsname, fa->arg)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1306 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1307 |
|
789 | 1308 |
/* |
1309 |
* Find all objsets under name, and for each, call 'func(child_name, arg)'. |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1310 |
* Perhaps change all callers to use dmu_objset_find_spa()? |
789 | 1311 |
*/ |
2199 | 1312 |
int |
1313 |
dmu_objset_find(char *name, int func(char *, void *), void *arg, int flags) |
|
789 | 1314 |
{ |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1315 |
struct findarg fa; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1316 |
fa.func = func; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1317 |
fa.arg = arg; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1318 |
return (dmu_objset_find_spa(NULL, name, findfunc, &fa, flags)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1319 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1320 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1321 |
/* |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1322 |
* Find all objsets under name, call func on each |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1323 |
*/ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1324 |
int |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1325 |
dmu_objset_find_spa(spa_t *spa, const char *name, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1326 |
int func(spa_t *, uint64_t, const char *, void *), void *arg, int flags) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1327 |
{ |
789 | 1328 |
dsl_dir_t *dd; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1329 |
dsl_pool_t *dp; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1330 |
dsl_dataset_t *ds; |
789 | 1331 |
zap_cursor_t zc; |
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1332 |
zap_attribute_t *attr; |
789 | 1333 |
char *child; |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1334 |
uint64_t thisobj; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1335 |
int err; |
789 | 1336 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1337 |
if (name == NULL) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1338 |
name = spa_name(spa); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1339 |
err = dsl_dir_open_spa(spa, name, FTAG, &dd, NULL); |
1544 | 1340 |
if (err) |
2199 | 1341 |
return (err); |
789 | 1342 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1343 |
/* Don't visit hidden ($MOS & $ORIGIN) objsets. */ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1344 |
if (dd->dd_myname[0] == '$') { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1345 |
dsl_dir_close(dd, FTAG); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1346 |
return (0); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1347 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1348 |
|
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1349 |
thisobj = dd->dd_phys->dd_head_dataset_obj; |
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1350 |
attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1351 |
dp = dd->dd_pool; |
789 | 1352 |
|
1353 |
/* |
|
1354 |
* Iterate over all children. |
|
1355 |
*/ |
|
2417 | 1356 |
if (flags & DS_FIND_CHILDREN) { |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1357 |
for (zap_cursor_init(&zc, dp->dp_meta_objset, |
2417 | 1358 |
dd->dd_phys->dd_child_dir_zapobj); |
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1359 |
zap_cursor_retrieve(&zc, attr) == 0; |
2417 | 1360 |
(void) zap_cursor_advance(&zc)) { |
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1361 |
ASSERT(attr->za_integer_length == sizeof (uint64_t)); |
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1362 |
ASSERT(attr->za_num_integers == 1); |
789 | 1363 |
|
2417 | 1364 |
child = kmem_alloc(MAXPATHLEN, KM_SLEEP); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1365 |
(void) strcpy(child, name); |
2417 | 1366 |
(void) strcat(child, "/"); |
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1367 |
(void) strcat(child, attr->za_name); |
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1368 |
err = dmu_objset_find_spa(spa, child, func, arg, flags); |
2417 | 1369 |
kmem_free(child, MAXPATHLEN); |
1370 |
if (err) |
|
1371 |
break; |
|
1372 |
} |
|
1373 |
zap_cursor_fini(&zc); |
|
2199 | 1374 |
|
2417 | 1375 |
if (err) { |
1376 |
dsl_dir_close(dd, FTAG); |
|
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1377 |
kmem_free(attr, sizeof (zap_attribute_t)); |
2417 | 1378 |
return (err); |
1379 |
} |
|
789 | 1380 |
} |
1381 |
||
1382 |
/* |
|
1383 |
* Iterate over all snapshots. |
|
1384 |
*/ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1385 |
if (flags & DS_FIND_SNAPSHOTS) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1386 |
if (!dsl_pool_sync_context(dp)) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1387 |
rw_enter(&dp->dp_config_rwlock, RW_READER); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1388 |
err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1389 |
if (!dsl_pool_sync_context(dp)) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1390 |
rw_exit(&dp->dp_config_rwlock); |
789 | 1391 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1392 |
if (err == 0) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1393 |
uint64_t snapobj = ds->ds_phys->ds_snapnames_zapobj; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1394 |
dsl_dataset_rele(ds, FTAG); |
789 | 1395 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1396 |
for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1397 |
zap_cursor_retrieve(&zc, attr) == 0; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1398 |
(void) zap_cursor_advance(&zc)) { |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1399 |
ASSERT(attr->za_integer_length == |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1400 |
sizeof (uint64_t)); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1401 |
ASSERT(attr->za_num_integers == 1); |
789 | 1402 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1403 |
child = kmem_alloc(MAXPATHLEN, KM_SLEEP); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1404 |
(void) strcpy(child, name); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1405 |
(void) strcat(child, "@"); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1406 |
(void) strcat(child, attr->za_name); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1407 |
err = func(spa, attr->za_first_integer, |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1408 |
child, arg); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1409 |
kmem_free(child, MAXPATHLEN); |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1410 |
if (err) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1411 |
break; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1412 |
} |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1413 |
zap_cursor_fini(&zc); |
789 | 1414 |
} |
1415 |
} |
|
1416 |
||
1417 |
dsl_dir_close(dd, FTAG); |
|
3978
2dd668007b7a
6533813 recursive snapshotting resulted in a bad stack overflow
mmusante
parents:
3897
diff
changeset
|
1418 |
kmem_free(attr, sizeof (zap_attribute_t)); |
789 | 1419 |
|
2199 | 1420 |
if (err) |
1421 |
return (err); |
|
1422 |
||
789 | 1423 |
/* |
1424 |
* Apply to self if appropriate. |
|
1425 |
*/ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1426 |
err = func(spa, thisobj, name, arg); |
2199 | 1427 |
return (err); |
789 | 1428 |
} |
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1429 |
|
8415
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1430 |
/* ARGSUSED */ |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1431 |
int |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1432 |
dmu_objset_prefetch(char *name, void *arg) |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1433 |
{ |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1434 |
dsl_dataset_t *ds; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1435 |
|
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1436 |
if (dsl_dataset_hold(name, FTAG, &ds)) |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1437 |
return (0); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1438 |
|
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1439 |
if (!BP_IS_HOLE(&ds->ds_phys->ds_bp)) { |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1440 |
mutex_enter(&ds->ds_opening_lock); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1441 |
if (!dsl_dataset_get_user_ptr(ds)) { |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1442 |
uint32_t aflags = ARC_NOWAIT | ARC_PREFETCH; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1443 |
zbookmark_t zb; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1444 |
|
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1445 |
zb.zb_objset = ds->ds_object; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1446 |
zb.zb_object = 0; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1447 |
zb.zb_level = -1; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1448 |
zb.zb_blkid = 0; |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1449 |
|
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1450 |
(void) arc_read_nolock(NULL, dsl_dataset_get_spa(ds), |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1451 |
&ds->ds_phys->ds_bp, NULL, NULL, |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1452 |
ZIO_PRIORITY_ASYNC_READ, |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1453 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE, |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1454 |
&aflags, &zb); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1455 |
} |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1456 |
mutex_exit(&ds->ds_opening_lock); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1457 |
} |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1458 |
|
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1459 |
dsl_dataset_rele(ds, FTAG); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1460 |
return (0); |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1461 |
} |
d5525cd1cbc2
6386929 initial "zfs list" is slow
Rich Morris <Richard.Morris@Sun.COM>
parents:
8213
diff
changeset
|
1462 |
|
5326
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1463 |
void |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1464 |
dmu_objset_set_user(objset_t *os, void *user_ptr) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1465 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1466 |
ASSERT(MUTEX_HELD(&os->os->os_user_ptr_lock)); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1467 |
os->os->os_user_ptr = user_ptr; |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1468 |
} |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1469 |
|
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1470 |
void * |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1471 |
dmu_objset_get_user(objset_t *os) |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1472 |
{ |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1473 |
ASSERT(MUTEX_HELD(&os->os->os_user_ptr_lock)); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1474 |
return (os->os->os_user_ptr); |
6752aa2bd5bc
6425096 want online 'zfs recv' (read only and read/write)
ek110237
parents:
5147
diff
changeset
|
1475 |
} |