Deleted Added
full compact
dsl_dataset.c (286543) dsl_dataset.c (286575)
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

--- 10 unchanged lines hidden (view full) ---

19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Portions Copyright (c) 2011 Martin Matuska <mm@FreeBSD.org>
24 * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
25 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
26 * Copyright (c) 2014 RackTop Systems.
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

--- 10 unchanged lines hidden (view full) ---

19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Portions Copyright (c) 2011 Martin Matuska <mm@FreeBSD.org>
24 * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
25 * Copyright (c) 2014, Joyent, Inc. All rights reserved.
26 * Copyright (c) 2014 RackTop Systems.
27 * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
27 */
28
29#include <sys/dmu_objset.h>
30#include <sys/dsl_dataset.h>
31#include <sys/dsl_dir.h>
32#include <sys/dsl_prop.h>
33#include <sys/dsl_synctask.h>
34#include <sys/dmu_traverse.h>

--- 37 unchanged lines hidden (view full) ---

72 uint64_t __tmp = (x); \
73 (x) = (y); \
74 (y) = __tmp; \
75 }
76
77#define DS_REF_MAX (1ULL << 62)
78
79extern inline dsl_dataset_phys_t *dsl_dataset_phys(dsl_dataset_t *ds);
28 */
29
30#include <sys/dmu_objset.h>
31#include <sys/dsl_dataset.h>
32#include <sys/dsl_dir.h>
33#include <sys/dsl_prop.h>
34#include <sys/dsl_synctask.h>
35#include <sys/dmu_traverse.h>

--- 37 unchanged lines hidden (view full) ---

73 uint64_t __tmp = (x); \
74 (x) = (y); \
75 (y) = __tmp; \
76 }
77
78#define DS_REF_MAX (1ULL << 62)
79
80extern inline dsl_dataset_phys_t *dsl_dataset_phys(dsl_dataset_t *ds);
80extern inline boolean_t dsl_dataset_is_snapshot(dsl_dataset_t *ds);
81
82/*
83 * Figure out how much of this delta should be propogated to the dsl_dir
84 * layer. If there's a refreservation, that space has already been
85 * partially accounted for in our ancestors.
86 */
87static int64_t
88parent_delta(dsl_dataset_t *ds, int64_t delta)

--- 67 unchanged lines hidden (view full) ---

156 if (ds == NULL) {
157 dsl_free(tx->tx_pool, tx->tx_txg, bp);
158 dsl_pool_mos_diduse_space(tx->tx_pool,
159 -used, -compressed, -uncompressed);
160 return (used);
161 }
162 ASSERT3P(tx->tx_pool, ==, ds->ds_dir->dd_pool);
163
81
82/*
83 * Figure out how much of this delta should be propogated to the dsl_dir
84 * layer. If there's a refreservation, that space has already been
85 * partially accounted for in our ancestors.
86 */
87static int64_t
88parent_delta(dsl_dataset_t *ds, int64_t delta)

--- 67 unchanged lines hidden (view full) ---

