FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_synctask.c
/*
 * Called in syncing context to execute the synctask.
 */
Called in syncing context to execute the synctask.
Called in syncing context to execute the synctask .
void
dsl_sync_task_sync(dsl_sync_task_t *dst, dmu_tx_t *tx)
{
	dsl_pool_t *dp = dst->dst_pool;
	ASSERT0(dst->dst_error);
	if (dst->dst_space_check != ZFS_SPACE_CHECK_NONE) {
		uint64_t quota = dsl_pool_adjustedsize(dp,
		    dst->dst_space_check == ZFS_SPACE_CHECK_RESERVED) -
		    metaslab_class_get_deferred(spa_normal_class(dp->dp_spa));
		uint64_t used = dsl_dir_phys(dp->dp_root_dir)->dd_used_bytes;
		if (dst->dst_space > 0 && used + dst->dst_space * 3 > quota) {
			dst->dst_error = SET_ERROR(ENOSPC);
			if (dst->dst_nowaiter)
				kmem_free(dst, sizeof (*dst));
			return;
		}
	}
	rrw_enter(&dp->dp_config_rwlock, RW_WRITER, FTAG);
	dst->dst_error = dst->dst_checkfunc(dst->dst_arg, tx);
	if (dst->dst_error == 0)
		dst->dst_syncfunc(dst->dst_arg, tx);
	rrw_exit(&dp->dp_config_rwlock, FTAG);
	if (dst->dst_nowaiter)
		kmem_free(dst, sizeof (*dst));
}
void dsl_sync_task_sync ( dsl_sync_task_t * dst , dmu_tx_t * tx ) { dsl_pool_t * dp = dst -> dst_pool ; ASSERT0 ( dst -> dst_error ) ; if ( dst -> dst_space_check != ZFS_SPACE_CHECK_NONE ) { uint64_t quota = dsl_pool_adjustedsize ( dp , dst -> dst_space_check == ZFS_SPACE_CHECK_RESERVED ) - metaslab_class_get_deferred ( spa_normal_class ( dp -> dp_spa ) ) ; uint64_t used = dsl_dir_phys ( dp -> dp_root_dir ) -> dd_used_bytes ; if ( dst -> dst_space > 0 && used + dst -> dst_space * 3 > quota ) { dst -> dst_error = SET_ERROR ( ENOSPC ) ; if ( dst -> dst_nowaiter ) kmem_free ( dst , sizeof ( * dst ) ) ; return ; } } rrw_enter ( & dp -> dp_config_rwlock , RW_WRITER , FTAG ) ; dst -> dst_error = dst -> dst_checkfunc ( dst -> dst_arg , tx ) ; if ( dst -> dst_error == 0 ) dst -> dst_syncfunc ( dst -> dst_arg , tx ) ; rrw_exit ( & dp -> dp_config_rwlock , FTAG ) ; if ( dst -> dst_nowaiter ) kmem_free ( dst , sizeof ( * dst ) ) ; }
Called in syncing context to execute the synctask.
Called in syncing context to execute the synctask .
/*
	 * Check for sufficient space.
	 *
	 * When the sync task was created, the caller specified the
	 * type of space checking required.  See the comment in
	 * zfs_space_check_t for details on the semantics of each
	 * type of space checking.
	 *
	 * We just check against what's on-disk; we don't want any
	 * in-flight accounting to get in our way, because open context
	 * may have already used up various in-core limits
	 * (arc_tempreserve, dsl_pool_tempreserve).
	 */ /* MOS space is triple-dittoed, so we multiply by 3. */ /*
	 * Check for errors by calling checkfunc.
	 */