xref: /freebsd-src/sys/contrib/openzfs/include/sys/zvol.h (revision f8b1db88b827cf24ae14c55a2e762313f0f9911c)
1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy  * CDDL HEADER START
3eda14cbcSMatt Macy  *
4eda14cbcSMatt Macy  * The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy  * Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy  * You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy  *
8eda14cbcSMatt Macy  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9271171e0SMartin Matuska  * or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy  * See the License for the specific language governing permissions
11eda14cbcSMatt Macy  * and limitations under the License.
12eda14cbcSMatt Macy  *
13eda14cbcSMatt Macy  * When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy  * If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy  * fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy  * information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy  *
19eda14cbcSMatt Macy  * CDDL HEADER END
20eda14cbcSMatt Macy  */
21eda14cbcSMatt Macy 
22eda14cbcSMatt Macy /*
23eda14cbcSMatt Macy  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
24eda14cbcSMatt Macy  * Copyright (c) 2016 Actifio, Inc. All rights reserved.
25eda14cbcSMatt Macy  */
26eda14cbcSMatt Macy 
27eda14cbcSMatt Macy #ifndef	_SYS_ZVOL_H
28eda14cbcSMatt Macy #define	_SYS_ZVOL_H
29eda14cbcSMatt Macy 
30eda14cbcSMatt Macy #include <sys/zfs_context.h>
31eda14cbcSMatt Macy 
32eda14cbcSMatt Macy #define	ZVOL_OBJ		1ULL
33eda14cbcSMatt Macy #define	ZVOL_ZAP_OBJ		2ULL
34eda14cbcSMatt Macy 
35eda14cbcSMatt Macy #define	SPEC_MAXOFFSET_T	((1LL << ((NBBY * sizeof (daddr32_t)) + \
36eda14cbcSMatt Macy 				DEV_BSHIFT - 1)) - 1)
37eda14cbcSMatt Macy 
38eda14cbcSMatt Macy extern void zvol_create_minor(const char *);
39eda14cbcSMatt Macy extern void zvol_create_minors_recursive(const char *);
40eda14cbcSMatt Macy extern void zvol_remove_minors(spa_t *, const char *, boolean_t);
41eda14cbcSMatt Macy extern void zvol_rename_minors(spa_t *, const char *, const char *, boolean_t);
42eda14cbcSMatt Macy 
43eda14cbcSMatt Macy #ifdef _KERNEL
44eda14cbcSMatt Macy struct zvol_state;
45eda14cbcSMatt Macy typedef struct zvol_state zvol_state_handle_t;
46eda14cbcSMatt Macy 
47eda14cbcSMatt Macy extern int zvol_check_volsize(uint64_t, uint64_t);
48eda14cbcSMatt Macy extern int zvol_check_volblocksize(const char *, uint64_t);
49eda14cbcSMatt Macy extern int zvol_get_stats(objset_t *, nvlist_t *);
50eda14cbcSMatt Macy extern boolean_t zvol_is_zvol(const char *);
51eda14cbcSMatt Macy extern void zvol_create_cb(objset_t *, void *, cred_t *, dmu_tx_t *);
52eda14cbcSMatt Macy extern int zvol_set_volsize(const char *, uint64_t);
53*f8b1db88SMartin Matuska extern int zvol_set_volthreading(const char *, boolean_t);
54*f8b1db88SMartin Matuska extern int zvol_set_common(const char *, zfs_prop_t, zprop_source_t, uint64_t);
55*f8b1db88SMartin Matuska extern int zvol_set_ro(const char *, boolean_t);
56eda14cbcSMatt Macy extern zvol_state_handle_t *zvol_suspend(const char *);
57eda14cbcSMatt Macy extern int zvol_resume(zvol_state_handle_t *);
58eda14cbcSMatt Macy extern void *zvol_tag(zvol_state_handle_t *);
59eda14cbcSMatt Macy 
60eda14cbcSMatt Macy extern int zvol_init(void);
61eda14cbcSMatt Macy extern void zvol_fini(void);
62eda14cbcSMatt Macy extern int zvol_busy(void);
63eda14cbcSMatt Macy 
64eda14cbcSMatt Macy #endif /* _KERNEL */
65eda14cbcSMatt Macy #endif /* _SYS_ZVOL_H */
66