4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
26 #ifndef _SYS_DSL_SYNCTASK_H
27 #define _SYS_DSL_SYNCTASK_H
30 #include <sys/zfs_context.h>
38 typedef int (dsl_checkfunc_t
)(void *, dmu_tx_t
*);
39 typedef void (dsl_syncfunc_t
)(void *, dmu_tx_t
*);
40 typedef void (dsl_sigfunc_t
)(void *, dmu_tx_t
*);
42 typedef enum zfs_space_check
{
44 * Normal space check: if there is less than 3.2% free space,
45 * the operation will fail. Operations which are logically
46 * creating things should use this (e.g. "zfs create", "zfs snapshot").
47 * User writes (via the ZPL / ZVOL) also fail at this point.
49 ZFS_SPACE_CHECK_NORMAL
,
52 * Space check allows use of half the slop space. If there
53 * is less than 1.6% free space, the operation will fail. Most
54 * operations should use this (e.g. "zfs set", "zfs rename"),
55 * because we want them to succeed even after user writes are failing,
56 * so that they can be used as part of the space recovery process.
58 ZFS_SPACE_CHECK_RESERVED
,
61 * Space check allows use of three quarters of the slop space.
62 * If there is less than 0.8% free space, the operation will
65 ZFS_SPACE_CHECK_EXTRA_RESERVED
,
68 * In all cases "zfs destroy" is expected to result in an net
69 * reduction of space, except one. When the pool has a
70 * checkpoint, space freed by "zfs destroy" will not actually
71 * free anything internally. Thus, it starts failing after
72 * three quarters of the slop space is exceeded.
74 ZFS_SPACE_CHECK_DESTROY
= ZFS_SPACE_CHECK_EXTRA_RESERVED
,
77 * A channel program can run a "zfs destroy" as part of its
78 * script and therefore has the same space_check policy when
81 ZFS_SPACE_CHECK_ZCP_EVAL
= ZFS_SPACE_CHECK_DESTROY
,
84 * No space check is performed. This level of space check should
85 * be used cautiously as operations that use it can even run when
86 * 0.8% capacity is left for use. In this scenario, if there is a
87 * checkpoint, async destroys are suspended and any kind of freeing
88 * can potentially add space instead of freeing it.
90 * See also the comments above spa_slop_shift.
94 ZFS_SPACE_CHECK_DISCARD_CHECKPOINT
= ZFS_SPACE_CHECK_NONE
,
98 typedef struct dsl_sync_task
{
100 struct dsl_pool
*dst_pool
;
103 zfs_space_check_t dst_space_check
;
104 dsl_checkfunc_t
*dst_checkfunc
;
105 dsl_syncfunc_t
*dst_syncfunc
;
108 boolean_t dst_nowaiter
;
111 void dsl_sync_task_sync(dsl_sync_task_t
*, dmu_tx_t
*);
112 int dsl_sync_task(const char *, dsl_checkfunc_t
*,
113 dsl_syncfunc_t
*, void *, int, zfs_space_check_t
);
114 void dsl_sync_task_nowait(struct dsl_pool
*, dsl_syncfunc_t
*,
116 int dsl_early_sync_task(const char *, dsl_checkfunc_t
*,
117 dsl_syncfunc_t
*, void *, int, zfs_space_check_t
);
118 void dsl_early_sync_task_nowait(struct dsl_pool
*, dsl_syncfunc_t
*,
120 int dsl_sync_task_sig(const char *, dsl_checkfunc_t
*, dsl_syncfunc_t
*,
121 dsl_sigfunc_t
*, void *, int, zfs_space_check_t
);
127 #endif /* _SYS_DSL_SYNCTASK_H */