]> git.proxmox.com Git - mirror_zfs.git/blob - module/zfs/dmu_objset.c
dmu_objset_userquota_get_ids uses dn_bonus unsafely
[mirror_zfs.git] / module / zfs / dmu_objset.c
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25 * Copyright (c) 2013, Joyent, Inc. All rights reserved.
26 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
27 */
28
29 /* Portions Copyright 2010 Robert Milkowski */
30
31 #include <sys/cred.h>
32 #include <sys/zfs_context.h>
33 #include <sys/dmu_objset.h>
34 #include <sys/dsl_dir.h>
35 #include <sys/dsl_dataset.h>
36 #include <sys/dsl_prop.h>
37 #include <sys/dsl_pool.h>
38 #include <sys/dsl_synctask.h>
39 #include <sys/dsl_deleg.h>
40 #include <sys/dnode.h>
41 #include <sys/dbuf.h>
42 #include <sys/zvol.h>
43 #include <sys/dmu_tx.h>
44 #include <sys/zap.h>
45 #include <sys/zil.h>
46 #include <sys/dmu_impl.h>
47 #include <sys/zfs_ioctl.h>
48 #include <sys/sa.h>
49 #include <sys/zfs_onexit.h>
50 #include <sys/dsl_destroy.h>
51
52 /*
53 * Needed to close a window in dnode_move() that allows the objset to be freed
54 * before it can be safely accessed.
55 */
56 krwlock_t os_lock;
57
58 void
59 dmu_objset_init(void)
60 {
61 rw_init(&os_lock, NULL, RW_DEFAULT, NULL);
62 }
63
64 void
65 dmu_objset_fini(void)
66 {
67 rw_destroy(&os_lock);
68 }
69
70 spa_t *
71 dmu_objset_spa(objset_t *os)
72 {
73 return (os->os_spa);
74 }
75
76 zilog_t *
77 dmu_objset_zil(objset_t *os)
78 {
79 return (os->os_zil);
80 }
81
82 dsl_pool_t *
83 dmu_objset_pool(objset_t *os)
84 {
85 dsl_dataset_t *ds;
86
87 if ((ds = os->os_dsl_dataset) != NULL && ds->ds_dir)
88 return (ds->ds_dir->dd_pool);
89 else
90 return (spa_get_dsl(os->os_spa));
91 }
92
93 dsl_dataset_t *
94 dmu_objset_ds(objset_t *os)
95 {
96 return (os->os_dsl_dataset);
97 }
98
99 dmu_objset_type_t
100 dmu_objset_type(objset_t *os)
101 {
102 return (os->os_phys->os_type);
103 }
104
105 void
106 dmu_objset_name(objset_t *os, char *buf)
107 {
108 dsl_dataset_name(os->os_dsl_dataset, buf);
109 }
110
111 uint64_t
112 dmu_objset_id(objset_t *os)
113 {
114 dsl_dataset_t *ds = os->os_dsl_dataset;
115
116 return (ds ? ds->ds_object : 0);
117 }
118
119 zfs_sync_type_t
120 dmu_objset_syncprop(objset_t *os)
121 {
122 return (os->os_sync);
123 }
124
125 zfs_logbias_op_t
126 dmu_objset_logbias(objset_t *os)
127 {
128 return (os->os_logbias);
129 }
130
131 static void
132 checksum_changed_cb(void *arg, uint64_t newval)
133 {
134 objset_t *os = arg;
135
136 /*
137 * Inheritance should have been done by now.
138 */
139 ASSERT(newval != ZIO_CHECKSUM_INHERIT);
140
141 os->os_checksum = zio_checksum_select(newval, ZIO_CHECKSUM_ON_VALUE);
142 }
143
144 static void
145 compression_changed_cb(void *arg, uint64_t newval)
146 {
147 objset_t *os = arg;
148
149 /*
150 * Inheritance and range checking should have been done by now.
151 */
152 ASSERT(newval != ZIO_COMPRESS_INHERIT);
153
154 os->os_compress = zio_compress_select(newval, ZIO_COMPRESS_ON_VALUE);
155 }
156
157 static void
158 copies_changed_cb(void *arg, uint64_t newval)
159 {
160 objset_t *os = arg;
161
162 /*
163 * Inheritance and range checking should have been done by now.
164 */
165 ASSERT(newval > 0);
166 ASSERT(newval <= spa_max_replication(os->os_spa));
167
168 os->os_copies = newval;
169 }
170
171 static void
172 dedup_changed_cb(void *arg, uint64_t newval)
173 {
174 objset_t *os = arg;
175 spa_t *spa = os->os_spa;
176 enum zio_checksum checksum;
177
178 /*
179 * Inheritance should have been done by now.
180 */
181 ASSERT(newval != ZIO_CHECKSUM_INHERIT);
182
183 checksum = zio_checksum_dedup_select(spa, newval, ZIO_CHECKSUM_OFF);
184
185 os->os_dedup_checksum = checksum & ZIO_CHECKSUM_MASK;
186 os->os_dedup_verify = !!(checksum & ZIO_CHECKSUM_VERIFY);
187 }
188
189 static void
190 primary_cache_changed_cb(void *arg, uint64_t newval)
191 {
192 objset_t *os = arg;
193
194 /*
195 * Inheritance and range checking should have been done by now.
196 */
197 ASSERT(newval == ZFS_CACHE_ALL || newval == ZFS_CACHE_NONE ||
198 newval == ZFS_CACHE_METADATA);
199
200 os->os_primary_cache = newval;
201 }
202
203 static void
204 secondary_cache_changed_cb(void *arg, uint64_t newval)
205 {
206 objset_t *os = arg;
207
208 /*
209 * Inheritance and range checking should have been done by now.
210 */
211 ASSERT(newval == ZFS_CACHE_ALL || newval == ZFS_CACHE_NONE ||
212 newval == ZFS_CACHE_METADATA);
213
214 os->os_secondary_cache = newval;
215 }
216
217 static void
218 sync_changed_cb(void *arg, uint64_t newval)
219 {
220 objset_t *os = arg;
221
222 /*
223 * Inheritance and range checking should have been done by now.
224 */
225 ASSERT(newval == ZFS_SYNC_STANDARD || newval == ZFS_SYNC_ALWAYS ||
226 newval == ZFS_SYNC_DISABLED);
227
228 os->os_sync = newval;
229 if (os->os_zil)
230 zil_set_sync(os->os_zil, newval);
231 }
232
233 static void
234 redundant_metadata_changed_cb(void *arg, uint64_t newval)
235 {
236 objset_t *os = arg;
237
238 /*
239 * Inheritance and range checking should have been done by now.
240 */
241 ASSERT(newval == ZFS_REDUNDANT_METADATA_ALL ||
242 newval == ZFS_REDUNDANT_METADATA_MOST);
243
244 os->os_redundant_metadata = newval;
245 }
246
247 static void
248 logbias_changed_cb(void *arg, uint64_t newval)
249 {
250 objset_t *os = arg;
251
252 ASSERT(newval == ZFS_LOGBIAS_LATENCY ||
253 newval == ZFS_LOGBIAS_THROUGHPUT);
254 os->os_logbias = newval;
255 if (os->os_zil)
256 zil_set_logbias(os->os_zil, newval);
257 }
258
259 static void
260 recordsize_changed_cb(void *arg, uint64_t newval)
261 {
262 objset_t *os = arg;
263
264 os->os_recordsize = newval;
265 }
266
267 void
268 dmu_objset_byteswap(void *buf, size_t size)
269 {
270 objset_phys_t *osp = buf;
271
272 ASSERT(size == OBJSET_OLD_PHYS_SIZE || size == sizeof (objset_phys_t));
273 dnode_byteswap(&osp->os_meta_dnode);
274 byteswap_uint64_array(&osp->os_zil_header, sizeof (zil_header_t));
275 osp->os_type = BSWAP_64(osp->os_type);
276 osp->os_flags = BSWAP_64(osp->os_flags);
277 if (size == sizeof (objset_phys_t)) {
278 dnode_byteswap(&osp->os_userused_dnode);
279 dnode_byteswap(&osp->os_groupused_dnode);
280 }
281 }
282
283 int
284 dmu_objset_open_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
285 objset_t **osp)
286 {
287 objset_t *os;
288 int i, err;
289
290 ASSERT(ds == NULL || MUTEX_HELD(&ds->ds_opening_lock));
291
292 os = kmem_zalloc(sizeof (objset_t), KM_SLEEP);
293 os->os_dsl_dataset = ds;
294 os->os_spa = spa;
295 os->os_rootbp = bp;
296 if (!BP_IS_HOLE(os->os_rootbp)) {
297 uint32_t aflags = ARC_WAIT;
298 zbookmark_phys_t zb;
299 SET_BOOKMARK(&zb, ds ? ds->ds_object : DMU_META_OBJSET,
300 ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
301
302 if (DMU_OS_IS_L2CACHEABLE(os))
303 aflags |= ARC_L2CACHE;
304 if (DMU_OS_IS_L2COMPRESSIBLE(os))
305 aflags |= ARC_L2COMPRESS;
306
307 dprintf_bp(os->os_rootbp, "reading %s", "");
308 err = arc_read(NULL, spa, os->os_rootbp,
309 arc_getbuf_func, &os->os_phys_buf,
310 ZIO_PRIORITY_SYNC_READ, ZIO_FLAG_CANFAIL, &aflags, &zb);
311 if (err != 0) {
312 kmem_free(os, sizeof (objset_t));
313 /* convert checksum errors into IO errors */
314 if (err == ECKSUM)
315 err = SET_ERROR(EIO);
316 return (err);
317 }
318
319 /* Increase the blocksize if we are permitted. */
320 if (spa_version(spa) >= SPA_VERSION_USERSPACE &&
321 arc_buf_size(os->os_phys_buf) < sizeof (objset_phys_t)) {
322 arc_buf_t *buf = arc_buf_alloc(spa,
323 sizeof (objset_phys_t), &os->os_phys_buf,
324 ARC_BUFC_METADATA);
325 bzero(buf->b_data, sizeof (objset_phys_t));
326 bcopy(os->os_phys_buf->b_data, buf->b_data,
327 arc_buf_size(os->os_phys_buf));
328 (void) arc_buf_remove_ref(os->os_phys_buf,
329 &os->os_phys_buf);
330 os->os_phys_buf = buf;
331 }
332
333 os->os_phys = os->os_phys_buf->b_data;
334 os->os_flags = os->os_phys->os_flags;
335 } else {
336 int size = spa_version(spa) >= SPA_VERSION_USERSPACE ?
337 sizeof (objset_phys_t) : OBJSET_OLD_PHYS_SIZE;
338 os->os_phys_buf = arc_buf_alloc(spa, size,
339 &os->os_phys_buf, ARC_BUFC_METADATA);
340 os->os_phys = os->os_phys_buf->b_data;
341 bzero(os->os_phys, size);
342 }
343
344 /*
345 * Note: the changed_cb will be called once before the register
346 * func returns, thus changing the checksum/compression from the
347 * default (fletcher2/off). Snapshots don't need to know about
348 * checksum/compression/copies.
349 */
350 if (ds != NULL) {
351 err = dsl_prop_register(ds,
352 zfs_prop_to_name(ZFS_PROP_PRIMARYCACHE),
353 primary_cache_changed_cb, os);
354 if (err == 0) {
355 err = dsl_prop_register(ds,
356 zfs_prop_to_name(ZFS_PROP_SECONDARYCACHE),
357 secondary_cache_changed_cb, os);
358 }
359 if (!ds->ds_is_snapshot) {
360 if (err == 0) {
361 err = dsl_prop_register(ds,
362 zfs_prop_to_name(ZFS_PROP_CHECKSUM),
363 checksum_changed_cb, os);
364 }
365 if (err == 0) {
366 err = dsl_prop_register(ds,
367 zfs_prop_to_name(ZFS_PROP_COMPRESSION),
368 compression_changed_cb, os);
369 }
370 if (err == 0) {
371 err = dsl_prop_register(ds,
372 zfs_prop_to_name(ZFS_PROP_COPIES),
373 copies_changed_cb, os);
374 }
375 if (err == 0) {
376 err = dsl_prop_register(ds,
377 zfs_prop_to_name(ZFS_PROP_DEDUP),
378 dedup_changed_cb, os);
379 }
380 if (err == 0) {
381 err = dsl_prop_register(ds,
382 zfs_prop_to_name(ZFS_PROP_LOGBIAS),
383 logbias_changed_cb, os);
384 }
385 if (err == 0) {
386 err = dsl_prop_register(ds,
387 zfs_prop_to_name(ZFS_PROP_SYNC),
388 sync_changed_cb, os);
389 }
390 if (err == 0) {
391 err = dsl_prop_register(ds,
392 zfs_prop_to_name(
393 ZFS_PROP_REDUNDANT_METADATA),
394 redundant_metadata_changed_cb, os);
395 }
396 if (err == 0) {
397 err = dsl_prop_register(ds,
398 zfs_prop_to_name(ZFS_PROP_RECORDSIZE),
399 recordsize_changed_cb, os);
400 }
401 }
402 if (err != 0) {
403 VERIFY(arc_buf_remove_ref(os->os_phys_buf,
404 &os->os_phys_buf));
405 kmem_free(os, sizeof (objset_t));
406 return (err);
407 }
408 } else {
409 /* It's the meta-objset. */
410 os->os_checksum = ZIO_CHECKSUM_FLETCHER_4;
411 os->os_compress = ZIO_COMPRESS_LZJB;
412 os->os_copies = spa_max_replication(spa);
413 os->os_dedup_checksum = ZIO_CHECKSUM_OFF;
414 os->os_dedup_verify = B_FALSE;
415 os->os_logbias = ZFS_LOGBIAS_LATENCY;
416 os->os_sync = ZFS_SYNC_STANDARD;
417 os->os_primary_cache = ZFS_CACHE_ALL;
418 os->os_secondary_cache = ZFS_CACHE_ALL;
419 }
420
421 if (ds == NULL || !ds->ds_is_snapshot)
422 os->os_zil_header = os->os_phys->os_zil_header;
423 os->os_zil = zil_alloc(os, &os->os_zil_header);
424
425 for (i = 0; i < TXG_SIZE; i++) {
426 list_create(&os->os_dirty_dnodes[i], sizeof (dnode_t),
427 offsetof(dnode_t, dn_dirty_link[i]));
428 list_create(&os->os_free_dnodes[i], sizeof (dnode_t),
429 offsetof(dnode_t, dn_dirty_link[i]));
430 }
431 list_create(&os->os_dnodes, sizeof (dnode_t),
432 offsetof(dnode_t, dn_link));
433 list_create(&os->os_downgraded_dbufs, sizeof (dmu_buf_impl_t),
434 offsetof(dmu_buf_impl_t, db_link));
435
436 list_link_init(&os->os_evicting_node);
437
438 mutex_init(&os->os_lock, NULL, MUTEX_DEFAULT, NULL);
439 mutex_init(&os->os_obj_lock, NULL, MUTEX_DEFAULT, NULL);
440 mutex_init(&os->os_user_ptr_lock, NULL, MUTEX_DEFAULT, NULL);
441
442 dnode_special_open(os, &os->os_phys->os_meta_dnode,
443 DMU_META_DNODE_OBJECT, &os->os_meta_dnode);
444 if (arc_buf_size(os->os_phys_buf) >= sizeof (objset_phys_t)) {
445 dnode_special_open(os, &os->os_phys->os_userused_dnode,
446 DMU_USERUSED_OBJECT, &os->os_userused_dnode);
447 dnode_special_open(os, &os->os_phys->os_groupused_dnode,
448 DMU_GROUPUSED_OBJECT, &os->os_groupused_dnode);
449 }
450
451 *osp = os;
452 return (0);
453 }
454
455 int
456 dmu_objset_from_ds(dsl_dataset_t *ds, objset_t **osp)
457 {
458 int err = 0;
459
460 mutex_enter(&ds->ds_opening_lock);
461 if (ds->ds_objset == NULL) {
462 objset_t *os;
463 err = dmu_objset_open_impl(dsl_dataset_get_spa(ds),
464 ds, dsl_dataset_get_blkptr(ds), &os);
465
466 if (err == 0) {
467 mutex_enter(&ds->ds_lock);
468 ASSERT(ds->ds_objset == NULL);
469 ds->ds_objset = os;
470 mutex_exit(&ds->ds_lock);
471 }
472 }
473 *osp = ds->ds_objset;
474 mutex_exit(&ds->ds_opening_lock);
475 return (err);
476 }
477
478 /*
479 * Holds the pool while the objset is held. Therefore only one objset
480 * can be held at a time.
481 */
482 int
483 dmu_objset_hold(const char *name, void *tag, objset_t **osp)
484 {
485 dsl_pool_t *dp;
486 dsl_dataset_t *ds;
487 int err;
488
489 err = dsl_pool_hold(name, tag, &dp);
490 if (err != 0)
491 return (err);
492 err = dsl_dataset_hold(dp, name, tag, &ds);
493 if (err != 0) {
494 dsl_pool_rele(dp, tag);
495 return (err);
496 }
497
498 err = dmu_objset_from_ds(ds, osp);
499 if (err != 0) {
500 dsl_dataset_rele(ds, tag);
501 dsl_pool_rele(dp, tag);
502 }
503
504 return (err);
505 }
506
507 /*
508 * dsl_pool must not be held when this is called.
509 * Upon successful return, there will be a longhold on the dataset,
510 * and the dsl_pool will not be held.
511 */
512 int
513 dmu_objset_own(const char *name, dmu_objset_type_t type,
514 boolean_t readonly, void *tag, objset_t **osp)
515 {
516 dsl_pool_t *dp;
517 dsl_dataset_t *ds;
518 int err;
519
520 err = dsl_pool_hold(name, FTAG, &dp);
521 if (err != 0)
522 return (err);
523 err = dsl_dataset_own(dp, name, tag, &ds);
524 if (err != 0) {
525 dsl_pool_rele(dp, FTAG);
526 return (err);
527 }
528
529 err = dmu_objset_from_ds(ds, osp);
530 dsl_pool_rele(dp, FTAG);
531 if (err != 0) {
532 dsl_dataset_disown(ds, tag);
533 } else if (type != DMU_OST_ANY && type != (*osp)->os_phys->os_type) {
534 dsl_dataset_disown(ds, tag);
535 return (SET_ERROR(EINVAL));
536 } else if (!readonly && ds->ds_is_snapshot) {
537 dsl_dataset_disown(ds, tag);
538 return (SET_ERROR(EROFS));
539 }
540 return (err);
541 }
542
543 void
544 dmu_objset_rele(objset_t *os, void *tag)
545 {
546 dsl_pool_t *dp = dmu_objset_pool(os);
547 dsl_dataset_rele(os->os_dsl_dataset, tag);
548 dsl_pool_rele(dp, tag);
549 }
550
551 /*
552 * When we are called, os MUST refer to an objset associated with a dataset
553 * that is owned by 'tag'; that is, is held and long held by 'tag' and ds_owner
554 * == tag. We will then release and reacquire ownership of the dataset while
555 * holding the pool config_rwlock to avoid intervening namespace or ownership
556 * changes may occur.
557 *
558 * This exists solely to accommodate zfs_ioc_userspace_upgrade()'s desire to
559 * release the hold on its dataset and acquire a new one on the dataset of the
560 * same name so that it can be partially torn down and reconstructed.
561 */
562 void
563 dmu_objset_refresh_ownership(objset_t *os, void *tag)
564 {
565 dsl_pool_t *dp;
566 dsl_dataset_t *ds, *newds;
567 char name[MAXNAMELEN];
568
569 ds = os->os_dsl_dataset;
570 VERIFY3P(ds, !=, NULL);
571 VERIFY3P(ds->ds_owner, ==, tag);
572 VERIFY(dsl_dataset_long_held(ds));
573
574 dsl_dataset_name(ds, name);
575 dp = dmu_objset_pool(os);
576 dsl_pool_config_enter(dp, FTAG);
577 dmu_objset_disown(os, tag);
578 VERIFY0(dsl_dataset_own(dp, name, tag, &newds));
579 VERIFY3P(newds, ==, os->os_dsl_dataset);
580 dsl_pool_config_exit(dp, FTAG);
581 }
582
583 void
584 dmu_objset_disown(objset_t *os, void *tag)
585 {
586 dsl_dataset_disown(os->os_dsl_dataset, tag);
587 }
588
589 void
590 dmu_objset_evict_dbufs(objset_t *os)
591 {
592 dnode_t *dn_marker;
593 dnode_t *dn;
594
595 dn_marker = kmem_alloc(sizeof (dnode_t), KM_SLEEP);
596
597 mutex_enter(&os->os_lock);
598 dn = list_head(&os->os_dnodes);
599 while (dn != NULL) {
600 /*
601 * Skip dnodes without holds. We have to do this dance
602 * because dnode_add_ref() only works if there is already a
603 * hold. If the dnode has no holds, then it has no dbufs.
604 */
605 if (dnode_add_ref(dn, FTAG)) {
606 list_insert_after(&os->os_dnodes, dn, dn_marker);
607 mutex_exit(&os->os_lock);
608
609 dnode_evict_dbufs(dn);
610 dnode_rele(dn, FTAG);
611
612 mutex_enter(&os->os_lock);
613 dn = list_next(&os->os_dnodes, dn_marker);
614 list_remove(&os->os_dnodes, dn_marker);
615 } else {
616 dn = list_next(&os->os_dnodes, dn);
617 }
618 }
619 mutex_exit(&os->os_lock);
620
621 kmem_free(dn_marker, sizeof (dnode_t));
622
623 if (DMU_USERUSED_DNODE(os) != NULL) {
624 dnode_evict_dbufs(DMU_GROUPUSED_DNODE(os));
625 dnode_evict_dbufs(DMU_USERUSED_DNODE(os));
626 }
627 dnode_evict_dbufs(DMU_META_DNODE(os));
628 }
629
630 /*
631 * Objset eviction processing is split into into two pieces.
632 * The first marks the objset as evicting, evicts any dbufs that
633 * have a refcount of zero, and then queues up the objset for the
634 * second phase of eviction. Once os->os_dnodes has been cleared by
635 * dnode_buf_pageout()->dnode_destroy(), the second phase is executed.
636 * The second phase closes the special dnodes, dequeues the objset from
637 * the list of those undergoing eviction, and finally frees the objset.
638 *
639 * NOTE: Due to asynchronous eviction processing (invocation of
640 * dnode_buf_pageout()), it is possible for the meta dnode for the
641 * objset to have no holds even though os->os_dnodes is not empty.
642 */
643 void
644 dmu_objset_evict(objset_t *os)
645 {
646 int t;
647
648 dsl_dataset_t *ds = os->os_dsl_dataset;
649
650 for (t = 0; t < TXG_SIZE; t++)
651 ASSERT(!dmu_objset_is_dirty(os, t));
652
653 if (ds) {
654 if (!ds->ds_is_snapshot) {
655 VERIFY0(dsl_prop_unregister(ds,
656 zfs_prop_to_name(ZFS_PROP_CHECKSUM),
657 checksum_changed_cb, os));
658 VERIFY0(dsl_prop_unregister(ds,
659 zfs_prop_to_name(ZFS_PROP_COMPRESSION),
660 compression_changed_cb, os));
661 VERIFY0(dsl_prop_unregister(ds,
662 zfs_prop_to_name(ZFS_PROP_COPIES),
663 copies_changed_cb, os));
664 VERIFY0(dsl_prop_unregister(ds,
665 zfs_prop_to_name(ZFS_PROP_DEDUP),
666 dedup_changed_cb, os));
667 VERIFY0(dsl_prop_unregister(ds,
668 zfs_prop_to_name(ZFS_PROP_LOGBIAS),
669 logbias_changed_cb, os));
670 VERIFY0(dsl_prop_unregister(ds,
671 zfs_prop_to_name(ZFS_PROP_SYNC),
672 sync_changed_cb, os));
673 VERIFY0(dsl_prop_unregister(ds,
674 zfs_prop_to_name(ZFS_PROP_REDUNDANT_METADATA),
675 redundant_metadata_changed_cb, os));
676 VERIFY0(dsl_prop_unregister(ds,
677 zfs_prop_to_name(ZFS_PROP_RECORDSIZE),
678 recordsize_changed_cb, os));
679 }
680 VERIFY0(dsl_prop_unregister(ds,
681 zfs_prop_to_name(ZFS_PROP_PRIMARYCACHE),
682 primary_cache_changed_cb, os));
683 VERIFY0(dsl_prop_unregister(ds,
684 zfs_prop_to_name(ZFS_PROP_SECONDARYCACHE),
685 secondary_cache_changed_cb, os));
686 }
687
688 if (os->os_sa)
689 sa_tear_down(os);
690
691 os->os_evicting = B_TRUE;
692 dmu_objset_evict_dbufs(os);
693
694 mutex_enter(&os->os_lock);
695 spa_evicting_os_register(os->os_spa, os);
696 if (list_is_empty(&os->os_dnodes)) {
697 mutex_exit(&os->os_lock);
698 dmu_objset_evict_done(os);
699 } else {
700 mutex_exit(&os->os_lock);
701 }
702 }
703
704 void
705 dmu_objset_evict_done(objset_t *os)
706 {
707 ASSERT3P(list_head(&os->os_dnodes), ==, NULL);
708
709 dnode_special_close(&os->os_meta_dnode);
710 if (DMU_USERUSED_DNODE(os)) {
711 dnode_special_close(&os->os_userused_dnode);
712 dnode_special_close(&os->os_groupused_dnode);
713 }
714 zil_free(os->os_zil);
715
716 VERIFY(arc_buf_remove_ref(os->os_phys_buf, &os->os_phys_buf));
717
718 /*
719 * This is a barrier to prevent the objset from going away in
720 * dnode_move() until we can safely ensure that the objset is still in
721 * use. We consider the objset valid before the barrier and invalid
722 * after the barrier.
723 */
724 rw_enter(&os_lock, RW_READER);
725 rw_exit(&os_lock);
726
727 mutex_destroy(&os->os_lock);
728 mutex_destroy(&os->os_obj_lock);
729 mutex_destroy(&os->os_user_ptr_lock);
730 spa_evicting_os_deregister(os->os_spa, os);
731 kmem_free(os, sizeof (objset_t));
732 }
733
734 timestruc_t
735 dmu_objset_snap_cmtime(objset_t *os)
736 {
737 return (dsl_dir_snap_cmtime(os->os_dsl_dataset->ds_dir));
738 }
739
740 /* called from dsl for meta-objset */
741 objset_t *
742 dmu_objset_create_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
743 dmu_objset_type_t type, dmu_tx_t *tx)
744 {
745 objset_t *os;
746 dnode_t *mdn;
747
748 ASSERT(dmu_tx_is_syncing(tx));
749
750 if (ds != NULL)
751 VERIFY0(dmu_objset_from_ds(ds, &os));
752 else
753 VERIFY0(dmu_objset_open_impl(spa, NULL, bp, &os));
754
755 mdn = DMU_META_DNODE(os);
756
757 dnode_allocate(mdn, DMU_OT_DNODE, 1 << DNODE_BLOCK_SHIFT,
758 DN_MAX_INDBLKSHIFT, DMU_OT_NONE, 0, tx);
759
760 /*
761 * We don't want to have to increase the meta-dnode's nlevels
762 * later, because then we could do it in quescing context while
763 * we are also accessing it in open context.
764 *
765 * This precaution is not necessary for the MOS (ds == NULL),
766 * because the MOS is only updated in syncing context.
767 * This is most fortunate: the MOS is the only objset that
768 * needs to be synced multiple times as spa_sync() iterates
769 * to convergence, so minimizing its dn_nlevels matters.
770 */
771 if (ds != NULL) {
772 int levels = 1;
773
774 /*
775 * Determine the number of levels necessary for the meta-dnode
776 * to contain DN_MAX_OBJECT dnodes.
777 */
778 while ((uint64_t)mdn->dn_nblkptr << (mdn->dn_datablkshift +
779 (levels - 1) * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT)) <
780 DN_MAX_OBJECT * sizeof (dnode_phys_t))
781 levels++;
782
783 mdn->dn_next_nlevels[tx->tx_txg & TXG_MASK] =
784 mdn->dn_nlevels = levels;
785 }
786
787 ASSERT(type != DMU_OST_NONE);
788 ASSERT(type != DMU_OST_ANY);
789 ASSERT(type < DMU_OST_NUMTYPES);
790 os->os_phys->os_type = type;
791 if (dmu_objset_userused_enabled(os)) {
792 os->os_phys->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE;
793 os->os_flags = os->os_phys->os_flags;
794 }
795
796 dsl_dataset_dirty(ds, tx);
797
798 return (os);
799 }
800
801 typedef struct dmu_objset_create_arg {
802 const char *doca_name;
803 cred_t *doca_cred;
804 void (*doca_userfunc)(objset_t *os, void *arg,
805 cred_t *cr, dmu_tx_t *tx);
806 void *doca_userarg;
807 dmu_objset_type_t doca_type;
808 uint64_t doca_flags;
809 } dmu_objset_create_arg_t;
810
811 /*ARGSUSED*/
812 static int
813 dmu_objset_create_check(void *arg, dmu_tx_t *tx)
814 {
815 dmu_objset_create_arg_t *doca = arg;
816 dsl_pool_t *dp = dmu_tx_pool(tx);
817 dsl_dir_t *pdd;
818 const char *tail;
819 int error;
820
821 if (strchr(doca->doca_name, '@') != NULL)
822 return (SET_ERROR(EINVAL));
823
824 error = dsl_dir_hold(dp, doca->doca_name, FTAG, &pdd, &tail);
825 if (error != 0)
826 return (error);
827 if (tail == NULL) {
828 dsl_dir_rele(pdd, FTAG);
829 return (SET_ERROR(EEXIST));
830 }
831 error = dsl_fs_ss_limit_check(pdd, 1, ZFS_PROP_FILESYSTEM_LIMIT, NULL,
832 doca->doca_cred);
833 dsl_dir_rele(pdd, FTAG);
834
835 return (error);
836 }
837
838 static void
839 dmu_objset_create_sync(void *arg, dmu_tx_t *tx)
840 {
841 dmu_objset_create_arg_t *doca = arg;
842 dsl_pool_t *dp = dmu_tx_pool(tx);
843 dsl_dir_t *pdd;
844 const char *tail;
845 dsl_dataset_t *ds;
846 uint64_t obj;
847 blkptr_t *bp;
848 objset_t *os;
849
850 VERIFY0(dsl_dir_hold(dp, doca->doca_name, FTAG, &pdd, &tail));
851
852 obj = dsl_dataset_create_sync(pdd, tail, NULL, doca->doca_flags,
853 doca->doca_cred, tx);
854
855 VERIFY0(dsl_dataset_hold_obj(pdd->dd_pool, obj, FTAG, &ds));
856 bp = dsl_dataset_get_blkptr(ds);
857 os = dmu_objset_create_impl(pdd->dd_pool->dp_spa,
858 ds, bp, doca->doca_type, tx);
859
860 if (doca->doca_userfunc != NULL) {
861 doca->doca_userfunc(os, doca->doca_userarg,
862 doca->doca_cred, tx);
863 }
864
865 spa_history_log_internal_ds(ds, "create", tx, "");
866 dsl_dataset_rele(ds, FTAG);
867 dsl_dir_rele(pdd, FTAG);
868 }
869
870 int
871 dmu_objset_create(const char *name, dmu_objset_type_t type, uint64_t flags,
872 void (*func)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx), void *arg)
873 {
874 dmu_objset_create_arg_t doca;
875
876 doca.doca_name = name;
877 doca.doca_cred = CRED();
878 doca.doca_flags = flags;
879 doca.doca_userfunc = func;
880 doca.doca_userarg = arg;
881 doca.doca_type = type;
882
883 return (dsl_sync_task(name,
884 dmu_objset_create_check, dmu_objset_create_sync, &doca,
885 5, ZFS_SPACE_CHECK_NORMAL));
886 }
887
888 typedef struct dmu_objset_clone_arg {
889 const char *doca_clone;
890 const char *doca_origin;
891 cred_t *doca_cred;
892 } dmu_objset_clone_arg_t;
893
894 /*ARGSUSED*/
895 static int
896 dmu_objset_clone_check(void *arg, dmu_tx_t *tx)
897 {
898 dmu_objset_clone_arg_t *doca = arg;
899 dsl_dir_t *pdd;
900 const char *tail;
901 int error;
902 dsl_dataset_t *origin;
903 dsl_pool_t *dp = dmu_tx_pool(tx);
904
905 if (strchr(doca->doca_clone, '@') != NULL)
906 return (SET_ERROR(EINVAL));
907
908 error = dsl_dir_hold(dp, doca->doca_clone, FTAG, &pdd, &tail);
909 if (error != 0)
910 return (error);
911 if (tail == NULL) {
912 dsl_dir_rele(pdd, FTAG);
913 return (SET_ERROR(EEXIST));
914 }
915 /* You can't clone across pools. */
916 if (pdd->dd_pool != dp) {
917 dsl_dir_rele(pdd, FTAG);
918 return (SET_ERROR(EXDEV));
919 }
920 error = dsl_fs_ss_limit_check(pdd, 1, ZFS_PROP_FILESYSTEM_LIMIT, NULL,
921 doca->doca_cred);
922 if (error != 0) {
923 dsl_dir_rele(pdd, FTAG);
924 return (SET_ERROR(EDQUOT));
925 }
926 dsl_dir_rele(pdd, FTAG);
927
928 error = dsl_dataset_hold(dp, doca->doca_origin, FTAG, &origin);
929 if (error != 0)
930 return (error);
931
932 /* You can't clone across pools. */
933 if (origin->ds_dir->dd_pool != dp) {
934 dsl_dataset_rele(origin, FTAG);
935 return (SET_ERROR(EXDEV));
936 }
937
938 /* You can only clone snapshots, not the head datasets. */
939 if (!origin->ds_is_snapshot) {
940 dsl_dataset_rele(origin, FTAG);
941 return (SET_ERROR(EINVAL));
942 }
943 dsl_dataset_rele(origin, FTAG);
944
945 return (0);
946 }
947
948 static void
949 dmu_objset_clone_sync(void *arg, dmu_tx_t *tx)
950 {
951 dmu_objset_clone_arg_t *doca = arg;
952 dsl_pool_t *dp = dmu_tx_pool(tx);
953 dsl_dir_t *pdd;
954 const char *tail;
955 dsl_dataset_t *origin, *ds;
956 uint64_t obj;
957 char namebuf[MAXNAMELEN];
958
959 VERIFY0(dsl_dir_hold(dp, doca->doca_clone, FTAG, &pdd, &tail));
960 VERIFY0(dsl_dataset_hold(dp, doca->doca_origin, FTAG, &origin));
961
962 obj = dsl_dataset_create_sync(pdd, tail, origin, 0,
963 doca->doca_cred, tx);
964
965 VERIFY0(dsl_dataset_hold_obj(pdd->dd_pool, obj, FTAG, &ds));
966 dsl_dataset_name(origin, namebuf);
967 spa_history_log_internal_ds(ds, "clone", tx,
968 "origin=%s (%llu)", namebuf, origin->ds_object);
969 dsl_dataset_rele(ds, FTAG);
970 dsl_dataset_rele(origin, FTAG);
971 dsl_dir_rele(pdd, FTAG);
972 }
973
974 int
975 dmu_objset_clone(const char *clone, const char *origin)
976 {
977 dmu_objset_clone_arg_t doca;
978
979 doca.doca_clone = clone;
980 doca.doca_origin = origin;
981 doca.doca_cred = CRED();
982
983 return (dsl_sync_task(clone,
984 dmu_objset_clone_check, dmu_objset_clone_sync, &doca,
985 5, ZFS_SPACE_CHECK_NORMAL));
986 }
987
988 int
989 dmu_objset_snapshot_one(const char *fsname, const char *snapname)
990 {
991 int err;
992 char *longsnap = kmem_asprintf("%s@%s", fsname, snapname);
993 nvlist_t *snaps = fnvlist_alloc();
994
995 fnvlist_add_boolean(snaps, longsnap);
996 strfree(longsnap);
997 err = dsl_dataset_snapshot(snaps, NULL, NULL);
998 fnvlist_free(snaps);
999 return (err);
1000 }
1001
1002 static void
1003 dmu_objset_sync_dnodes(list_t *list, list_t *newlist, dmu_tx_t *tx)
1004 {
1005 dnode_t *dn;
1006
1007 while ((dn = list_head(list))) {
1008 ASSERT(dn->dn_object != DMU_META_DNODE_OBJECT);
1009 ASSERT(dn->dn_dbuf->db_data_pending);
1010 /*
1011 * Initialize dn_zio outside dnode_sync() because the
1012 * meta-dnode needs to set it ouside dnode_sync().
1013 */
1014 dn->dn_zio = dn->dn_dbuf->db_data_pending->dr_zio;
1015 ASSERT(dn->dn_zio);
1016
1017 ASSERT3U(dn->dn_nlevels, <=, DN_MAX_LEVELS);
1018 list_remove(list, dn);
1019
1020 if (newlist) {
1021 (void) dnode_add_ref(dn, newlist);
1022 list_insert_tail(newlist, dn);
1023 }
1024
1025 dnode_sync(dn, tx);
1026 }
1027 }
1028
1029 /* ARGSUSED */
1030 static void
1031 dmu_objset_write_ready(zio_t *zio, arc_buf_t *abuf, void *arg)
1032 {
1033 int i;
1034
1035 blkptr_t *bp = zio->io_bp;
1036 objset_t *os = arg;
1037 dnode_phys_t *dnp = &os->os_phys->os_meta_dnode;
1038
1039 ASSERT(!BP_IS_EMBEDDED(bp));
1040 ASSERT3P(bp, ==, os->os_rootbp);
1041 ASSERT3U(BP_GET_TYPE(bp), ==, DMU_OT_OBJSET);
1042 ASSERT0(BP_GET_LEVEL(bp));
1043
1044 /*
1045 * Update rootbp fill count: it should be the number of objects
1046 * allocated in the object set (not counting the "special"
1047 * objects that are stored in the objset_phys_t -- the meta
1048 * dnode and user/group accounting objects).
1049 */
1050 bp->blk_fill = 0;
1051 for (i = 0; i < dnp->dn_nblkptr; i++)
1052 bp->blk_fill += BP_GET_FILL(&dnp->dn_blkptr[i]);
1053 }
1054
1055 /* ARGSUSED */
1056 static void
1057 dmu_objset_write_done(zio_t *zio, arc_buf_t *abuf, void *arg)
1058 {
1059 blkptr_t *bp = zio->io_bp;
1060 blkptr_t *bp_orig = &zio->io_bp_orig;
1061 objset_t *os = arg;
1062
1063 if (zio->io_flags & ZIO_FLAG_IO_REWRITE) {
1064 ASSERT(BP_EQUAL(bp, bp_orig));
1065 } else {
1066 dsl_dataset_t *ds = os->os_dsl_dataset;
1067 dmu_tx_t *tx = os->os_synctx;
1068
1069 (void) dsl_dataset_block_kill(ds, bp_orig, tx, B_TRUE);
1070 dsl_dataset_block_born(ds, bp, tx);
1071 }
1072 }
1073
1074 /* called from dsl */
1075 void
1076 dmu_objset_sync(objset_t *os, zio_t *pio, dmu_tx_t *tx)
1077 {
1078 int txgoff;
1079 zbookmark_phys_t zb;
1080 zio_prop_t zp;
1081 zio_t *zio;
1082 list_t *list;
1083 list_t *newlist = NULL;
1084 dbuf_dirty_record_t *dr;
1085
1086 dprintf_ds(os->os_dsl_dataset, "txg=%llu\n", tx->tx_txg);
1087
1088 ASSERT(dmu_tx_is_syncing(tx));
1089 /* XXX the write_done callback should really give us the tx... */
1090 os->os_synctx = tx;
1091
1092 if (os->os_dsl_dataset == NULL) {
1093 /*
1094 * This is the MOS. If we have upgraded,
1095 * spa_max_replication() could change, so reset
1096 * os_copies here.
1097 */
1098 os->os_copies = spa_max_replication(os->os_spa);
1099 }
1100
1101 /*
1102 * Create the root block IO
1103 */
1104 SET_BOOKMARK(&zb, os->os_dsl_dataset ?
1105 os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
1106 ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
1107 arc_release(os->os_phys_buf, &os->os_phys_buf);
1108
1109 dmu_write_policy(os, NULL, 0, 0, &zp);
1110
1111 zio = arc_write(pio, os->os_spa, tx->tx_txg,
1112 os->os_rootbp, os->os_phys_buf, DMU_OS_IS_L2CACHEABLE(os),
1113 DMU_OS_IS_L2COMPRESSIBLE(os), &zp, dmu_objset_write_ready,
1114 NULL, dmu_objset_write_done, os, ZIO_PRIORITY_ASYNC_WRITE,
1115 ZIO_FLAG_MUSTSUCCEED, &zb);
1116
1117 /*
1118 * Sync special dnodes - the parent IO for the sync is the root block
1119 */
1120 DMU_META_DNODE(os)->dn_zio = zio;
1121 dnode_sync(DMU_META_DNODE(os), tx);
1122
1123 os->os_phys->os_flags = os->os_flags;
1124
1125 if (DMU_USERUSED_DNODE(os) &&
1126 DMU_USERUSED_DNODE(os)->dn_type != DMU_OT_NONE) {
1127 DMU_USERUSED_DNODE(os)->dn_zio = zio;
1128 dnode_sync(DMU_USERUSED_DNODE(os), tx);
1129 DMU_GROUPUSED_DNODE(os)->dn_zio = zio;
1130 dnode_sync(DMU_GROUPUSED_DNODE(os), tx);
1131 }
1132
1133 txgoff = tx->tx_txg & TXG_MASK;
1134
1135 if (dmu_objset_userused_enabled(os)) {
1136 newlist = &os->os_synced_dnodes;
1137 /*
1138 * We must create the list here because it uses the
1139 * dn_dirty_link[] of this txg.
1140 */
1141 list_create(newlist, sizeof (dnode_t),
1142 offsetof(dnode_t, dn_dirty_link[txgoff]));
1143 }
1144
1145 dmu_objset_sync_dnodes(&os->os_free_dnodes[txgoff], newlist, tx);
1146 dmu_objset_sync_dnodes(&os->os_dirty_dnodes[txgoff], newlist, tx);
1147
1148 list = &DMU_META_DNODE(os)->dn_dirty_records[txgoff];
1149 while ((dr = list_head(list))) {
1150 ASSERT0(dr->dr_dbuf->db_level);
1151 list_remove(list, dr);
1152 if (dr->dr_zio)
1153 zio_nowait(dr->dr_zio);
1154 }
1155 /*
1156 * Free intent log blocks up to this tx.
1157 */
1158 zil_sync(os->os_zil, tx);
1159 os->os_phys->os_zil_header = os->os_zil_header;
1160 zio_nowait(zio);
1161 }
1162
1163 boolean_t
1164 dmu_objset_is_dirty(objset_t *os, uint64_t txg)
1165 {
1166 return (!list_is_empty(&os->os_dirty_dnodes[txg & TXG_MASK]) ||
1167 !list_is_empty(&os->os_free_dnodes[txg & TXG_MASK]));
1168 }
1169
1170 static objset_used_cb_t *used_cbs[DMU_OST_NUMTYPES];
1171
1172 void
1173 dmu_objset_register_type(dmu_objset_type_t ost, objset_used_cb_t *cb)
1174 {
1175 used_cbs[ost] = cb;
1176 }
1177
1178 boolean_t
1179 dmu_objset_userused_enabled(objset_t *os)
1180 {
1181 return (spa_version(os->os_spa) >= SPA_VERSION_USERSPACE &&
1182 used_cbs[os->os_phys->os_type] != NULL &&
1183 DMU_USERUSED_DNODE(os) != NULL);
1184 }
1185
1186 static void
1187 do_userquota_update(objset_t *os, uint64_t used, uint64_t flags,
1188 uint64_t user, uint64_t group, boolean_t subtract, dmu_tx_t *tx)
1189 {
1190 if ((flags & DNODE_FLAG_USERUSED_ACCOUNTED)) {
1191 int64_t delta = DNODE_SIZE + used;
1192 if (subtract)
1193 delta = -delta;
1194 VERIFY3U(0, ==, zap_increment_int(os, DMU_USERUSED_OBJECT,
1195 user, delta, tx));
1196 VERIFY3U(0, ==, zap_increment_int(os, DMU_GROUPUSED_OBJECT,
1197 group, delta, tx));
1198 }
1199 }
1200
1201 void
1202 dmu_objset_do_userquota_updates(objset_t *os, dmu_tx_t *tx)
1203 {
1204 dnode_t *dn;
1205 list_t *list = &os->os_synced_dnodes;
1206
1207 ASSERT(list_head(list) == NULL || dmu_objset_userused_enabled(os));
1208
1209 while ((dn = list_head(list))) {
1210 int flags;
1211 ASSERT(!DMU_OBJECT_IS_SPECIAL(dn->dn_object));
1212 ASSERT(dn->dn_phys->dn_type == DMU_OT_NONE ||
1213 dn->dn_phys->dn_flags &
1214 DNODE_FLAG_USERUSED_ACCOUNTED);
1215
1216 /* Allocate the user/groupused objects if necessary. */
1217 if (DMU_USERUSED_DNODE(os)->dn_type == DMU_OT_NONE) {
1218 VERIFY(0 == zap_create_claim(os,
1219 DMU_USERUSED_OBJECT,
1220 DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx));
1221 VERIFY(0 == zap_create_claim(os,
1222 DMU_GROUPUSED_OBJECT,
1223 DMU_OT_USERGROUP_USED, DMU_OT_NONE, 0, tx));
1224 }
1225
1226 /*
1227 * We intentionally modify the zap object even if the
1228 * net delta is zero. Otherwise
1229 * the block of the zap obj could be shared between
1230 * datasets but need to be different between them after
1231 * a bprewrite.
1232 */
1233
1234 flags = dn->dn_id_flags;
1235 ASSERT(flags);
1236 if (flags & DN_ID_OLD_EXIST) {
1237 do_userquota_update(os, dn->dn_oldused, dn->dn_oldflags,
1238 dn->dn_olduid, dn->dn_oldgid, B_TRUE, tx);
1239 }
1240 if (flags & DN_ID_NEW_EXIST) {
1241 do_userquota_update(os, DN_USED_BYTES(dn->dn_phys),
1242 dn->dn_phys->dn_flags, dn->dn_newuid,
1243 dn->dn_newgid, B_FALSE, tx);
1244 }
1245
1246 mutex_enter(&dn->dn_mtx);
1247 dn->dn_oldused = 0;
1248 dn->dn_oldflags = 0;
1249 if (dn->dn_id_flags & DN_ID_NEW_EXIST) {
1250 dn->dn_olduid = dn->dn_newuid;
1251 dn->dn_oldgid = dn->dn_newgid;
1252 dn->dn_id_flags |= DN_ID_OLD_EXIST;
1253 if (dn->dn_bonuslen == 0)
1254 dn->dn_id_flags |= DN_ID_CHKED_SPILL;
1255 else
1256 dn->dn_id_flags |= DN_ID_CHKED_BONUS;
1257 }
1258 dn->dn_id_flags &= ~(DN_ID_NEW_EXIST);
1259 mutex_exit(&dn->dn_mtx);
1260
1261 list_remove(list, dn);
1262 dnode_rele(dn, list);
1263 }
1264 }
1265
1266 /*
1267 * Returns a pointer to data to find uid/gid from
1268 *
1269 * If a dirty record for transaction group that is syncing can't
1270 * be found then NULL is returned. In the NULL case it is assumed
1271 * the uid/gid aren't changing.
1272 */
1273 static void *
1274 dmu_objset_userquota_find_data(dmu_buf_impl_t *db, dmu_tx_t *tx)
1275 {
1276 dbuf_dirty_record_t *dr, **drp;
1277 void *data;
1278
1279 if (db->db_dirtycnt == 0)
1280 return (db->db.db_data); /* Nothing is changing */
1281
1282 for (drp = &db->db_last_dirty; (dr = *drp) != NULL; drp = &dr->dr_next)
1283 if (dr->dr_txg == tx->tx_txg)
1284 break;
1285
1286 if (dr == NULL) {
1287 data = NULL;
1288 } else {
1289 dnode_t *dn;
1290
1291 DB_DNODE_ENTER(dr->dr_dbuf);
1292 dn = DB_DNODE(dr->dr_dbuf);
1293
1294 if (dn->dn_bonuslen == 0 &&
1295 dr->dr_dbuf->db_blkid == DMU_SPILL_BLKID)
1296 data = dr->dt.dl.dr_data->b_data;
1297 else
1298 data = dr->dt.dl.dr_data;
1299
1300 DB_DNODE_EXIT(dr->dr_dbuf);
1301 }
1302
1303 return (data);
1304 }
1305
1306 void
1307 dmu_objset_userquota_get_ids(dnode_t *dn, boolean_t before, dmu_tx_t *tx)
1308 {
1309 objset_t *os = dn->dn_objset;
1310 void *data = NULL;
1311 dmu_buf_impl_t *db = NULL;
1312 uint64_t *user = NULL;
1313 uint64_t *group = NULL;
1314 int flags = dn->dn_id_flags;
1315 int error;
1316 boolean_t have_spill = B_FALSE;
1317 boolean_t have_bonus = B_FALSE;
1318
1319 if (!dmu_objset_userused_enabled(dn->dn_objset))
1320 return;
1321
1322 if (before && (flags & (DN_ID_CHKED_BONUS|DN_ID_OLD_EXIST|
1323 DN_ID_CHKED_SPILL)))
1324 return;
1325
1326 if (before && dn->dn_bonuslen != 0)
1327 data = DN_BONUS(dn->dn_phys);
1328 else if (!before && dn->dn_bonuslen != 0) {
1329 db = dn->dn_bonus;
1330 if (db != NULL) {
1331 if (!RW_WRITE_HELD(&dn->dn_struct_rwlock)) {
1332 have_bonus = dbuf_try_add_ref((dmu_buf_t *)db,
1333 dn->dn_objset, dn->dn_object,
1334 DMU_BONUS_BLKID, FTAG);
1335
1336 /*
1337 * The hold will fail if the buffer is
1338 * being evicted due to unlink, in which
1339 * case nothing needs to be done.
1340 */
1341 if (!have_bonus)
1342 return;
1343 }
1344 mutex_enter(&db->db_mtx);
1345 data = dmu_objset_userquota_find_data(db, tx);
1346 } else {
1347 data = DN_BONUS(dn->dn_phys);
1348 }
1349 } else if (dn->dn_bonuslen == 0 && dn->dn_bonustype == DMU_OT_SA) {
1350 int rf = 0;
1351
1352 if (RW_WRITE_HELD(&dn->dn_struct_rwlock))
1353 rf |= DB_RF_HAVESTRUCT;
1354 error = dmu_spill_hold_by_dnode(dn,
1355 rf | DB_RF_MUST_SUCCEED,
1356 FTAG, (dmu_buf_t **)&db);
1357 ASSERT(error == 0);
1358 mutex_enter(&db->db_mtx);
1359 data = (before) ? db->db.db_data :
1360 dmu_objset_userquota_find_data(db, tx);
1361 have_spill = B_TRUE;
1362 } else {
1363 mutex_enter(&dn->dn_mtx);
1364 dn->dn_id_flags |= DN_ID_CHKED_BONUS;
1365 mutex_exit(&dn->dn_mtx);
1366 return;
1367 }
1368
1369 if (before) {
1370 ASSERT(data);
1371 user = &dn->dn_olduid;
1372 group = &dn->dn_oldgid;
1373 } else if (data) {
1374 user = &dn->dn_newuid;
1375 group = &dn->dn_newgid;
1376 }
1377
1378 /*
1379 * Must always call the callback in case the object
1380 * type has changed and that type isn't an object type to track
1381 */
1382 error = used_cbs[os->os_phys->os_type](dn->dn_bonustype, data,
1383 user, group);
1384
1385 /*
1386 * Preserve existing uid/gid when the callback can't determine
1387 * what the new uid/gid are and the callback returned EEXIST.
1388 * The EEXIST error tells us to just use the existing uid/gid.
1389 * If we don't know what the old values are then just assign
1390 * them to 0, since that is a new file being created.
1391 */
1392 if (!before && data == NULL && error == EEXIST) {
1393 if (flags & DN_ID_OLD_EXIST) {
1394 dn->dn_newuid = dn->dn_olduid;
1395 dn->dn_newgid = dn->dn_oldgid;
1396 } else {
1397 dn->dn_newuid = 0;
1398 dn->dn_newgid = 0;
1399 }
1400 error = 0;
1401 }
1402
1403 if (db)
1404 mutex_exit(&db->db_mtx);
1405
1406 mutex_enter(&dn->dn_mtx);
1407 if (error == 0 && before)
1408 dn->dn_id_flags |= DN_ID_OLD_EXIST;
1409 if (error == 0 && !before)
1410 dn->dn_id_flags |= DN_ID_NEW_EXIST;
1411
1412 if (have_spill) {
1413 dn->dn_id_flags |= DN_ID_CHKED_SPILL;
1414 } else {
1415 dn->dn_id_flags |= DN_ID_CHKED_BONUS;
1416 }
1417 mutex_exit(&dn->dn_mtx);
1418 if (have_spill || have_bonus)
1419 dmu_buf_rele((dmu_buf_t *)db, FTAG);
1420 }
1421
1422 boolean_t
1423 dmu_objset_userspace_present(objset_t *os)
1424 {
1425 return (os->os_phys->os_flags &
1426 OBJSET_FLAG_USERACCOUNTING_COMPLETE);
1427 }
1428
1429 int
1430 dmu_objset_userspace_upgrade(objset_t *os)
1431 {
1432 uint64_t obj;
1433 int err = 0;
1434
1435 if (dmu_objset_userspace_present(os))
1436 return (0);
1437 if (!dmu_objset_userused_enabled(os))
1438 return (SET_ERROR(ENOTSUP));
1439 if (dmu_objset_is_snapshot(os))
1440 return (SET_ERROR(EINVAL));
1441
1442 /*
1443 * We simply need to mark every object dirty, so that it will be
1444 * synced out and now accounted. If this is called
1445 * concurrently, or if we already did some work before crashing,
1446 * that's fine, since we track each object's accounted state
1447 * independently.
1448 */
1449
1450 for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE, 0)) {
1451 dmu_tx_t *tx;
1452 dmu_buf_t *db;
1453 int objerr;
1454
1455 if (issig(JUSTLOOKING) && issig(FORREAL))
1456 return (SET_ERROR(EINTR));
1457
1458 objerr = dmu_bonus_hold(os, obj, FTAG, &db);
1459 if (objerr != 0)
1460 continue;
1461 tx = dmu_tx_create(os);
1462 dmu_tx_hold_bonus(tx, obj);
1463 objerr = dmu_tx_assign(tx, TXG_WAIT);
1464 if (objerr != 0) {
1465 dmu_tx_abort(tx);
1466 continue;
1467 }
1468 dmu_buf_will_dirty(db, tx);
1469 dmu_buf_rele(db, FTAG);
1470 dmu_tx_commit(tx);
1471 }
1472
1473 os->os_flags |= OBJSET_FLAG_USERACCOUNTING_COMPLETE;
1474 txg_wait_synced(dmu_objset_pool(os), 0);
1475 return (0);
1476 }
1477
1478 void
1479 dmu_objset_space(objset_t *os, uint64_t *refdbytesp, uint64_t *availbytesp,
1480 uint64_t *usedobjsp, uint64_t *availobjsp)
1481 {
1482 dsl_dataset_space(os->os_dsl_dataset, refdbytesp, availbytesp,
1483 usedobjsp, availobjsp);
1484 }
1485
1486 uint64_t
1487 dmu_objset_fsid_guid(objset_t *os)
1488 {
1489 return (dsl_dataset_fsid_guid(os->os_dsl_dataset));
1490 }
1491
1492 void
1493 dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat)
1494 {
1495 stat->dds_type = os->os_phys->os_type;
1496 if (os->os_dsl_dataset)
1497 dsl_dataset_fast_stat(os->os_dsl_dataset, stat);
1498 }
1499
1500 void
1501 dmu_objset_stats(objset_t *os, nvlist_t *nv)
1502 {
1503 ASSERT(os->os_dsl_dataset ||
1504 os->os_phys->os_type == DMU_OST_META);
1505
1506 if (os->os_dsl_dataset != NULL)
1507 dsl_dataset_stats(os->os_dsl_dataset, nv);
1508
1509 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_TYPE,
1510 os->os_phys->os_type);
1511 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USERACCOUNTING,
1512 dmu_objset_userspace_present(os));
1513 }
1514
1515 int
1516 dmu_objset_is_snapshot(objset_t *os)
1517 {
1518 if (os->os_dsl_dataset != NULL)
1519 return (os->os_dsl_dataset->ds_is_snapshot);
1520 else
1521 return (B_FALSE);
1522 }
1523
1524 int
1525 dmu_snapshot_realname(objset_t *os, char *name, char *real, int maxlen,
1526 boolean_t *conflict)
1527 {
1528 dsl_dataset_t *ds = os->os_dsl_dataset;
1529 uint64_t ignored;
1530
1531 if (dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0)
1532 return (SET_ERROR(ENOENT));
1533
1534 return (zap_lookup_norm(ds->ds_dir->dd_pool->dp_meta_objset,
1535 dsl_dataset_phys(ds)->ds_snapnames_zapobj, name, 8, 1, &ignored,
1536 MT_FIRST, real, maxlen, conflict));
1537 }
1538
1539 int
1540 dmu_snapshot_list_next(objset_t *os, int namelen, char *name,
1541 uint64_t *idp, uint64_t *offp, boolean_t *case_conflict)
1542 {
1543 dsl_dataset_t *ds = os->os_dsl_dataset;
1544 zap_cursor_t cursor;
1545 zap_attribute_t attr;
1546
1547 ASSERT(dsl_pool_config_held(dmu_objset_pool(os)));
1548
1549 if (dsl_dataset_phys(ds)->ds_snapnames_zapobj == 0)
1550 return (SET_ERROR(ENOENT));
1551
1552 zap_cursor_init_serialized(&cursor,
1553 ds->ds_dir->dd_pool->dp_meta_objset,
1554 dsl_dataset_phys(ds)->ds_snapnames_zapobj, *offp);
1555
1556 if (zap_cursor_retrieve(&cursor, &attr) != 0) {
1557 zap_cursor_fini(&cursor);
1558 return (SET_ERROR(ENOENT));
1559 }
1560
1561 if (strlen(attr.za_name) + 1 > namelen) {
1562 zap_cursor_fini(&cursor);
1563 return (SET_ERROR(ENAMETOOLONG));
1564 }
1565
1566 (void) strcpy(name, attr.za_name);
1567 if (idp)
1568 *idp = attr.za_first_integer;
1569 if (case_conflict)
1570 *case_conflict = attr.za_normalization_conflict;
1571 zap_cursor_advance(&cursor);
1572 *offp = zap_cursor_serialize(&cursor);
1573 zap_cursor_fini(&cursor);
1574
1575 return (0);
1576 }
1577
1578 int
1579 dmu_snapshot_lookup(objset_t *os, const char *name, uint64_t *value)
1580 {
1581 return (dsl_dataset_snap_lookup(os->os_dsl_dataset, name, value));
1582 }
1583
1584 int
1585 dmu_dir_list_next(objset_t *os, int namelen, char *name,
1586 uint64_t *idp, uint64_t *offp)
1587 {
1588 dsl_dir_t *dd = os->os_dsl_dataset->ds_dir;
1589 zap_cursor_t cursor;
1590 zap_attribute_t attr;
1591
1592 /* there is no next dir on a snapshot! */
1593 if (os->os_dsl_dataset->ds_object !=
1594 dsl_dir_phys(dd)->dd_head_dataset_obj)
1595 return (SET_ERROR(ENOENT));
1596
1597 zap_cursor_init_serialized(&cursor,
1598 dd->dd_pool->dp_meta_objset,
1599 dsl_dir_phys(dd)->dd_child_dir_zapobj, *offp);
1600
1601 if (zap_cursor_retrieve(&cursor, &attr) != 0) {
1602 zap_cursor_fini(&cursor);
1603 return (SET_ERROR(ENOENT));
1604 }
1605
1606 if (strlen(attr.za_name) + 1 > namelen) {
1607 zap_cursor_fini(&cursor);
1608 return (SET_ERROR(ENAMETOOLONG));
1609 }
1610
1611 (void) strcpy(name, attr.za_name);
1612 if (idp)
1613 *idp = attr.za_first_integer;
1614 zap_cursor_advance(&cursor);
1615 *offp = zap_cursor_serialize(&cursor);
1616 zap_cursor_fini(&cursor);
1617
1618 return (0);
1619 }
1620
1621 /*
1622 * Find objsets under and including ddobj, call func(ds) on each.
1623 */
1624 int
1625 dmu_objset_find_dp(dsl_pool_t *dp, uint64_t ddobj,
1626 int func(dsl_pool_t *, dsl_dataset_t *, void *), void *arg, int flags)
1627 {
1628 dsl_dir_t *dd;
1629 dsl_dataset_t *ds;
1630 zap_cursor_t zc;
1631 zap_attribute_t *attr;
1632 uint64_t thisobj;
1633 int err;
1634
1635 ASSERT(dsl_pool_config_held(dp));
1636
1637 err = dsl_dir_hold_obj(dp, ddobj, NULL, FTAG, &dd);
1638 if (err != 0)
1639 return (err);
1640
1641 /* Don't visit hidden ($MOS & $ORIGIN) objsets. */
1642 if (dd->dd_myname[0] == '$') {
1643 dsl_dir_rele(dd, FTAG);
1644 return (0);
1645 }
1646
1647 thisobj = dsl_dir_phys(dd)->dd_head_dataset_obj;
1648 attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
1649
1650 /*
1651 * Iterate over all children.
1652 */
1653 if (flags & DS_FIND_CHILDREN) {
1654 for (zap_cursor_init(&zc, dp->dp_meta_objset,
1655 dsl_dir_phys(dd)->dd_child_dir_zapobj);
1656 zap_cursor_retrieve(&zc, attr) == 0;
1657 (void) zap_cursor_advance(&zc)) {
1658 ASSERT3U(attr->za_integer_length, ==,
1659 sizeof (uint64_t));
1660 ASSERT3U(attr->za_num_integers, ==, 1);
1661
1662 err = dmu_objset_find_dp(dp, attr->za_first_integer,
1663 func, arg, flags);
1664 if (err != 0)
1665 break;
1666 }
1667 zap_cursor_fini(&zc);
1668
1669 if (err != 0) {
1670 dsl_dir_rele(dd, FTAG);
1671 kmem_free(attr, sizeof (zap_attribute_t));
1672 return (err);
1673 }
1674 }
1675
1676 /*
1677 * Iterate over all snapshots.
1678 */
1679 if (flags & DS_FIND_SNAPSHOTS) {
1680 dsl_dataset_t *ds;
1681 err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
1682
1683 if (err == 0) {
1684 uint64_t snapobj;
1685
1686 snapobj = dsl_dataset_phys(ds)->ds_snapnames_zapobj;
1687 dsl_dataset_rele(ds, FTAG);
1688
1689 for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj);
1690 zap_cursor_retrieve(&zc, attr) == 0;
1691 (void) zap_cursor_advance(&zc)) {
1692 ASSERT3U(attr->za_integer_length, ==,
1693 sizeof (uint64_t));
1694 ASSERT3U(attr->za_num_integers, ==, 1);
1695
1696 err = dsl_dataset_hold_obj(dp,
1697 attr->za_first_integer, FTAG, &ds);
1698 if (err != 0)
1699 break;
1700 err = func(dp, ds, arg);
1701 dsl_dataset_rele(ds, FTAG);
1702 if (err != 0)
1703 break;
1704 }
1705 zap_cursor_fini(&zc);
1706 }
1707 }
1708
1709 dsl_dir_rele(dd, FTAG);
1710 kmem_free(attr, sizeof (zap_attribute_t));
1711
1712 if (err != 0)
1713 return (err);
1714
1715 /*
1716 * Apply to self.
1717 */
1718 err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
1719 if (err != 0)
1720 return (err);
1721 err = func(dp, ds, arg);
1722 dsl_dataset_rele(ds, FTAG);
1723 return (err);
1724 }
1725
1726 /*
1727 * Find all objsets under name, and for each, call 'func(child_name, arg)'.
1728 * The dp_config_rwlock must not be held when this is called, and it
1729 * will not be held when the callback is called.
1730 * Therefore this function should only be used when the pool is not changing
1731 * (e.g. in syncing context), or the callback can deal with the possible races.
1732 */
1733 static int
1734 dmu_objset_find_impl(spa_t *spa, const char *name,
1735 int func(const char *, void *), void *arg, int flags)
1736 {
1737 dsl_dir_t *dd;
1738 dsl_pool_t *dp = spa_get_dsl(spa);
1739 dsl_dataset_t *ds;
1740 zap_cursor_t zc;
1741 zap_attribute_t *attr;
1742 char *child;
1743 uint64_t thisobj;
1744 int err;
1745
1746 dsl_pool_config_enter(dp, FTAG);
1747
1748 err = dsl_dir_hold(dp, name, FTAG, &dd, NULL);
1749 if (err != 0) {
1750 dsl_pool_config_exit(dp, FTAG);
1751 return (err);
1752 }
1753
1754 /* Don't visit hidden ($MOS & $ORIGIN) objsets. */
1755 if (dd->dd_myname[0] == '$') {
1756 dsl_dir_rele(dd, FTAG);
1757 dsl_pool_config_exit(dp, FTAG);
1758 return (0);
1759 }
1760
1761 thisobj = dsl_dir_phys(dd)->dd_head_dataset_obj;
1762 attr = kmem_alloc(sizeof (zap_attribute_t), KM_SLEEP);
1763
1764 /*
1765 * Iterate over all children.
1766 */
1767 if (flags & DS_FIND_CHILDREN) {
1768 for (zap_cursor_init(&zc, dp->dp_meta_objset,
1769 dsl_dir_phys(dd)->dd_child_dir_zapobj);
1770 zap_cursor_retrieve(&zc, attr) == 0;
1771 (void) zap_cursor_advance(&zc)) {
1772 ASSERT3U(attr->za_integer_length, ==,
1773 sizeof (uint64_t));
1774 ASSERT3U(attr->za_num_integers, ==, 1);
1775
1776 child = kmem_asprintf("%s/%s", name, attr->za_name);
1777 dsl_pool_config_exit(dp, FTAG);
1778 err = dmu_objset_find_impl(spa, child,
1779 func, arg, flags);
1780 dsl_pool_config_enter(dp, FTAG);
1781 strfree(child);
1782 if (err != 0)
1783 break;
1784 }
1785 zap_cursor_fini(&zc);
1786
1787 if (err != 0) {
1788 dsl_dir_rele(dd, FTAG);
1789 dsl_pool_config_exit(dp, FTAG);
1790 kmem_free(attr, sizeof (zap_attribute_t));
1791 return (err);
1792 }
1793 }
1794
1795 /*
1796 * Iterate over all snapshots.
1797 */
1798 if (flags & DS_FIND_SNAPSHOTS) {
1799 err = dsl_dataset_hold_obj(dp, thisobj, FTAG, &ds);
1800
1801 if (err == 0) {
1802 uint64_t snapobj;
1803
1804 snapobj = dsl_dataset_phys(ds)->ds_snapnames_zapobj;
1805 dsl_dataset_rele(ds, FTAG);
1806
1807 for (zap_cursor_init(&zc, dp->dp_meta_objset, snapobj);
1808 zap_cursor_retrieve(&zc, attr) == 0;
1809 (void) zap_cursor_advance(&zc)) {
1810 ASSERT3U(attr->za_integer_length, ==,
1811 sizeof (uint64_t));
1812 ASSERT3U(attr->za_num_integers, ==, 1);
1813
1814 child = kmem_asprintf("%s@%s",
1815 name, attr->za_name);
1816 dsl_pool_config_exit(dp, FTAG);
1817 err = func(child, arg);
1818 dsl_pool_config_enter(dp, FTAG);
1819 strfree(child);
1820 if (err != 0)
1821 break;
1822 }
1823 zap_cursor_fini(&zc);
1824 }
1825 }
1826
1827 dsl_dir_rele(dd, FTAG);
1828 kmem_free(attr, sizeof (zap_attribute_t));
1829 dsl_pool_config_exit(dp, FTAG);
1830
1831 if (err != 0)
1832 return (err);
1833
1834 /* Apply to self. */
1835 return (func(name, arg));
1836 }
1837
1838 /*
1839 * See comment above dmu_objset_find_impl().
1840 */
1841 int
1842 dmu_objset_find(char *name, int func(const char *, void *), void *arg,
1843 int flags)
1844 {
1845 spa_t *spa;
1846 int error;
1847
1848 error = spa_open(name, &spa, FTAG);
1849 if (error != 0)
1850 return (error);
1851 error = dmu_objset_find_impl(spa, name, func, arg, flags);
1852 spa_close(spa, FTAG);
1853 return (error);
1854 }
1855
1856 void
1857 dmu_objset_set_user(objset_t *os, void *user_ptr)
1858 {
1859 ASSERT(MUTEX_HELD(&os->os_user_ptr_lock));
1860 os->os_user_ptr = user_ptr;
1861 }
1862
1863 void *
1864 dmu_objset_get_user(objset_t *os)
1865 {
1866 ASSERT(MUTEX_HELD(&os->os_user_ptr_lock));
1867 return (os->os_user_ptr);
1868 }
1869
1870 /*
1871 * Determine name of filesystem, given name of snapshot.
1872 * buf must be at least MAXNAMELEN bytes
1873 */
1874 int
1875 dmu_fsname(const char *snapname, char *buf)
1876 {
1877 char *atp = strchr(snapname, '@');
1878 if (atp == NULL)
1879 return (SET_ERROR(EINVAL));
1880 if (atp - snapname >= MAXNAMELEN)
1881 return (SET_ERROR(ENAMETOOLONG));
1882 (void) strlcpy(buf, snapname, atp - snapname + 1);
1883 return (0);
1884 }
1885
1886 #if defined(_KERNEL) && defined(HAVE_SPL)
1887 EXPORT_SYMBOL(dmu_objset_zil);
1888 EXPORT_SYMBOL(dmu_objset_pool);
1889 EXPORT_SYMBOL(dmu_objset_ds);
1890 EXPORT_SYMBOL(dmu_objset_type);
1891 EXPORT_SYMBOL(dmu_objset_name);
1892 EXPORT_SYMBOL(dmu_objset_hold);
1893 EXPORT_SYMBOL(dmu_objset_own);
1894 EXPORT_SYMBOL(dmu_objset_rele);
1895 EXPORT_SYMBOL(dmu_objset_disown);
1896 EXPORT_SYMBOL(dmu_objset_from_ds);
1897 EXPORT_SYMBOL(dmu_objset_create);
1898 EXPORT_SYMBOL(dmu_objset_clone);
1899 EXPORT_SYMBOL(dmu_objset_stats);
1900 EXPORT_SYMBOL(dmu_objset_fast_stat);
1901 EXPORT_SYMBOL(dmu_objset_spa);
1902 EXPORT_SYMBOL(dmu_objset_space);
1903 EXPORT_SYMBOL(dmu_objset_fsid_guid);
1904 EXPORT_SYMBOL(dmu_objset_find);
1905 EXPORT_SYMBOL(dmu_objset_byteswap);
1906 EXPORT_SYMBOL(dmu_objset_evict_dbufs);
1907 EXPORT_SYMBOL(dmu_objset_snap_cmtime);
1908
1909 EXPORT_SYMBOL(dmu_objset_sync);
1910 EXPORT_SYMBOL(dmu_objset_is_dirty);
1911 EXPORT_SYMBOL(dmu_objset_create_impl);
1912 EXPORT_SYMBOL(dmu_objset_open_impl);
1913 EXPORT_SYMBOL(dmu_objset_evict);
1914 EXPORT_SYMBOL(dmu_objset_register_type);
1915 EXPORT_SYMBOL(dmu_objset_do_userquota_updates);
1916 EXPORT_SYMBOL(dmu_objset_userquota_get_ids);
1917 EXPORT_SYMBOL(dmu_objset_userused_enabled);
1918 EXPORT_SYMBOL(dmu_objset_userspace_upgrade);
1919 EXPORT_SYMBOL(dmu_objset_userspace_present);
1920 #endif