1*591e0e13SSebastien Roy /*
2*591e0e13SSebastien Roy  * CDDL HEADER START
3*591e0e13SSebastien Roy  *
4*591e0e13SSebastien Roy  * The contents of this file are subject to the terms of the
5*591e0e13SSebastien Roy  * Common Development and Distribution License (the "License").
6*591e0e13SSebastien Roy  * You may not use this file except in compliance with the License.
7*591e0e13SSebastien Roy  *
8*591e0e13SSebastien Roy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*591e0e13SSebastien Roy  * or http://www.opensolaris.org/os/licensing.
10*591e0e13SSebastien Roy  * See the License for the specific language governing permissions
11*591e0e13SSebastien Roy  * and limitations under the License.
12*591e0e13SSebastien Roy  *
13*591e0e13SSebastien Roy  * When distributing Covered Code, include this CDDL HEADER in each
14*591e0e13SSebastien Roy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*591e0e13SSebastien Roy  * If applicable, add the following below this CDDL HEADER, with the
16*591e0e13SSebastien Roy  * fields enclosed by brackets "[]" replaced with your own identifying
17*591e0e13SSebastien Roy  * information: Portions Copyright [yyyy] [name of copyright owner]
18*591e0e13SSebastien Roy  *
19*591e0e13SSebastien Roy  * CDDL HEADER END
20*591e0e13SSebastien Roy  */
21*591e0e13SSebastien Roy /*
22*591e0e13SSebastien Roy  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23*591e0e13SSebastien Roy  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
24*591e0e13SSebastien Roy  * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
25*591e0e13SSebastien Roy  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
26*591e0e13SSebastien Roy  */
27*591e0e13SSebastien Roy 
28*591e0e13SSebastien Roy #ifndef	_ZFS_TASKQ_H
29*591e0e13SSebastien Roy #define	_ZFS_TASKQ_H
30*591e0e13SSebastien Roy 
31*591e0e13SSebastien Roy #include <stdint.h>
32*591e0e13SSebastien Roy #include <umem.h>
33*591e0e13SSebastien Roy 
34*591e0e13SSebastien Roy #ifdef	__cplusplus
35*591e0e13SSebastien Roy extern "C" {
36*591e0e13SSebastien Roy #endif
37*591e0e13SSebastien Roy 
38*591e0e13SSebastien Roy typedef struct zfs_taskq zfs_taskq_t;
39*591e0e13SSebastien Roy typedef uintptr_t zfs_taskqid_t;
40*591e0e13SSebastien Roy typedef void (ztask_func_t)(void *);
41*591e0e13SSebastien Roy 
42*591e0e13SSebastien Roy #define	ZFS_TQENT_FLAG_PREALLOC		0x1	/* taskq_dispatch_ent used */
43*591e0e13SSebastien Roy 
44*591e0e13SSebastien Roy #define	ZFS_TASKQ_PREPOPULATE		0x0001
45*591e0e13SSebastien Roy 
46*591e0e13SSebastien Roy #define	ZFS_TQ_SLEEP	UMEM_NOFAIL	/* Can block for memory */
47*591e0e13SSebastien Roy #define	ZFS_TQ_NOSLEEP	UMEM_DEFAULT	/* cannot block for memory; may fail */
48*591e0e13SSebastien Roy #define	ZFS_TQ_FRONT	0x08		/* Queue in front */
49*591e0e13SSebastien Roy 
50*591e0e13SSebastien Roy extern zfs_taskq_t	*zfs_taskq_create(const char *, int, pri_t, int,
51*591e0e13SSebastien Roy 	int, uint_t);
52*591e0e13SSebastien Roy extern void		zfs_taskq_destroy(zfs_taskq_t *);
53*591e0e13SSebastien Roy 
54*591e0e13SSebastien Roy extern zfs_taskqid_t	zfs_taskq_dispatch(zfs_taskq_t *, ztask_func_t,
55*591e0e13SSebastien Roy 	void *, uint_t);
56*591e0e13SSebastien Roy 
57*591e0e13SSebastien Roy extern void		zfs_taskq_wait(zfs_taskq_t *);
58*591e0e13SSebastien Roy 
59*591e0e13SSebastien Roy #ifdef	__cplusplus
60*591e0e13SSebastien Roy }
61*591e0e13SSebastien Roy #endif
62*591e0e13SSebastien Roy 
63*591e0e13SSebastien Roy #endif	/* _ZFS_TASKQ_H */
64