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