156 if (ds == NULL) {
157 dsl_free(tx->tx_pool, tx->tx_txg, bp);
158 dsl_pool_mos_diduse_space(tx->tx_pool,
159 -used, -compressed, -uncompressed);
160 return (used);
161 }
162 ASSERT3P(tx->tx_pool, ==, ds->ds_dir->dd_pool);
163
164 ASSERT(!dsl_dataset_is_snapshot(ds));
164 ASSERT(!ds->ds_is_snapshot);
165 dmu_buf_will_dirty(ds->ds_dbuf, tx);
166
167 if (bp->blk_birth > dsl_dataset_phys(ds)->ds_prev_snap_txg) {
168 int64_t delta;
169
170 dprintf_bp(bp, "freeing ds=%llu", ds->ds_object);
171 dsl_free(tx->tx_pool, tx->tx_txg, bp);
172

--- 81 unchanged lines hidden (view full) ---

254 (bp != NULL && BP_IS_HOLE(bp)))
255 return (B_FALSE);
256
257 ddt_prefetch(dsl_dataset_get_spa(ds), bp);
258
259 return (B_TRUE);
260}
261
165 dmu_buf_will_dirty(ds->ds_dbuf, tx);
166
167 if (bp->blk_birth > dsl_dataset_phys(ds)->ds_prev_snap_txg) {
168 int64_t delta;
169
170 dprintf_bp(bp, "freeing ds=%llu", ds->ds_object);
171 dsl_free(tx->tx_pool, tx->tx_txg, bp);
172

--- 81 unchanged lines hidden (view full) ---

254 (bp != NULL && BP_IS_HOLE(bp)))
255 return (B_FALSE);
256
257 ddt_prefetch(dsl_dataset_get_spa(ds), bp);
258
259 return (B_TRUE);
260}
261
262/* ARGSUSED */
263static void
262static void
264dsl_dataset_evict(dmu_buf_t *db, void *dsv)
263dsl_dataset_evict(void *dbu)
265{
264{
266 dsl_dataset_t *ds = dsv;
265 dsl_dataset_t *ds = dbu;
267
268 ASSERT(ds->ds_owner == NULL);
269
266
267 ASSERT(ds->ds_owner == NULL);
268
269 ds->ds_dbuf = NULL;
270
270 unique_remove(ds->ds_fsid_guid);
271
272 if (ds->ds_objset != NULL)
273 dmu_objset_evict(ds->ds_objset);
274
275 if (ds->ds_prev) {
276 dsl_dataset_rele(ds->ds_prev, ds);
277 ds->ds_prev = NULL;
278 }
279
280 bplist_destroy(&ds->ds_pending_deadlist);
271 unique_remove(ds->ds_fsid_guid);
272
273 if (ds->ds_objset != NULL)
274 dmu_objset_evict(ds->ds_objset);
275
276 if (ds->ds_prev) {
277 dsl_dataset_rele(ds->ds_prev, ds);
278 ds->ds_prev = NULL;
279 }
280
281 bplist_destroy(&ds->ds_pending_deadlist);
281 if (dsl_dataset_phys(ds)->ds_deadlist_obj != 0)
282 if (ds->ds_deadlist.dl_os != NULL)
282 dsl_deadlist_close(&ds->ds_deadlist);
283 if (ds->ds_dir)
283 dsl_deadlist_close(&ds->ds_deadlist);
284 if (ds->ds_dir)
284 dsl_dir_rele(ds->ds_dir, ds);
285 dsl_dir_async_rele(ds->ds_dir, ds);
285
286 ASSERT(!list_link_active(&ds->ds_synced_link));
287
288 if (mutex_owned(&ds->ds_lock))
289 mutex_exit(&ds->ds_lock);
290 mutex_destroy(&ds->ds_lock);
291 if (mutex_owned(&ds->ds_opening_lock))
292 mutex_exit(&ds->ds_opening_lock);

--- 119 unchanged lines hidden (view full) ---

412
413 ds = dmu_buf_get_user(dbuf);
414 if (ds == NULL) {
415 dsl_dataset_t *winner = NULL;
416
417 ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP);
418 ds->ds_dbuf = dbuf;
419 ds->ds_object = dsobj;
286
287 ASSERT(!list_link_active(&ds->ds_synced_link));
288
289 if (mutex_owned(&ds->ds_lock))
290 mutex_exit(&ds->ds_lock);
291 mutex_destroy(&ds->ds_lock);
292 if (mutex_owned(&ds->ds_opening_lock))
293 mutex_exit(&ds->ds_opening_lock);

--- 119 unchanged lines hidden (view full) ---

413
414 ds = dmu_buf_get_user(dbuf);
415 if (ds == NULL) {
416 dsl_dataset_t *winner = NULL;
417
418 ds = kmem_zalloc(sizeof (dsl_dataset_t), KM_SLEEP);
419 ds->ds_dbuf = dbuf;
420 ds->ds_object = dsobj;
421 ds->ds_is_snapshot = dsl_dataset_phys(ds)->ds_num_children != 0;
420
421 mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL);
422 mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL);
423 mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL);
424 refcount_create(&ds->ds_longholds);
425
426 bplist_create(&ds->ds_pending_deadlist);
427 dsl_deadlist_open(&ds->ds_deadlist,

--- 23 unchanged lines hidden (view full) ---

451 refcount_destroy(&ds->ds_longholds);
452 bplist_destroy(&ds->ds_pending_deadlist);
453 dsl_deadlist_close(&ds->ds_deadlist);
454 kmem_free(ds, sizeof (dsl_dataset_t));
455 dmu_buf_rele(dbuf, tag);
456 return (err);
457 }
458
422
423 mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL);
424 mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL);
425 mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL);
426 refcount_create(&ds->ds_longholds);
427
428 bplist_create(&ds->ds_pending_deadlist);
429 dsl_deadlist_open(&ds->ds_deadlist,

--- 23 unchanged lines hidden (view full) ---

453 refcount_destroy(&ds->ds_longholds);
454 bplist_destroy(&ds->ds_pending_deadlist);
455 dsl_deadlist_close(&ds->ds_deadlist);
456 kmem_free(ds, sizeof (dsl_dataset_t));
457 dmu_buf_rele(dbuf, tag);
458 return (err);
459 }
460
459 if (!dsl_dataset_is_snapshot(ds)) {
461 if (!ds->ds_is_snapshot) {
460 ds->ds_snapname[0] = '\0';
461 if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
462 err = dsl_dataset_hold_obj(dp,
463 dsl_dataset_phys(ds)->ds_prev_snap_obj,
464 ds, &ds->ds_prev);
465 }
466 if (doi.doi_type == DMU_OTN_ZAP_METADATA) {
467 int zaperr = zap_lookup(mos, ds->ds_object,

--- 10 unchanged lines hidden (view full) ---

478 dsl_dataset_phys(ds)->ds_userrefs_obj != 0) {
479 err = zap_count(
480 ds->ds_dir->dd_pool->dp_meta_objset,
481 dsl_dataset_phys(ds)->ds_userrefs_obj,
482 &ds->ds_userrefs);
483 }
484 }
485
462 ds->ds_snapname[0] = '\0';
463 if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0) {
464 err = dsl_dataset_hold_obj(dp,
465 dsl_dataset_phys(ds)->ds_prev_snap_obj,
466 ds, &ds->ds_prev);
467 }
468 if (doi.doi_type == DMU_OTN_ZAP_METADATA) {
469 int zaperr = zap_lookup(mos, ds->ds_object,

--- 10 unchanged lines hidden (view full) ---

480 dsl_dataset_phys(ds)->ds_userrefs_obj != 0) {
481 err = zap_count(
482 ds->ds_dir->dd_pool->dp_meta_objset,
483 dsl_dataset_phys(ds)->ds_userrefs_obj,
484 &ds->ds_userrefs);
485 }
486 }
487
486 if (err == 0 && !dsl_dataset_is_snapshot(ds)) {
488 if (err == 0 && !ds->ds_is_snapshot) {
487 err = dsl_prop_get_int_ds(ds,
488 zfs_prop_to_name(ZFS_PROP_REFRESERVATION),
489 &ds->ds_reserved);
490 if (err == 0) {
491 err = dsl_prop_get_int_ds(ds,
492 zfs_prop_to_name(ZFS_PROP_REFQUOTA),
493 &ds->ds_quota);
494 }
495 } else {
496 ds->ds_reserved = ds->ds_quota = 0;
497 }
498
489 err = dsl_prop_get_int_ds(ds,
490 zfs_prop_to_name(ZFS_PROP_REFRESERVATION),
491 &ds->ds_reserved);
492 if (err == 0) {
493 err = dsl_prop_get_int_ds(ds,
494 zfs_prop_to_name(ZFS_PROP_REFQUOTA),
495 &ds->ds_quota);
496 }
497 } else {
498 ds->ds_reserved = ds->ds_quota = 0;
499 }
500
499 if (err != 0 || (winner = dmu_buf_set_user_ie(dbuf, ds,
500 dsl_dataset_evict)) != NULL) {
501 dmu_buf_init_user(&ds->ds_dbu, dsl_dataset_evict, &ds->ds_dbuf);
502 if (err == 0)
503 winner = dmu_buf_set_user_ie(dbuf, &ds->ds_dbu);
504
505 if (err != 0 || winner != NULL) {
501 bplist_destroy(&ds->ds_pending_deadlist);
502 dsl_deadlist_close(&ds->ds_deadlist);
503 if (ds->ds_prev)
504 dsl_dataset_rele(ds->ds_prev, ds);
505 dsl_dir_rele(ds->ds_dir, ds);
506 mutex_destroy(&ds->ds_lock);
507 mutex_destroy(&ds->ds_opening_lock);
508 mutex_destroy(&ds->ds_sendstream_lock);

--- 405 unchanged lines hidden (view full) ---

914 * has been freed up since the snapshot was taken.
915 */
916void
917dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds)
918{
919 uint64_t mrs_used;
920 uint64_t dlused, dlcomp, dluncomp;
921
506 bplist_destroy(&ds->ds_pending_deadlist);
507 dsl_deadlist_close(&ds->ds_deadlist);
508 if (ds->ds_prev)
509 dsl_dataset_rele(ds->ds_prev, ds);
510 dsl_dir_rele(ds->ds_dir, ds);
511 mutex_destroy(&ds->ds_lock);
512 mutex_destroy(&ds->ds_opening_lock);
513 mutex_destroy(&ds->ds_sendstream_lock);

--- 405 unchanged lines hidden (view full) ---

919 * has been freed up since the snapshot was taken.
920 */
921void
922dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds)
923{
924 uint64_t mrs_used;
925 uint64_t dlused, dlcomp, dluncomp;
926
922 ASSERT(!dsl_dataset_is_snapshot(ds));
927 ASSERT(!ds->ds_is_snapshot);
923
924 if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0)
925 mrs_used = dsl_dataset_phys(ds->ds_prev)->ds_referenced_bytes;
926 else
927 mrs_used = 0;
928
929 dsl_deadlist_space(&ds->ds_deadlist, &dlused, &dlcomp, &dluncomp);
930

--- 739 unchanged lines hidden (view full) ---

1670 ratio = dsl_dataset_phys(ds)->ds_compressed_bytes == 0 ? 100 :
1671 (dsl_dataset_phys(ds)->ds_uncompressed_bytes * 100 /
1672 dsl_dataset_phys(ds)->ds_compressed_bytes);
1673
1674 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO, ratio);
1675 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_LOGICALREFERENCED,
1676 dsl_dataset_phys(ds)->ds_uncompressed_bytes);
1677
928
929 if (dsl_dataset_phys(ds)->ds_prev_snap_obj != 0)
930 mrs_used = dsl_dataset_phys(ds->ds_prev)->ds_referenced_bytes;
931 else
932 mrs_used = 0;
933
934 dsl_deadlist_space(&ds->ds_deadlist, &dlused, &dlcomp, &dluncomp);
935

