xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h (revision d8ab6e129d75d7c3f21a7909bf811a3de65faea8)
1fa9e4066Sahrens /*
2fa9e4066Sahrens  * CDDL HEADER START
3fa9e4066Sahrens  *
4fa9e4066Sahrens  * The contents of this file are subject to the terms of the
5ea8dc4b6Seschrock  * Common Development and Distribution License (the "License").
6ea8dc4b6Seschrock  * You may not use this file except in compliance with the License.
7fa9e4066Sahrens  *
8fa9e4066Sahrens  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e4066Sahrens  * or http://www.opensolaris.org/os/licensing.
10fa9e4066Sahrens  * See the License for the specific language governing permissions
11fa9e4066Sahrens  * and limitations under the License.
12fa9e4066Sahrens  *
13fa9e4066Sahrens  * When distributing Covered Code, include this CDDL HEADER in each
14fa9e4066Sahrens  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e4066Sahrens  * If applicable, add the following below this CDDL HEADER, with the
16fa9e4066Sahrens  * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e4066Sahrens  * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e4066Sahrens  *
19fa9e4066Sahrens  * CDDL HEADER END
20fa9e4066Sahrens  */
21fa9e4066Sahrens /*
22c99e4bdcSChris Kirby  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
230d8fa8f8SMartin Matuska  * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
24ed992b0aSSerapheim Dimitropoulos  * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
25880094b6SAndrew Stormont  * Copyright 2016 RackTop Systems.
26c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
27fa9e4066Sahrens  */
28fa9e4066Sahrens 
29fa9e4066Sahrens #ifndef	_SYS_ZFS_IOCTL_H
30fa9e4066Sahrens #define	_SYS_ZFS_IOCTL_H
31fa9e4066Sahrens 
32fa9e4066Sahrens #include <sys/cred.h>
33fa9e4066Sahrens #include <sys/dmu.h>
34ea8dc4b6Seschrock #include <sys/zio.h>
35ecd6cf80Smarks #include <sys/dsl_deleg.h>
369e69d7d0SLori Alt #include <sys/spa.h>
3799d5e173STim Haley #include <sys/zfs_stat.h>
38fa9e4066Sahrens 
39da6c28aaSamw #ifdef _KERNEL
40da6c28aaSamw #include <sys/nvpair.h>
41da6c28aaSamw #endif	/* _KERNEL */
42da6c28aaSamw 
43fa9e4066Sahrens #ifdef	__cplusplus
44fa9e4066Sahrens extern "C" {
45fa9e4066Sahrens #endif
46fa9e4066Sahrens 
474445fffbSMatthew Ahrens /*
484445fffbSMatthew Ahrens  * The structures in this file are passed between userland and the
494445fffbSMatthew Ahrens  * kernel.  Userland may be running a 32-bit process, while the kernel
504445fffbSMatthew Ahrens  * is 64-bit.  Therefore, these structures need to compile the same in
514445fffbSMatthew Ahrens  * 32-bit and 64-bit.  This means not using type "long", and adding
524445fffbSMatthew Ahrens  * explicit padding so that the 32-bit structure will not be packed more
534445fffbSMatthew Ahrens  * tightly than the 64-bit structure (which requires 64-bit alignment).
544445fffbSMatthew Ahrens  */
554445fffbSMatthew Ahrens 
56fa9e4066Sahrens /*
57fa9e4066Sahrens  * Property values for snapdir
58fa9e4066Sahrens  */
59a0965f35Sbonwick #define	ZFS_SNAPDIR_HIDDEN		0
60a0965f35Sbonwick #define	ZFS_SNAPDIR_VISIBLE		1
61fa9e4066Sahrens 
629e69d7d0SLori Alt /*
639e69d7d0SLori Alt  * Field manipulation macros for the drr_versioninfo field of the
649e69d7d0SLori Alt  * send stream header.
659e69d7d0SLori Alt  */
669e69d7d0SLori Alt 
679e69d7d0SLori Alt /*
689e69d7d0SLori Alt  * Header types for zfs send streams.
699e69d7d0SLori Alt  */
709e69d7d0SLori Alt typedef enum drr_headertype {
719e69d7d0SLori Alt 	DMU_SUBSTREAM = 0x1,
729e69d7d0SLori Alt 	DMU_COMPOUNDSTREAM = 0x2
739e69d7d0SLori Alt } drr_headertype_t;
749e69d7d0SLori Alt 
759e69d7d0SLori Alt #define	DMU_GET_STREAM_HDRTYPE(vi)	BF64_GET((vi), 0, 2)
769e69d7d0SLori Alt #define	DMU_SET_STREAM_HDRTYPE(vi, x)	BF64_SET((vi), 0, 2, x)
779e69d7d0SLori Alt 
789e69d7d0SLori Alt #define	DMU_GET_FEATUREFLAGS(vi)	BF64_GET((vi), 2, 30)
799e69d7d0SLori Alt #define	DMU_SET_FEATUREFLAGS(vi, x)	BF64_SET((vi), 2, 30, x)
809e69d7d0SLori Alt 
819e69d7d0SLori Alt /*
829e69d7d0SLori Alt  * Feature flags for zfs send streams (flags in drr_versioninfo)
839e69d7d0SLori Alt  */
849e69d7d0SLori Alt 
859c3fd121SMatthew Ahrens #define	DMU_BACKUP_FEATURE_DEDUP		(1 << 0)
869c3fd121SMatthew Ahrens #define	DMU_BACKUP_FEATURE_DEDUPPROPS		(1 << 1)
879c3fd121SMatthew Ahrens #define	DMU_BACKUP_FEATURE_SA_SPILL		(1 << 2)
885d7b4d43SMatthew Ahrens /* flags #3 - #15 are reserved for incompatible closed-source implementations */
899c3fd121SMatthew Ahrens #define	DMU_BACKUP_FEATURE_EMBED_DATA		(1 << 16)
905602294fSDan Kimmel #define	DMU_BACKUP_FEATURE_LZ4			(1 << 17)
91b5152584SMatthew Ahrens /* flag #18 is reserved for a Delphix feature */
929c3fd121SMatthew Ahrens #define	DMU_BACKUP_FEATURE_LARGE_BLOCKS		(1 << 19)
939c3fd121SMatthew Ahrens #define	DMU_BACKUP_FEATURE_RESUMING		(1 << 20)
946ccda740Sloli /* flag #21 is reserved for the redacted send/receive feature */
955602294fSDan Kimmel #define	DMU_BACKUP_FEATURE_COMPRESSED		(1 << 22)
9654811da5SToomas Soome #define	DMU_BACKUP_FEATURE_LARGE_DNODE		(1 << 23)
97eb633035STom Caputi #define	DMU_BACKUP_FEATURE_RAW			(1 << 24)
98acd7f809SAllan Jude /* flag #25 is reserved for the ZSTD compression feature */
996ccda740Sloli #define	DMU_BACKUP_FEATURE_HOLDS		(1 << 26)
1009e69d7d0SLori Alt 
1019e69d7d0SLori Alt /*
1029e69d7d0SLori Alt  * Mask of all supported backup features
1039e69d7d0SLori Alt  */
1048e714474SLori Alt #define	DMU_BACKUP_FEATURE_MASK	(DMU_BACKUP_FEATURE_DEDUP | \
1055d7b4d43SMatthew Ahrens     DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL | \
1065602294fSDan Kimmel     DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_LZ4 | \
1076ccda740Sloli     DMU_BACKUP_FEATURE_RESUMING | DMU_BACKUP_FEATURE_LARGE_BLOCKS | \
1086ccda740Sloli     DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
1096ccda740Sloli     DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS)
1109e69d7d0SLori Alt 
1119e69d7d0SLori Alt /* Are all features in the given flag word currently supported? */
1129e69d7d0SLori Alt #define	DMU_STREAM_SUPPORTED(x)	(!((x) & ~DMU_BACKUP_FEATURE_MASK))
1139e69d7d0SLori Alt 
1149c3fd121SMatthew Ahrens typedef enum dmu_send_resume_token_version {
1159c3fd121SMatthew Ahrens 	ZFS_SEND_RESUME_TOKEN_VERSION = 1
1169c3fd121SMatthew Ahrens } dmu_send_resume_token_version_t;
1179c3fd121SMatthew Ahrens 
1189e69d7d0SLori Alt /*
1199e69d7d0SLori Alt  * The drr_versioninfo field of the dmu_replay_record has the
1209e69d7d0SLori Alt  * following layout:
1219e69d7d0SLori Alt  *
1229e69d7d0SLori Alt  *	64	56	48	40	32	24	16	8	0
1239e69d7d0SLori Alt  *	+-------+-------+-------+-------+-------+-------+-------+-------+
12454811da5SToomas Soome  *	|		reserved	|        feature-flags	    |C|S|
1259e69d7d0SLori Alt  *	+-------+-------+-------+-------+-------+-------+-------+-------+
1269e69d7d0SLori Alt  *
1279e69d7d0SLori Alt  * The low order two bits indicate the header type: SUBSTREAM (0x1)
1289e69d7d0SLori Alt  * or COMPOUNDSTREAM (0x2).  Using two bits for this is historical:
1299e69d7d0SLori Alt  * this field used to be a version number, where the two version types
1309e69d7d0SLori Alt  * were 1 and 2.  Using two bits for this allows earlier versions of
1319e69d7d0SLori Alt  * the code to be able to recognize send streams that don't use any
1329e69d7d0SLori Alt  * of the features indicated by feature flags.
1339e69d7d0SLori Alt  */
1349e69d7d0SLori Alt 
135fa9e4066Sahrens #define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
136fa9e4066Sahrens 
137880094b6SAndrew Stormont /*
138880094b6SAndrew Stormont  * Send stream flags.  Bits 24-31 are reserved for vendor-specific
139880094b6SAndrew Stormont  * implementations and should not be used.
140880094b6SAndrew Stormont  */
141ab04eb8eStimh #define	DRR_FLAG_CLONE		(1<<0)
142ab04eb8eStimh #define	DRR_FLAG_CI_DATA	(1<<1)
14368ecb2ecSPaul Dagnelie /*
14468ecb2ecSPaul Dagnelie  * This send stream, if it is a full send, includes the FREE and FREEOBJECT
14568ecb2ecSPaul Dagnelie  * records that are created by the sending process.  This means that the send
14668ecb2ecSPaul Dagnelie  * stream can be received as a clone, even though it is not an incremental.
14768ecb2ecSPaul Dagnelie  * This is not implemented as a feature flag, because the receiving side does
14868ecb2ecSPaul Dagnelie  * not need to have implemented it to receive this stream; it is fully backwards
14968ecb2ecSPaul Dagnelie  * compatible.  We need a flag, though, because full send streams without it
15068ecb2ecSPaul Dagnelie  * cannot necessarily be received as a clone correctly.
15168ecb2ecSPaul Dagnelie  */
15268ecb2ecSPaul Dagnelie #define	DRR_FLAG_FREERECORDS	(1<<2)
153eb633035STom Caputi /*
154eb633035STom Caputi  * When DRR_FLAG_SPILL_BLOCK is set it indicates the DRR_OBJECT_SPILL
155eb633035STom Caputi  * and DRR_SPILL_UNMODIFIED flags are meaningful in the send stream.
156eb633035STom Caputi  *
157eb633035STom Caputi  * When DRR_FLAG_SPILL_BLOCK is set, DRR_OBJECT records will have
158eb633035STom Caputi  * DRR_OBJECT_SPILL set if and only if they should have a spill block
159eb633035STom Caputi  * (either an existing one, or a new one in the send stream).  When clear
160eb633035STom Caputi  * the object does not have a spill block and any existing spill block
161eb633035STom Caputi  * should be freed.
162eb633035STom Caputi  *
163eb633035STom Caputi  * Similarly, when DRR_FLAG_SPILL_BLOCK is set, DRR_SPILL records will
164eb633035STom Caputi  * have DRR_SPILL_UNMODIFIED set if and only if they were included for
165eb633035STom Caputi  * backward compatibility purposes, and can be safely ignored by new versions
166eb633035STom Caputi  * of zfs receive.  Previous versions of ZFS which do not understand the
167eb633035STom Caputi  * DRR_FLAG_SPILL_BLOCK will process this record and recreate any missing
168eb633035STom Caputi  * spill blocks.
169eb633035STom Caputi  */
170eb633035STom Caputi #define	DRR_FLAG_SPILL_BLOCK	(1<<3)
1713cb34c60Sahrens 
1728e714474SLori Alt /*
173eb633035STom Caputi  * flags in the drr_flags field in the DRR_WRITE, DRR_SPILL, DRR_OBJECT,
174eb633035STom Caputi  * DRR_WRITE_BYREF, and DRR_OBJECT_RANGE blocks
1758e714474SLori Alt  */
1766ccda740Sloli #define	DRR_CHECKSUM_DEDUP	(1<<0) /* not used for SPILL records */
177eb633035STom Caputi #define	DRR_RAW_BYTESWAP	(1<<1)
178eb633035STom Caputi #define	DRR_OBJECT_SPILL	(1<<2) /* OBJECT record has a spill block */
179eb633035STom Caputi #define	DRR_SPILL_UNMODIFIED	(1<<2) /* SPILL record for unmodified block */
1808e714474SLori Alt 
1818e714474SLori Alt #define	DRR_IS_DEDUP_CAPABLE(flags)	((flags) & DRR_CHECKSUM_DEDUP)
182eb633035STom Caputi #define	DRR_IS_RAW_BYTESWAPPED(flags)	((flags) & DRR_RAW_BYTESWAP)
183eb633035STom Caputi #define	DRR_OBJECT_HAS_SPILL(flags)	((flags) & DRR_OBJECT_SPILL)
184eb633035STom Caputi #define	DRR_SPILL_IS_UNMODIFIED(flags)	((flags) & DRR_SPILL_UNMODIFIED)
1858e714474SLori Alt 
1865602294fSDan Kimmel /* deal with compressed drr_write replay records */
1875602294fSDan Kimmel #define	DRR_WRITE_COMPRESSED(drrw)	((drrw)->drr_compressiontype != 0)
1885602294fSDan Kimmel #define	DRR_WRITE_PAYLOAD_SIZE(drrw) \
1895602294fSDan Kimmel 	(DRR_WRITE_COMPRESSED(drrw) ? (drrw)->drr_compressed_size : \
1905602294fSDan Kimmel 	(drrw)->drr_logical_size)
191eb633035STom Caputi #define	DRR_SPILL_PAYLOAD_SIZE(drrs) \
192eb633035STom Caputi 	((drrs)->drr_compressed_size ? \
193eb633035STom Caputi 	(drrs)->drr_compressed_size : (drrs)->drr_length)
194eb633035STom Caputi #define	DRR_OBJECT_PAYLOAD_SIZE(drro) \
195eb633035STom Caputi 	((drro)->drr_raw_bonuslen != 0 ? \
196eb633035STom Caputi 	(drro)->drr_raw_bonuslen : P2ROUNDUP((drro)->drr_bonuslen, 8))
1975602294fSDan Kimmel 
198fa9e4066Sahrens /*
199fa9e4066Sahrens  * zfs ioctl command structure
200fa9e4066Sahrens  */
201fa9e4066Sahrens typedef struct dmu_replay_record {
202fa9e4066Sahrens 	enum {
203fa9e4066Sahrens 		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
2049e69d7d0SLori Alt 		DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
205eb633035STom Caputi 		DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_OBJECT_RANGE,
206eb633035STom Caputi 		DRR_NUMTYPES
207fa9e4066Sahrens 	} drr_type;
2083cb34c60Sahrens 	uint32_t drr_payloadlen;
209fa9e4066Sahrens 	union {
210fa9e4066Sahrens 		struct drr_begin {
211fa9e4066Sahrens 			uint64_t drr_magic;
2129e69d7d0SLori Alt 			uint64_t drr_versioninfo; /* was drr_version */
213fa9e4066Sahrens 			uint64_t drr_creation_time;
214fa9e4066Sahrens 			dmu_objset_type_t drr_type;
2153cb34c60Sahrens 			uint32_t drr_flags;
216fa9e4066Sahrens 			uint64_t drr_toguid;
217fa9e4066Sahrens 			uint64_t drr_fromguid;
218fa9e4066Sahrens 			char drr_toname[MAXNAMELEN];
219fa9e4066Sahrens 		} drr_begin;
220fa9e4066Sahrens 		struct drr_end {
221ea8dc4b6Seschrock 			zio_cksum_t drr_checksum;
2229e69d7d0SLori Alt 			uint64_t drr_toguid;
223fa9e4066Sahrens 		} drr_end;
224fa9e4066Sahrens 		struct drr_object {
225fa9e4066Sahrens 			uint64_t drr_object;
226fa9e4066Sahrens 			dmu_object_type_t drr_type;
227fa9e4066Sahrens 			dmu_object_type_t drr_bonustype;
228fa9e4066Sahrens 			uint32_t drr_blksz;
229fa9e4066Sahrens 			uint32_t drr_bonuslen;
2309e69d7d0SLori Alt 			uint8_t drr_checksumtype;
231fa9e4066Sahrens 			uint8_t drr_compress;
23254811da5SToomas Soome 			uint8_t drr_dn_slots;
233eb633035STom Caputi 			uint8_t drr_flags;
234eb633035STom Caputi 			uint32_t drr_raw_bonuslen;
2359e69d7d0SLori Alt 			uint64_t drr_toguid;
236eb633035STom Caputi 			/* only (possibly) nonzero for raw streams */
237eb633035STom Caputi 			uint8_t drr_indblkshift;
238eb633035STom Caputi 			uint8_t drr_nlevels;
239eb633035STom Caputi 			uint8_t drr_nblkptr;
240eb633035STom Caputi 			uint8_t drr_pad[5];
241eb633035STom Caputi 			uint64_t drr_maxblkid;
242a2eea2e1Sahrens 			/* bonus content follows */
243fa9e4066Sahrens 		} drr_object;
244fa9e4066Sahrens 		struct drr_freeobjects {
245fa9e4066Sahrens 			uint64_t drr_firstobj;
246fa9e4066Sahrens 			uint64_t drr_numobjs;
2479e69d7d0SLori Alt 			uint64_t drr_toguid;
248fa9e4066Sahrens 		} drr_freeobjects;
249fa9e4066Sahrens 		struct drr_write {
250fa9e4066Sahrens 			uint64_t drr_object;
251fa9e4066Sahrens 			dmu_object_type_t drr_type;
252fa9e4066Sahrens 			uint32_t drr_pad;
253fa9e4066Sahrens 			uint64_t drr_offset;
2545602294fSDan Kimmel 			uint64_t drr_logical_size;
2559e69d7d0SLori Alt 			uint64_t drr_toguid;
2569e69d7d0SLori Alt 			uint8_t drr_checksumtype;
257eb633035STom Caputi 			uint8_t drr_flags;
2585602294fSDan Kimmel 			uint8_t drr_compressiontype;
2595602294fSDan Kimmel 			uint8_t drr_pad2[5];
2605602294fSDan Kimmel 			/* deduplication key */
2615602294fSDan Kimmel 			ddt_key_t drr_key;
2625602294fSDan Kimmel 			/* only nonzero if drr_compressiontype is not 0 */
2635602294fSDan Kimmel 			uint64_t drr_compressed_size;
264eb633035STom Caputi 			/* only nonzero for raw streams */
265eb633035STom Caputi 			uint8_t drr_salt[ZIO_DATA_SALT_LEN];
266eb633035STom Caputi 			uint8_t drr_iv[ZIO_DATA_IV_LEN];
267eb633035STom Caputi 			uint8_t drr_mac[ZIO_DATA_MAC_LEN];
268a2eea2e1Sahrens 			/* content follows */
269fa9e4066Sahrens 		} drr_write;
270fa9e4066Sahrens 		struct drr_free {
271fa9e4066Sahrens 			uint64_t drr_object;
272fa9e4066Sahrens 			uint64_t drr_offset;
273fa9e4066Sahrens 			uint64_t drr_length;
2749e69d7d0SLori Alt 			uint64_t drr_toguid;
275fa9e4066Sahrens 		} drr_free;
2769e69d7d0SLori Alt 		struct drr_write_byref {
2779e69d7d0SLori Alt 			/* where to put the data */
2789e69d7d0SLori Alt 			uint64_t drr_object;
2799e69d7d0SLori Alt 			uint64_t drr_offset;
2809e69d7d0SLori Alt 			uint64_t drr_length;
2819e69d7d0SLori Alt 			uint64_t drr_toguid;
2829e69d7d0SLori Alt 			/* where to find the prior copy of the data */
2839e69d7d0SLori Alt 			uint64_t drr_refguid;
2849e69d7d0SLori Alt 			uint64_t drr_refobject;
2859e69d7d0SLori Alt 			uint64_t drr_refoffset;
2868e714474SLori Alt 			/* properties of the data */
2879e69d7d0SLori Alt 			uint8_t drr_checksumtype;
288eb633035STom Caputi 			uint8_t drr_flags;
2898e714474SLori Alt 			uint8_t drr_pad2[6];
2908e714474SLori Alt 			ddt_key_t drr_key; /* deduplication key */
2919e69d7d0SLori Alt 		} drr_write_byref;
2920a586ceaSMark Shellenbaum 		struct drr_spill {
2930a586ceaSMark Shellenbaum 			uint64_t drr_object;
2940a586ceaSMark Shellenbaum 			uint64_t drr_length;
2950a586ceaSMark Shellenbaum 			uint64_t drr_toguid;
296eb633035STom Caputi 			uint8_t drr_flags;
297eb633035STom Caputi 			uint8_t drr_compressiontype;
298eb633035STom Caputi 			uint8_t drr_pad[6];
299eb633035STom Caputi 			/* only nonzero for raw streams */
300eb633035STom Caputi 			uint64_t drr_compressed_size;
301eb633035STom Caputi 			uint8_t drr_salt[ZIO_DATA_SALT_LEN];
302eb633035STom Caputi 			uint8_t drr_iv[ZIO_DATA_IV_LEN];
303eb633035STom Caputi 			uint8_t drr_mac[ZIO_DATA_MAC_LEN];
304eb633035STom Caputi 			dmu_object_type_t drr_type;
3050a586ceaSMark Shellenbaum 			/* spill data follows */
3060a586ceaSMark Shellenbaum 		} drr_spill;
3075d7b4d43SMatthew Ahrens 		struct drr_write_embedded {
3085d7b4d43SMatthew Ahrens 			uint64_t drr_object;
3095d7b4d43SMatthew Ahrens 			uint64_t drr_offset;
3105d7b4d43SMatthew Ahrens 			/* logical length, should equal blocksize */
3115d7b4d43SMatthew Ahrens 			uint64_t drr_length;
3125d7b4d43SMatthew Ahrens 			uint64_t drr_toguid;
3135d7b4d43SMatthew Ahrens 			uint8_t drr_compression;
3145d7b4d43SMatthew Ahrens 			uint8_t drr_etype;
3155d7b4d43SMatthew Ahrens 			uint8_t drr_pad[6];
3165d7b4d43SMatthew Ahrens 			uint32_t drr_lsize; /* uncompressed size of payload */
3175d7b4d43SMatthew Ahrens 			uint32_t drr_psize; /* compr. (real) size of payload */
3185d7b4d43SMatthew Ahrens 			/* (possibly compressed) content follows */
3195d7b4d43SMatthew Ahrens 		} drr_write_embedded;
320eb633035STom Caputi 		struct drr_object_range {
321eb633035STom Caputi 			uint64_t drr_firstobj;
322eb633035STom Caputi 			uint64_t drr_numslots;
323eb633035STom Caputi 			uint64_t drr_toguid;
324eb633035STom Caputi 			uint8_t drr_salt[ZIO_DATA_SALT_LEN];
325eb633035STom Caputi 			uint8_t drr_iv[ZIO_DATA_IV_LEN];
326eb633035STom Caputi 			uint8_t drr_mac[ZIO_DATA_MAC_LEN];
327eb633035STom Caputi 			uint8_t drr_flags;
328eb633035STom Caputi 			uint8_t drr_pad[3];
329eb633035STom Caputi 		} drr_object_range;
33098110f08SMatthew Ahrens 
33198110f08SMatthew Ahrens 		/*
33298110f08SMatthew Ahrens 		 * Nore: drr_checksum is overlaid with all record types
33398110f08SMatthew Ahrens 		 * except DRR_BEGIN.  Therefore its (non-pad) members
33498110f08SMatthew Ahrens 		 * must not overlap with members from the other structs.
33598110f08SMatthew Ahrens 		 * We accomplish this by putting its members at the very
33698110f08SMatthew Ahrens 		 * end of the struct.
33798110f08SMatthew Ahrens 		 */
33898110f08SMatthew Ahrens 		struct drr_checksum {
33998110f08SMatthew Ahrens 			uint64_t drr_pad[34];
34098110f08SMatthew Ahrens 			/*
34198110f08SMatthew Ahrens 			 * fletcher-4 checksum of everything preceding the
34298110f08SMatthew Ahrens 			 * checksum.
34398110f08SMatthew Ahrens 			 */
34498110f08SMatthew Ahrens 			zio_cksum_t drr_checksum;
34598110f08SMatthew Ahrens 		} drr_checksum;
346fa9e4066Sahrens 	} drr_u;
347fa9e4066Sahrens } dmu_replay_record_t;
348fa9e4066Sahrens 
34999d5e173STim Haley /* diff record range types */
35099d5e173STim Haley typedef enum diff_type {
35199d5e173STim Haley 	DDR_NONE = 0x1,
35299d5e173STim Haley 	DDR_INUSE = 0x2,
35399d5e173STim Haley 	DDR_FREE = 0x4
35499d5e173STim Haley } diff_type_t;
35599d5e173STim Haley 
35699d5e173STim Haley /*
35799d5e173STim Haley  * The diff reports back ranges of free or in-use objects.
35899d5e173STim Haley  */
35999d5e173STim Haley typedef struct dmu_diff_record {
36099d5e173STim Haley 	uint64_t ddr_type;
36199d5e173STim Haley 	uint64_t ddr_first;
36299d5e173STim Haley 	uint64_t ddr_last;
36399d5e173STim Haley } dmu_diff_record_t;
36499d5e173STim Haley 
365ea8dc4b6Seschrock typedef struct zinject_record {
366ea8dc4b6Seschrock 	uint64_t	zi_objset;
367ea8dc4b6Seschrock 	uint64_t	zi_object;
368ea8dc4b6Seschrock 	uint64_t	zi_start;
369ea8dc4b6Seschrock 	uint64_t	zi_end;
370ea8dc4b6Seschrock 	uint64_t	zi_guid;
371ea8dc4b6Seschrock 	uint32_t	zi_level;
372ea8dc4b6Seschrock 	uint32_t	zi_error;
373ea8dc4b6Seschrock 	uint64_t	zi_type;
374ea8dc4b6Seschrock 	uint32_t	zi_freq;
3758956713aSEric Schrock 	uint32_t	zi_failfast;
37688ecc943SGeorge Wilson 	char		zi_func[MAXNAMELEN];
3778f18d1faSGeorge Wilson 	uint32_t	zi_iotype;
378468c413aSTim Haley 	int32_t		zi_duration;
379468c413aSTim Haley 	uint64_t	zi_timer;
38097e81309SPrakash Surya 	uint64_t	zi_nlanes;
381283b8460SGeorge.Wilson 	uint32_t	zi_cmd;
38212a8814cSTom Caputi 	uint32_t	zi_dvas;
383ea8dc4b6Seschrock } zinject_record_t;
384ea8dc4b6Seschrock 
385ea8dc4b6Seschrock #define	ZINJECT_NULL		0x1
386ea8dc4b6Seschrock #define	ZINJECT_FLUSH_ARC	0x2
387ea8dc4b6Seschrock #define	ZINJECT_UNLOAD_SPA	0x4
388*d8ab6e12SDon Brady #define	ZINJECT_CALC_RANGE	0x8
389ea8dc4b6Seschrock 
39012a8814cSTom Caputi #define	ZI_NO_DVA		(-1)
39112a8814cSTom Caputi 
392283b8460SGeorge.Wilson typedef enum zinject_type {
393283b8460SGeorge.Wilson 	ZINJECT_UNINITIALIZED,
394283b8460SGeorge.Wilson 	ZINJECT_DATA_FAULT,
395283b8460SGeorge.Wilson 	ZINJECT_DEVICE_FAULT,
396283b8460SGeorge.Wilson 	ZINJECT_LABEL_FAULT,
397283b8460SGeorge.Wilson 	ZINJECT_IGNORED_WRITES,
398283b8460SGeorge.Wilson 	ZINJECT_PANIC,
399283b8460SGeorge.Wilson 	ZINJECT_DELAY_IO,
400eb633035STom Caputi 	ZINJECT_DECRYPT_FAULT,
401283b8460SGeorge.Wilson } zinject_type_t;
402283b8460SGeorge.Wilson 
403ecd6cf80Smarks typedef struct zfs_share {
404ecd6cf80Smarks 	uint64_t	z_exportdata;
405ecd6cf80Smarks 	uint64_t	z_sharedata;
406ecd6cf80Smarks 	uint64_t	z_sharetype;	/* 0 = share, 1 = unshare */
407ecd6cf80Smarks 	uint64_t	z_sharemax;  /* max length of share string */
408ecd6cf80Smarks } zfs_share_t;
409ecd6cf80Smarks 
410de8267e0Stimh /*
411de8267e0Stimh  * ZFS file systems may behave the usual, POSIX-compliant way, where
412de8267e0Stimh  * name lookups are case-sensitive.  They may also be set up so that
413de8267e0Stimh  * all the name lookups are case-insensitive, or so that only some
414de8267e0Stimh  * lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
415de8267e0Stimh  */
416de8267e0Stimh typedef enum zfs_case {
417de8267e0Stimh 	ZFS_CASE_SENSITIVE,
418de8267e0Stimh 	ZFS_CASE_INSENSITIVE,
419de8267e0Stimh 	ZFS_CASE_MIXED
420de8267e0Stimh } zfs_case_t;
421de8267e0Stimh 
422ea4a67f4SMatthew Ahrens /*
423ea4a67f4SMatthew Ahrens  * Note: this struct must have the same layout in 32-bit and 64-bit, so
424ea4a67f4SMatthew Ahrens  * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit
425ea4a67f4SMatthew Ahrens  * kernel.  Therefore, we add padding to it so that no "hidden" padding
426ea4a67f4SMatthew Ahrens  * is automatically added on 64-bit (but not on 32-bit).
427ea4a67f4SMatthew Ahrens  */
428fa9e4066Sahrens typedef struct zfs_cmd {
4294445fffbSMatthew Ahrens 	char		zc_name[MAXPATHLEN];	/* name of pool or dataset */
4304445fffbSMatthew Ahrens 	uint64_t	zc_nvlist_src;		/* really (char *) */
4314445fffbSMatthew Ahrens 	uint64_t	zc_nvlist_src_size;
4324445fffbSMatthew Ahrens 	uint64_t	zc_nvlist_dst;		/* really (char *) */
4334445fffbSMatthew Ahrens 	uint64_t	zc_nvlist_dst_size;
4344445fffbSMatthew Ahrens 	boolean_t	zc_nvlist_dst_filled;	/* put an nvlist in dst? */
4354445fffbSMatthew Ahrens 	int		zc_pad2;
4364445fffbSMatthew Ahrens 
4374445fffbSMatthew Ahrens 	/*
4384445fffbSMatthew Ahrens 	 * The following members are for legacy ioctls which haven't been
4394445fffbSMatthew Ahrens 	 * converted to the new method.
4404445fffbSMatthew Ahrens 	 */
4414445fffbSMatthew Ahrens 	uint64_t	zc_history;		/* really (char *) */
44255434c77Sek 	char		zc_value[MAXPATHLEN * 2];
4433cb34c60Sahrens 	char		zc_string[MAXNAMELEN];
444ea8dc4b6Seschrock 	uint64_t	zc_guid;
445990b4856Slling 	uint64_t	zc_nvlist_conf;		/* really (char *) */
446990b4856Slling 	uint64_t	zc_nvlist_conf_size;
447fa9e4066Sahrens 	uint64_t	zc_cookie;
448fa9e4066Sahrens 	uint64_t	zc_objset_type;
449ecd6cf80Smarks 	uint64_t	zc_perm_action;
4504445fffbSMatthew Ahrens 	uint64_t	zc_history_len;
45106eeb2adSek 	uint64_t	zc_history_offset;
45255434c77Sek 	uint64_t	zc_obj;
453478ed9adSEric Taylor 	uint64_t	zc_iflags;		/* internal to zfs(7fs) */
454ecd6cf80Smarks 	zfs_share_t	zc_share;
455fa9e4066Sahrens 	dmu_objset_stats_t zc_objset_stats;
4569c3fd121SMatthew Ahrens 	dmu_replay_record_t zc_begin_record;
457ea8dc4b6Seschrock 	zinject_record_t zc_inject_record;
4585d7b4d43SMatthew Ahrens 	uint32_t	zc_defer_destroy;
4595d7b4d43SMatthew Ahrens 	uint32_t	zc_flags;
460c99e4bdcSChris Kirby 	uint64_t	zc_action_handle;
461c99e4bdcSChris Kirby 	int		zc_cleanup_fd;
4620d8fa8f8SMartin Matuska 	uint8_t		zc_simple;
463ea4a67f4SMatthew Ahrens 	uint8_t		zc_pad3[3];
4649c3fd121SMatthew Ahrens 	boolean_t	zc_resumable;
465ea4a67f4SMatthew Ahrens 	uint32_t	zc_pad4;
466a7f53a56SChris Kirby 	uint64_t	zc_sendobj;
467a7f53a56SChris Kirby 	uint64_t	zc_fromobj;
468a7f53a56SChris Kirby 	uint64_t	zc_createtxg;
46999d5e173STim Haley 	zfs_stat_t	zc_stat;
470fa9e4066Sahrens } zfs_cmd_t;
471fa9e4066Sahrens 
47214843421SMatthew Ahrens typedef struct zfs_useracct {
47314843421SMatthew Ahrens 	char zu_domain[256];
47414843421SMatthew Ahrens 	uid_t zu_rid;
47514843421SMatthew Ahrens 	uint32_t zu_pad;
47614843421SMatthew Ahrens 	uint64_t zu_space;
47714843421SMatthew Ahrens } zfs_useracct_t;
47814843421SMatthew Ahrens 
479c99e4bdcSChris Kirby #define	ZFSDEV_MAX_MINOR	(1 << 16)
480c99e4bdcSChris Kirby #define	ZFS_MIN_MINOR	(ZFSDEV_MAX_MINOR + 1)
481a0965f35Sbonwick 
4821195e687SMark J Musante #define	ZPOOL_EXPORT_AFTER_SPLIT 0x1
4831195e687SMark J Musante 
484fa9e4066Sahrens #ifdef _KERNEL
485dfc11533SChris Williamson struct objset;
486dfc11533SChris Williamson struct zfsvfs;
487fa9e4066Sahrens 
488da6c28aaSamw typedef struct zfs_creat {
489de8267e0Stimh 	nvlist_t	*zct_zplprops;
490da6c28aaSamw 	nvlist_t	*zct_props;
491da6c28aaSamw } zfs_creat_t;
492da6c28aaSamw 
493fa9e4066Sahrens extern dev_info_t *zfs_dip;
494fa9e4066Sahrens 
495dfc11533SChris Williamson extern int zfs_secpolicy_snapshot_perms(const char *, cred_t *);
496dfc11533SChris Williamson extern int zfs_secpolicy_rename_perms(const char *, const char *, cred_t *);
497dfc11533SChris Williamson extern int zfs_secpolicy_destroy_perms(const char *, cred_t *);
498fa9e4066Sahrens extern int zfs_busy(void);
499ed992b0aSSerapheim Dimitropoulos extern void zfs_unmount_snap(const char *);
5003b2aab18SMatthew Ahrens extern void zfs_destroy_unmount_origin(const char *);
501dfc11533SChris Williamson extern int getzfsvfs_impl(struct objset *, struct zfsvfs **);
502ed992b0aSSerapheim Dimitropoulos extern int getzfsvfs(const char *, struct zfsvfs **);
503fa9e4066Sahrens 
504c99e4bdcSChris Kirby /*
505c99e4bdcSChris Kirby  * ZFS minor numbers can refer to either a control device instance or
506c99e4bdcSChris Kirby  * a zvol. Depending on the value of zss_type, zss_data points to either
507c99e4bdcSChris Kirby  * a zvol_state_t or a zfs_onexit_t.
508c99e4bdcSChris Kirby  */
509c99e4bdcSChris Kirby enum zfs_soft_state_type {
510c99e4bdcSChris Kirby 	ZSST_ZVOL,
511c99e4bdcSChris Kirby 	ZSST_CTLDEV
512c99e4bdcSChris Kirby };
513c99e4bdcSChris Kirby 
514c99e4bdcSChris Kirby typedef struct zfs_soft_state {
515c99e4bdcSChris Kirby 	enum zfs_soft_state_type zss_type;
516c99e4bdcSChris Kirby 	void *zss_data;
517c99e4bdcSChris Kirby } zfs_soft_state_t;
518c99e4bdcSChris Kirby 
519c99e4bdcSChris Kirby extern void *zfsdev_get_soft_state(minor_t minor,
520c99e4bdcSChris Kirby     enum zfs_soft_state_type which);
521c99e4bdcSChris Kirby extern minor_t zfsdev_minor_alloc(void);
522c99e4bdcSChris Kirby 
523c99e4bdcSChris Kirby extern void *zfsdev_state;
524c99e4bdcSChris Kirby extern kmutex_t zfsdev_state_lock;
525c99e4bdcSChris Kirby 
526fa9e4066Sahrens #endif	/* _KERNEL */
527fa9e4066Sahrens 
528fa9e4066Sahrens #ifdef	__cplusplus
529fa9e4066Sahrens }
530fa9e4066Sahrens #endif
531fa9e4066Sahrens 
532fa9e4066Sahrens #endif	/* _SYS_ZFS_IOCTL_H */
533