1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens/*
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * CDDL HEADER START
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens *
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * The contents of this file are subject to the terms of the
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * Common Development and Distribution License (the "License").
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * You may not use this file except in compliance with the License.
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens *
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * or http://www.opensolaris.org/os/licensing.
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * See the License for the specific language governing permissions
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * and limitations under the License.
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens *
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * When distributing Covered Code, include this CDDL HEADER in each
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * If applicable, add the following below this CDDL HEADER, with the
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * fields enclosed by brackets "[]" replaced with your own identifying
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * information: Portions Copyright [yyyy] [name of copyright owner]
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens *
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens * CDDL HEADER END
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens */
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens/*
3f9d6ad73e45c6823b409f93b0c8d4f62861d2d5Lin Ling * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens */
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#ifndef _SYS_DSL_SYNCTASK_H
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#define _SYS_DSL_SYNCTASK_H
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#include <sys/txg.h>
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#include <sys/zfs_context.h>
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#ifdef __cplusplus
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrensextern "C" {
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#endif
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrensstruct dsl_pool;
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrenstypedef int (dsl_checkfunc_t)(void *, dmu_tx_t *);
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrenstypedef void (dsl_syncfunc_t)(void *, dmu_tx_t *);
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrenstypedef enum zfs_space_check {
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens /*
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * Normal space check: if there is less than 3.2% free space,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * the operation will fail. Operations which are logically
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * creating things should use this (e.g. "zfs create", "zfs snapshot").
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * User writes (via the ZPL / ZVOL) also fail at this point.
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens */
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens ZFS_SPACE_CHECK_NORMAL,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens /*
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * Space check allows use of half the slop space. If there
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * is less than 1.6% free space, the operation will fail. Most
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * operations should use this (e.g. "zfs set", "zfs rename"),
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * because we want them to succeed even after user writes are failing,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * so that they can be used as part of the space recovery process.
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens */
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens ZFS_SPACE_CHECK_RESERVED,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens /*
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * No space check is performed. Only operations which we expect to
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * result in a net reduction in space should use this
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * (e.g. "zfs destroy". Setting quotas & reservations also uses
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * this because it needs to circumvent the quota/reservation checks).
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens *
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens * See also the comments above spa_slop_shift.
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens */
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens ZFS_SPACE_CHECK_NONE,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens} zfs_space_check_t;
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrenstypedef struct dsl_sync_task {
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens txg_node_t dst_node;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens struct dsl_pool *dst_pool;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens uint64_t dst_txg;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens int dst_space;
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens zfs_space_check_t dst_space_check;
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens dsl_checkfunc_t *dst_checkfunc;
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens dsl_syncfunc_t *dst_syncfunc;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens void *dst_arg;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens int dst_error;
3b2aab18808792cbd248a12f1edf139b89833c13Matthew Ahrens boolean_t dst_nowaiter;
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens} dsl_sync_task_t;
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrensvoid dsl_sync_task_sync(dsl_sync_task_t *, dmu_tx_t *);
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrensint dsl_sync_task(const char *, dsl_checkfunc_t *,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens dsl_syncfunc_t *, void *, int, zfs_space_check_t);
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrensvoid dsl_sync_task_nowait(struct dsl_pool *, dsl_syncfunc_t *,
7d46dc6ca63a6f3f0d51aa655bfcf10cf2405a9eMatthew Ahrens void *, int, zfs_space_check_t, dmu_tx_t *);
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#ifdef __cplusplus
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens}
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#endif
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens
1d452cf5123cb6ac0a013a4dbd4dcceeb0da314dahrens#endif /* _SYS_DSL_SYNCTASK_H */