--- 739 unchanged lines hidden (view full) ---

1675 ratio = dsl_dataset_phys(ds)->ds_compressed_bytes == 0 ? 100 :
1676 (dsl_dataset_phys(ds)->ds_uncompressed_bytes * 100 /
1677 dsl_dataset_phys(ds)->ds_compressed_bytes);
1678
1679 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO, ratio);
1680 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_LOGICALREFERENCED,
1681 dsl_dataset_phys(ds)->ds_uncompressed_bytes);
1682
1678 if (dsl_dataset_is_snapshot(ds)) {
1683 if (ds->ds_is_snapshot) {
1679 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, ratio);
1680 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
1681 dsl_dataset_phys(ds)->ds_unique_bytes);
1682 get_clones_stat(ds, nv);
1683 } else {
1684 if (ds->ds_prev != NULL && ds->ds_prev != dp->dp_origin_snap) {
1685 char buf[MAXNAMELEN];
1686 dsl_dataset_name(ds->ds_prev, buf);

--- 51 unchanged lines hidden (view full) ---

1738 dsl_pool_t *dp = ds->ds_dir->dd_pool;
1739 ASSERT(dsl_pool_config_held(dp));
1740
1741 stat->dds_creation_txg = dsl_dataset_phys(ds)->ds_creation_txg;
1742 stat->dds_inconsistent =
1743 dsl_dataset_phys(ds)->ds_flags & DS_FLAG_INCONSISTENT;
1744 stat->dds_guid = dsl_dataset_phys(ds)->ds_guid;
1745 stat->dds_origin[0] = '\0';
1684 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, ratio);
1685 dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
1686 dsl_dataset_phys(ds)->ds_unique_bytes);
1687 get_clones_stat(ds, nv);
1688 } else {
1689 if (ds->ds_prev != NULL && ds->ds_prev != dp->dp_origin_snap) {
1690 char buf[MAXNAMELEN];
1691 dsl_dataset_name(ds->ds_prev, buf);

--- 51 unchanged lines hidden (view full) ---

1743 dsl_pool_t *dp = ds->ds_dir->dd_pool;
1744 ASSERT(dsl_pool_config_held(dp));
1745
1746 stat->dds_creation_txg = dsl_dataset_phys(ds)->ds_creation_txg;
1747 stat->dds_inconsistent =
1748 dsl_dataset_phys(ds)->ds_flags & DS_FLAG_INCONSISTENT;
1749 stat->dds_guid = dsl_dataset_phys(ds)->ds_guid;
1750 stat->dds_origin[0] = '\0';
1746 if (dsl_dataset_is_snapshot(ds)) {
1751 if (ds->ds_is_snapshot) {
1747 stat->dds_is_snapshot = B_TRUE;
1748 stat->dds_num_clones =
1749 dsl_dataset_phys(ds)->ds_num_children - 1;
1750 } else {
1751 stat->dds_is_snapshot = B_FALSE;
1752 stat->dds_num_clones = 0;
1753
1754 if (dsl_dir_is_clone(ds->ds_dir)) {

--- 263 unchanged lines hidden (view full) ---

2018 int64_t unused_refres_delta;
2019 int error;
2020
2021 error = dsl_dataset_hold(dp, ddra->ddra_fsname, FTAG, &ds);
2022 if (error != 0)
2023 return (error);
2024
2025 /* must not be a snapshot */
1752 stat->dds_is_snapshot = B_TRUE;
1753 stat->dds_num_clones =
1754 dsl_dataset_phys(ds)->ds_num_children - 1;
1755 } else {
1756 stat->dds_is_snapshot = B_FALSE;
1757 stat->dds_num_clones = 0;
1758
1759 if (dsl_dir_is_clone(ds->ds_dir)) {

--- 263 unchanged lines hidden (view full) ---

2023 int64_t unused_refres_delta;
2024 int error;
2025
2026 error = dsl_dataset_hold(dp, ddra->ddra_fsname, FTAG, &ds);
2027 if (error != 0)
2028 return (error);
2029
2030 /* must not be a snapshot */
2026 if (dsl_dataset_is_snapshot(ds)) {
2031 if (ds->ds_is_snapshot) {
2027 dsl_dataset_rele(ds, FTAG);
2028 return (SET_ERROR(EINVAL));
2029 }
2030
2031 /* must have a most recent snapshot */
2032 if (dsl_dataset_phys(ds)->ds_prev_snap_txg < TXG_INITIAL) {
2033 dsl_dataset_rele(ds, FTAG);
2034 return (SET_ERROR(EINVAL));

--- 584 unchanged lines hidden (view full) ---

2619 struct promotenode *snap;
2620
2621 error = dsl_dataset_hold(dp, ddpa->ddpa_clonename, tag,
2622 &ddpa->ddpa_clone);
2623 if (error != 0)
2624 return (error);
2625 dd = ddpa->ddpa_clone->ds_dir;
2626
2032 dsl_dataset_rele(ds, FTAG);
2033 return (SET_ERROR(EINVAL));
2034 }
2035
2036 /* must have a most recent snapshot */
2037 if (dsl_dataset_phys(ds)->ds_prev_snap_txg < TXG_INITIAL) {
2038 dsl_dataset_rele(ds, FTAG);
2039 return (SET_ERROR(EINVAL));

--- 584 unchanged lines hidden (view full) ---

2624 struct promotenode *snap;
2625
2626 error = dsl_dataset_hold(dp, ddpa->ddpa_clonename, tag,
2627 &ddpa->ddpa_clone);
2628 if (error != 0)
2629 return (error);
2630 dd = ddpa->ddpa_clone->ds_dir;
2631
2627 if (dsl_dataset_is_snapshot(ddpa->ddpa_clone) ||
2632 if (ddpa->ddpa_clone->ds_is_snapshot ||
2628 !dsl_dir_is_clone(dd)) {
2629 dsl_dataset_rele(ddpa->ddpa_clone, tag);
2630 return (SET_ERROR(EINVAL));
2631 }
2632
2633 error = snaplist_make(dp, 0, dsl_dir_phys(dd)->dd_origin_obj,
2634 &ddpa->shared_snaps, tag);
2635 if (error != 0)

--- 75 unchanged lines hidden (view full) ---

2711
2712int
2713dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
2714 dsl_dataset_t *origin_head, boolean_t force, void *owner, dmu_tx_t *tx)
2715{
2716 int64_t unused_refres_delta;
2717
2718 /* they should both be heads */
2633 !dsl_dir_is_clone(dd)) {
2634 dsl_dataset_rele(ddpa->ddpa_clone, tag);
2635 return (SET_ERROR(EINVAL));
2636 }
2637
2638 error = snaplist_make(dp, 0, dsl_dir_phys(dd)->dd_origin_obj,
2639 &ddpa->shared_snaps, tag);
2640 if (error != 0)

--- 75 unchanged lines hidden (view full) ---

2716
2717int
2718dsl_dataset_clone_swap_check_impl(dsl_dataset_t *clone,
2719 dsl_dataset_t *origin_head, boolean_t force, void *owner, dmu_tx_t *tx)
2720{
2721 int64_t unused_refres_delta;
2722
2723 /* they should both be heads */
2719 if (dsl_dataset_is_snapshot(clone) ||
2720 dsl_dataset_is_snapshot(origin_head))
2724 if (clone->ds_is_snapshot ||
2725 origin_head->ds_is_snapshot)
2721 return (SET_ERROR(EINVAL));
2722
2723 /* if we are not forcing, the branch point should be just before them */
2724 if (!force && clone->ds_prev != origin_head->ds_prev)
2725 return (SET_ERROR(EINVAL));
2726
2727 /* clone should be the clone (unless they are unrelated) */
2728 if (clone->ds_prev != NULL &&

--- 262 unchanged lines hidden (view full) ---

2991
2992 if (spa_version(dp->dp_spa) < SPA_VERSION_REFQUOTA)
2993 return (SET_ERROR(ENOTSUP));
2994
2995 error = dsl_dataset_hold(dp, ddsqra->ddsqra_name, FTAG, &ds);
2996 if (error != 0)
2997 return (error);
2998
2726 return (SET_ERROR(EINVAL));
2727
2728 /* if we are not forcing, the branch point should be just before them */
2729 if (!force && clone->ds_prev != origin_head->ds_prev)
2730 return (SET_ERROR(EINVAL));
2731
2732 /* clone should be the clone (unless they are unrelated) */
2733 if (clone->ds_prev != NULL &&

--- 262 unchanged lines hidden (view full) ---

2996
2997 if (spa_version(dp->dp_spa) < SPA_VERSION_REFQUOTA)
2998 return (SET_ERROR(ENOTSUP));
2999
3000 error = dsl_dataset_hold(dp, ddsqra->ddsqra_name, FTAG, &ds);
3001 if (error != 0)
3002 return (error);
3003
2999 if (dsl_dataset_is_snapshot(ds)) {
3004 if (ds->ds_is_snapshot) {
3000 dsl_dataset_rele(ds, FTAG);
3001 return (SET_ERROR(EINVAL));
3002 }
3003
3004 error = dsl_prop_predict(ds->ds_dir,
3005 zfs_prop_to_name(ZFS_PROP_REFQUOTA),
3006 ddsqra->ddsqra_source, ddsqra->ddsqra_value, &newval);
3007 if (error != 0) {

--- 66 unchanged lines hidden (view full) ---

3074
3075 if (spa_version(dp->dp_spa) < SPA_VERSION_REFRESERVATION)
3076 return (SET_ERROR(ENOTSUP));
3077
3078 error = dsl_dataset_hold(dp, ddsqra->ddsqra_name, FTAG, &ds);
3079 if (error != 0)
3080 return (error);
3081
3005 dsl_dataset_rele(ds, FTAG);
3006 return (SET_ERROR(EINVAL));
3007 }
3008
3009 error = dsl_prop_predict(ds->ds_dir,
3010 zfs_prop_to_name(ZFS_PROP_REFQUOTA),
3011 ddsqra->ddsqra_source, ddsqra->ddsqra_value, &newval);
3012 if (error != 0) {

--- 66 unchanged lines hidden (view full) ---

3079
3080 if (spa_version(dp->dp_spa) < SPA_VERSION_REFRESERVATION)
3081 return (SET_ERROR(ENOTSUP));
3082
3083 error = dsl_dataset_hold(dp, ddsqra->ddsqra_name, FTAG, &ds);
3084 if (error != 0)
3085 return (error);
3086
3082 if (dsl_dataset_is_snapshot(ds)) {
3087 if (ds->ds_is_snapshot) {
3083 dsl_dataset_rele(ds, FTAG);
3084 return (SET_ERROR(EINVAL));
3085 }
3086
3087 error = dsl_prop_predict(ds->ds_dir,
3088 zfs_prop_to_name(ZFS_PROP_REFRESERVATION),
3089 ddsqra->ddsqra_source, ddsqra->ddsqra_value, &newval);
3090 if (error != 0) {

--- 197 unchanged lines hidden (view full) ---

3288dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap,
3289 dsl_dataset_t *lastsnap,
3290 uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
3291{
3292 int err = 0;
3293 uint64_t snapobj;
3294 dsl_pool_t *dp = firstsnap->ds_dir->dd_pool;
3295
3088 dsl_dataset_rele(ds, FTAG);
3089 return (SET_ERROR(EINVAL));
3090 }
3091
3092 error = dsl_prop_predict(ds->ds_dir,
3093 zfs_prop_to_name(ZFS_PROP_REFRESERVATION),
3094 ddsqra->ddsqra_source, ddsqra->ddsqra_value, &newval);
3095 if (error != 0) {

--- 197 unchanged lines hidden (view full) ---

3293dsl_dataset_space_wouldfree(dsl_dataset_t *firstsnap,
3294 dsl_dataset_t *lastsnap,
3295 uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
3296{
3297 int err = 0;
3298 uint64_t snapobj;
3299 dsl_pool_t *dp = firstsnap->ds_dir->dd_pool;
3300
3296 ASSERT(dsl_dataset_is_snapshot(firstsnap));
3297 ASSERT(dsl_dataset_is_snapshot(lastsnap));
3301 ASSERT(firstsnap->ds_is_snapshot);
3302 ASSERT(lastsnap->ds_is_snapshot);
3298
3299 /*
3300 * Check that the snapshots are in the same dsl_dir, and firstsnap
3301 * is before lastsnap.
3302 */
3303 if (firstsnap->ds_dir != lastsnap->ds_dir ||
3304 dsl_dataset_phys(firstsnap)->ds_creation_txg >
3305 dsl_dataset_phys(lastsnap)->ds_creation_txg)

--- 108 unchanged lines hidden (view full) ---

3414dsl_dataset_is_before(dsl_dataset_t *later, dsl_dataset_t *earlier,
3415 uint64_t earlier_txg)
3416{
3417 dsl_pool_t *dp = later->ds_dir->dd_pool;
3418 int error;
3419 boolean_t ret;
3420
3421 ASSERT(dsl_pool_config_held(dp));
3303
3304 /*
3305 * Check that the snapshots are in the same dsl_dir, and firstsnap
3306 * is before lastsnap.
3307 */
3308 if (firstsnap->ds_dir != lastsnap->ds_dir ||
3309 dsl_dataset_phys(firstsnap)->ds_creation_txg >
3310 dsl_dataset_phys(lastsnap)->ds_creation_txg)

--- 108 unchanged lines hidden (view full) ---

3419dsl_dataset_is_before(dsl_dataset_t *later, dsl_dataset_t *earlier,
3420 uint64_t earlier_txg)
3421{
3422 dsl_pool_t *dp = later->ds_dir->dd_pool;
3423 int error;
3424 boolean_t ret;
3425
3426 ASSERT(dsl_pool_config_held(dp));
3422 ASSERT(dsl_dataset_is_snapshot(earlier) || earlier_txg != 0);
3427 ASSERT(earlier->ds_is_snapshot || earlier_txg != 0);
3423
3424 if (earlier_txg == 0)
3425 earlier_txg = dsl_dataset_phys(earlier)->ds_creation_txg;
3426
3428
3429 if (earlier_txg == 0)
3430 earlier_txg = dsl_dataset_phys(earlier)->ds_creation_txg;
3431
3427 if (dsl_dataset_is_snapshot(later) &&
3432 if (later->ds_is_snapshot &&
3428 earlier_txg >= dsl_dataset_phys(later)->ds_creation_txg)
3429 return (B_FALSE);
3430
3431 if (later->ds_dir == earlier->ds_dir)
3432 return (B_TRUE);
3433 if (!dsl_dir_is_clone(later->ds_dir))
3434 return (B_FALSE);
3435

--- 19 unchanged lines hidden ---
3433 earlier_txg >= dsl_dataset_phys(later)->ds_creation_txg)
3434 return (B_FALSE);
3435
3436 if (later->ds_dir == earlier->ds_dir)
3437 return (B_TRUE);
3438 if (!dsl_dir_is_clone(later->ds_dir))
3439 return (B_FALSE);
3440

--- 19 unchanged lines hidden ---