usr/src/uts/common/fs/zfs/dsl_dir.c
changeset 10922 e2081f502306
parent 10921 8aac17999e4d
child 10974 32d689ba6466
equal deleted inserted replaced
10921:8aac17999e4d 10922:e2081f502306
    30 #include <sys/dsl_dir.h>
    30 #include <sys/dsl_dir.h>
    31 #include <sys/dsl_prop.h>
    31 #include <sys/dsl_prop.h>
    32 #include <sys/dsl_synctask.h>
    32 #include <sys/dsl_synctask.h>
    33 #include <sys/dsl_deleg.h>
    33 #include <sys/dsl_deleg.h>
    34 #include <sys/spa.h>
    34 #include <sys/spa.h>
       
    35 #include <sys/metaslab.h>
    35 #include <sys/zap.h>
    36 #include <sys/zap.h>
    36 #include <sys/zio.h>
    37 #include <sys/zio.h>
    37 #include <sys/arc.h>
    38 #include <sys/arc.h>
    38 #include <sys/sunddi.h>
    39 #include <sys/sunddi.h>
    39 #include "zfs_namecheck.h"
    40 #include "zfs_namecheck.h"
   648 		 * we think we are using more space than there
   649 		 * we think we are using more space than there
   649 		 * is in the pool (which is already 1.6% more than
   650 		 * is in the pool (which is already 1.6% more than
   650 		 * dsl_pool_adjustedsize()), something is very
   651 		 * dsl_pool_adjustedsize()), something is very
   651 		 * wrong.
   652 		 * wrong.
   652 		 */
   653 		 */
   653 		ASSERT3U(used, <=, spa_get_space(dd->dd_pool->dp_spa));
   654 		ASSERT3U(used, <=, metaslab_class_get_space(
       
   655 		    spa_normal_class(dd->dd_pool->dp_spa)));
   654 	} else {
   656 	} else {
   655 		/*
   657 		/*
   656 		 * the lesser of the space provided by our parent and
   658 		 * the lesser of the space provided by our parent and
   657 		 * the space left in our quota
   659 		 * the space left in our quota
   658 		 */
   660 		 */
   734 	 * but still within the pool's allocation slop.  In cases where
   736 	 * but still within the pool's allocation slop.  In cases where
   735 	 * we're very close to full, this will allow a steady trickle of
   737 	 * we're very close to full, this will allow a steady trickle of
   736 	 * removes to get through.
   738 	 * removes to get through.
   737 	 */
   739 	 */
   738 	if (dd->dd_parent == NULL) {
   740 	if (dd->dd_parent == NULL) {
       
   741 		spa_t *spa = dd->dd_pool->dp_spa;
   739 		uint64_t poolsize = dsl_pool_adjustedsize(dd->dd_pool, netfree);
   742 		uint64_t poolsize = dsl_pool_adjustedsize(dd->dd_pool, netfree);
   740 		deferred = spa_get_defers(dd->dd_pool->dp_spa);
   743 		deferred = metaslab_class_get_deferred(spa_normal_class(spa));
   741 		if (poolsize - deferred < quota) {
   744 		if (poolsize - deferred < quota) {
   742 			quota = poolsize - deferred;
   745 			quota = poolsize - deferred;
   743 			retval = ENOSPC;
   746 			retval = ENOSPC;
   744 		}
   747 		}
   745 	}
   748 	}