summaryrefslogtreecommitdiffstats
path: root/module/zfs/dsl_dataset.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2009-02-18 12:51:31 -0800
committerBrian Behlendorf <[email protected]>2009-02-18 12:51:31 -0800
commitd164b2093561a9771db07346e6fffc9ca19427a2 (patch)
treeb24adaf8695cebdd827968ac1df3cc0093936be1 /module/zfs/dsl_dataset.c
parentc65e71073f45e6e549c825969740cb15a96ea547 (diff)
Rebase master to b108
Diffstat (limited to 'module/zfs/dsl_dataset.c')
-rw-r--r--module/zfs/dsl_dataset.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c
index e488b2bdd..a68b12d33 100644
--- a/module/zfs/dsl_dataset.c
+++ b/module/zfs/dsl_dataset.c
@@ -19,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -2204,6 +2204,12 @@ dsl_dataset_rename(char *oldname, const char *newname, boolean_t recursive)
err = dsl_dir_open(oldname, FTAG, &dd, &tail);
if (err)
return (err);
+ /*
+ * If there are more than 2 references there may be holds
+ * hanging around that haven't been cleared out yet.
+ */
+ if (dmu_buf_refcount(dd->dd_dbuf) > 2)
+ txg_wait_synced(dd->dd_pool, 0);
if (tail == NULL) {
int delta = strlen(newname) - strlen(oldname);
@@ -3024,12 +3030,8 @@ dsl_dataset_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx)
dsl_dataset_t *ds = arg1;
uint64_t *reservationp = arg2;
uint64_t new_reservation = *reservationp;
- int64_t delta;
uint64_t unique;
- if (new_reservation > INT64_MAX)
- return (EOVERFLOW);
-
if (spa_version(ds->ds_dir->dd_pool->dp_spa) <
SPA_VERSION_REFRESERVATION)
return (ENOTSUP);
@@ -3046,15 +3048,18 @@ dsl_dataset_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx)
mutex_enter(&ds->ds_lock);
unique = dsl_dataset_unique(ds);
- delta = MAX(unique, new_reservation) - MAX(unique, ds->ds_reserved);
mutex_exit(&ds->ds_lock);
- if (delta > 0 &&
- delta > dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE))
- return (ENOSPC);
- if (delta > 0 && ds->ds_quota > 0 &&
- new_reservation > ds->ds_quota)
- return (ENOSPC);
+ if (MAX(unique, new_reservation) > MAX(unique, ds->ds_reserved)) {
+ uint64_t delta = MAX(unique, new_reservation) -
+ MAX(unique, ds->ds_reserved);
+
+ if (delta > dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE))
+ return (ENOSPC);
+ if (ds->ds_quota > 0 &&
+ new_reservation > ds->ds_quota)
+ return (ENOSPC);
+ }
return (0);
}