diff usr/src/uts/common/fs/zfs/dsl_dataset.c @ 5831:48655d6b290b

6630761 In sub-filesystem, available space is less than refreservation space
author ck153898
date Mon, 14 Jan 2008 13:37:53 -0800
parents 81f1af42bafc
children 235fee4665e7
line wrap: on
line diff
--- a/usr/src/uts/common/fs/zfs/dsl_dataset.c	Mon Jan 14 13:35:29 2008 -0800
+++ b/usr/src/uts/common/fs/zfs/dsl_dataset.c	Mon Jan 14 13:37:53 2008 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -2544,12 +2544,19 @@
 
 int
 dsl_dataset_check_quota(dsl_dataset_t *ds, boolean_t check_quota,
-    uint64_t asize, uint64_t inflight, uint64_t *used)
+    uint64_t asize, uint64_t inflight, uint64_t *used,
+    uint64_t *ref_rsrv)
 {
 	int error = 0;
 
 	ASSERT3S(asize, >, 0);
 
+	/*
+	 * *ref_rsrv is the portion of asize that will come from any
+	 * unconsumed refreservation space.
+	 */
+	*ref_rsrv = 0;
+
 	mutex_enter(&ds->ds_lock);
 	/*
 	 * Make a space adjustment for reserved bytes.
@@ -2558,6 +2565,8 @@
 		ASSERT3U(*used, >=,
 		    ds->ds_reserved - ds->ds_phys->ds_unique_bytes);
 		*used -= (ds->ds_reserved - ds->ds_phys->ds_unique_bytes);
+		*ref_rsrv =
+		    asize - MIN(asize, parent_delta(ds, asize + inflight));
 	}
 
 	if (!check_quota || ds->ds_quota == 0) {