1fa9e406ahrens/*
2fa9e406ahrens * CDDL HEADER START
3fa9e406ahrens *
4fa9e406ahrens * The contents of this file are subject to the terms of the
5ea8dc4beschrock * Common Development and Distribution License (the "License").
6ea8dc4beschrock * You may not use this file except in compliance with the License.
7fa9e406ahrens *
8fa9e406ahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fa9e406ahrens * or http://www.opensolaris.org/os/licensing.
10fa9e406ahrens * See the License for the specific language governing permissions
11fa9e406ahrens * and limitations under the License.
12fa9e406ahrens *
13fa9e406ahrens * When distributing Covered Code, include this CDDL HEADER in each
14fa9e406ahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fa9e406ahrens * If applicable, add the following below this CDDL HEADER, with the
16fa9e406ahrens * fields enclosed by brackets "[]" replaced with your own identifying
17fa9e406ahrens * information: Portions Copyright [yyyy] [name of copyright owner]
18fa9e406ahrens *
19fa9e406ahrens * CDDL HEADER END
20fa9e406ahrens */
21fa9e406ahrens/*
22c99e4bdChris Kirby * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
230d8fa8fMartin Matuska * Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
24ed992b0Serapheim Dimitropoulos * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
25880094bAndrew Stormont * Copyright 2016 RackTop Systems.
26c3d26abMatthew Ahrens * Copyright (c) 2014 Integros [integros.com]
27b853d39Don Brady * Copyright (c) 2017, Intel Corporation.
28fa9e406ahrens */
29fa9e406ahrens
30fa9e406ahrens#ifndef	_SYS_ZFS_IOCTL_H
31fa9e406ahrens#define	_SYS_ZFS_IOCTL_H
32fa9e406ahrens
33fa9e406ahrens#include <sys/cred.h>
34fa9e406ahrens#include <sys/dmu.h>
35ea8dc4beschrock#include <sys/zio.h>
36ecd6cf8marks#include <sys/dsl_deleg.h>
379e69d7dLori Alt#include <sys/spa.h>
3899d5e17Tim Haley#include <sys/zfs_stat.h>
39fa9e406ahrens
40da6c28aamw#ifdef _KERNEL
41da6c28aamw#include <sys/nvpair.h>
42da6c28aamw#endif	/* _KERNEL */
43da6c28aamw
44fa9e406ahrens#ifdef	__cplusplus
45fa9e406ahrensextern "C" {
46fa9e406ahrens#endif
47fa9e406ahrens
48fa9e406ahrens/*
494445fffMatthew Ahrens * The structures in this file are passed between userland and the
504445fffMatthew Ahrens * kernel.  Userland may be running a 32-bit process, while the kernel
514445fffMatthew Ahrens * is 64-bit.  Therefore, these structures need to compile the same in
524445fffMatthew Ahrens * 32-bit and 64-bit.  This means not using type "long", and adding
534445fffMatthew Ahrens * explicit padding so that the 32-bit structure will not be packed more
544445fffMatthew Ahrens * tightly than the 64-bit structure (which requires 64-bit alignment).
554445fffMatthew Ahrens */
564445fffMatthew Ahrens
574445fffMatthew Ahrens/*
58fa9e406ahrens * Property values for snapdir
59fa9e406ahrens */
60a0965f3bonwick#define	ZFS_SNAPDIR_HIDDEN		0
61a0965f3bonwick#define	ZFS_SNAPDIR_VISIBLE		1
62fa9e406ahrens
639e69d7dLori Alt/*
649e69d7dLori Alt * Field manipulation macros for the drr_versioninfo field of the
659e69d7dLori Alt * send stream header.
669e69d7dLori Alt */
679e69d7dLori Alt
689e69d7dLori Alt/*
699e69d7dLori Alt * Header types for zfs send streams.
709e69d7dLori Alt */
719e69d7dLori Alttypedef enum drr_headertype {
729e69d7dLori Alt	DMU_SUBSTREAM = 0x1,
739e69d7dLori Alt	DMU_COMPOUNDSTREAM = 0x2
749e69d7dLori Alt} drr_headertype_t;
759e69d7dLori Alt
769e69d7dLori Alt#define	DMU_GET_STREAM_HDRTYPE(vi)	BF64_GET((vi), 0, 2)
779e69d7dLori Alt#define	DMU_SET_STREAM_HDRTYPE(vi, x)	BF64_SET((vi), 0, 2, x)
789e69d7dLori Alt
799e69d7dLori Alt#define	DMU_GET_FEATUREFLAGS(vi)	BF64_GET((vi), 2, 30)
809e69d7dLori Alt#define	DMU_SET_FEATUREFLAGS(vi, x)	BF64_SET((vi), 2, 30, x)
819e69d7dLori Alt
829e69d7dLori Alt/*
839e69d7dLori Alt * Feature flags for zfs send streams (flags in drr_versioninfo)
849e69d7dLori Alt */
859e69d7dLori Alt
869c3fd12Matthew Ahrens#define	DMU_BACKUP_FEATURE_DEDUP		(1 << 0)
879c3fd12Matthew Ahrens#define	DMU_BACKUP_FEATURE_DEDUPPROPS		(1 << 1)
889c3fd12Matthew Ahrens#define	DMU_BACKUP_FEATURE_SA_SPILL		(1 << 2)
895d7b4d4Matthew Ahrens/* flags #3 - #15 are reserved for incompatible closed-source implementations */
909c3fd12Matthew Ahrens#define	DMU_BACKUP_FEATURE_EMBED_DATA		(1 << 16)
915602294Dan Kimmel#define	DMU_BACKUP_FEATURE_LZ4			(1 << 17)
92b515258Matthew Ahrens/* flag #18 is reserved for a Delphix feature */
939c3fd12Matthew Ahrens#define	DMU_BACKUP_FEATURE_LARGE_BLOCKS		(1 << 19)
949c3fd12Matthew Ahrens#define	DMU_BACKUP_FEATURE_RESUMING		(1 << 20)
956ccda74loli/* flag #21 is reserved for the redacted send/receive feature */
965602294Dan Kimmel#define	DMU_BACKUP_FEATURE_COMPRESSED		(1 << 22)
9754811daToomas Soome#define	DMU_BACKUP_FEATURE_LARGE_DNODE		(1 << 23)
98eb63303Tom Caputi#define	DMU_BACKUP_FEATURE_RAW			(1 << 24)
99acd7f80Allan Jude/* flag #25 is reserved for the ZSTD compression feature */
1006ccda74loli#define	DMU_BACKUP_FEATURE_HOLDS		(1 << 26)
1019e69d7dLori Alt
1029e69d7dLori Alt/*
1039e69d7dLori Alt * Mask of all supported backup features
1049e69d7dLori Alt */
1058e71447Lori Alt#define	DMU_BACKUP_FEATURE_MASK	(DMU_BACKUP_FEATURE_DEDUP | \
1065d7b4d4Matthew Ahrens    DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL | \
1075602294Dan Kimmel    DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_LZ4 | \
1086ccda74loli    DMU_BACKUP_FEATURE_RESUMING | DMU_BACKUP_FEATURE_LARGE_BLOCKS | \
1096ccda74loli    DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
1106ccda74loli    DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS)
1119e69d7dLori Alt
1129e69d7dLori Alt/* Are all features in the given flag word currently supported? */
1139e69d7dLori Alt#define	DMU_STREAM_SUPPORTED(x)	(!((x) & ~DMU_BACKUP_FEATURE_MASK))
1149e69d7dLori Alt
1159c3fd12Matthew Ahrenstypedef enum dmu_send_resume_token_version {
1169c3fd12Matthew Ahrens	ZFS_SEND_RESUME_TOKEN_VERSION = 1
1179c3fd12Matthew Ahrens} dmu_send_resume_token_version_t;
1189c3fd12Matthew Ahrens
1199e69d7dLori Alt/*
1209e69d7dLori Alt * The drr_versioninfo field of the dmu_replay_record has the
1219e69d7dLori Alt * following layout:
1229e69d7dLori Alt *
1239e69d7dLori Alt *	64	56	48	40	32	24	16	8	0
1249e69d7dLori Alt *	+-------+-------+-------+-------+-------+-------+-------+-------+
12554811daToomas Soome *	|		reserved	|        feature-flags	    |C|S|
1269e69d7dLori Alt *	+-------+-------+-------+-------+-------+-------+-------+-------+
1279e69d7dLori Alt *
1289e69d7dLori Alt * The low order two bits indicate the header type: SUBSTREAM (0x1)
1299e69d7dLori Alt * or COMPOUNDSTREAM (0x2).  Using two bits for this is historical:
1309e69d7dLori Alt * this field used to be a version number, where the two version types
1319e69d7dLori Alt * were 1 and 2.  Using two bits for this allows earlier versions of
1329e69d7dLori Alt * the code to be able to recognize send streams that don't use any
1339e69d7dLori Alt * of the features indicated by feature flags.
1349e69d7dLori Alt */
1359e69d7dLori Alt
136fa9e406ahrens#define	DMU_BACKUP_MAGIC 0x2F5bacbacULL
137fa9e406ahrens
138880094bAndrew Stormont/*
139880094bAndrew Stormont * Send stream flags.  Bits 24-31 are reserved for vendor-specific
140880094bAndrew Stormont * implementations and should not be used.
141880094bAndrew Stormont */
142ab04eb8timh#define	DRR_FLAG_CLONE		(1<<0)
143ab04eb8timh#define	DRR_FLAG_CI_DATA	(1<<1)
14468ecb2ePaul Dagnelie/*
14568ecb2ePaul Dagnelie * This send stream, if it is a full send, includes the FREE and FREEOBJECT
14668ecb2ePaul Dagnelie * records that are created by the sending process.  This means that the send
14768ecb2ePaul Dagnelie * stream can be received as a clone, even though it is not an incremental.
14868ecb2ePaul Dagnelie * This is not implemented as a feature flag, because the receiving side does
14968ecb2ePaul Dagnelie * not need to have implemented it to receive this stream; it is fully backwards
15068ecb2ePaul Dagnelie * compatible.  We need a flag, though, because full send streams without it
15168ecb2ePaul Dagnelie * cannot necessarily be received as a clone correctly.
15268ecb2ePaul Dagnelie */
15368ecb2ePaul Dagnelie#define	DRR_FLAG_FREERECORDS	(1<<2)
154eb63303Tom Caputi/*
155eb63303Tom Caputi * When DRR_FLAG_SPILL_BLOCK is set it indicates the DRR_OBJECT_SPILL
156eb63303Tom Caputi * and DRR_SPILL_UNMODIFIED flags are meaningful in the send stream.
157eb63303Tom Caputi *
158eb63303Tom Caputi * When DRR_FLAG_SPILL_BLOCK is set, DRR_OBJECT records will have
159eb63303Tom Caputi * DRR_OBJECT_SPILL set if and only if they should have a spill block
160eb63303Tom Caputi * (either an existing one, or a new one in the send stream).  When clear
161eb63303Tom Caputi * the object does not have a spill block and any existing spill block
162eb63303Tom Caputi * should be freed.
163eb63303Tom Caputi *
164eb63303Tom Caputi * Similarly, when DRR_FLAG_SPILL_BLOCK is set, DRR_SPILL records will
165eb63303Tom Caputi * have DRR_SPILL_UNMODIFIED set if and only if they were included for
166eb63303Tom Caputi * backward compatibility purposes, and can be safely ignored by new versions
167eb63303Tom Caputi * of zfs receive.  Previous versions of ZFS which do not understand the
168eb63303Tom Caputi * DRR_FLAG_SPILL_BLOCK will process this record and recreate any missing
169eb63303Tom Caputi * spill blocks.
170eb63303Tom Caputi */
171eb63303Tom Caputi#define	DRR_FLAG_SPILL_BLOCK	(1<<3)
1723cb34c6ahrens
173fa9e406ahrens/*
174eb63303Tom Caputi * flags in the drr_flags field in the DRR_WRITE, DRR_SPILL, DRR_OBJECT,
175eb63303Tom Caputi * DRR_WRITE_BYREF, and DRR_OBJECT_RANGE blocks
1768e71447Lori Alt */
1776ccda74loli#define	DRR_CHECKSUM_DEDUP	(1<<0) /* not used for SPILL records */
178eb63303Tom Caputi#define	DRR_RAW_BYTESWAP	(1<<1)
179eb63303Tom Caputi#define	DRR_OBJECT_SPILL	(1<<2) /* OBJECT record has a spill block */
180eb63303Tom Caputi#define	DRR_SPILL_UNMODIFIED	(1<<2) /* SPILL record for unmodified block */
1818e71447Lori Alt
1828e71447Lori Alt#define	DRR_IS_DEDUP_CAPABLE(flags)	((flags) & DRR_CHECKSUM_DEDUP)
183eb63303Tom Caputi#define	DRR_IS_RAW_BYTESWAPPED(flags)	((flags) & DRR_RAW_BYTESWAP)
184eb63303Tom Caputi#define	DRR_OBJECT_HAS_SPILL(flags)	((flags) & DRR_OBJECT_SPILL)
185eb63303Tom Caputi#define	DRR_SPILL_IS_UNMODIFIED(flags)	((flags) & DRR_SPILL_UNMODIFIED)
1868e71447Lori Alt
1875602294Dan Kimmel/* deal with compressed drr_write replay records */
1885602294Dan Kimmel#define	DRR_WRITE_COMPRESSED(drrw)	((drrw)->drr_compressiontype != 0)
1895602294Dan Kimmel#define	DRR_WRITE_PAYLOAD_SIZE(drrw) \
1905602294Dan Kimmel	(DRR_WRITE_COMPRESSED(drrw) ? (drrw)->drr_compressed_size : \
1915602294Dan Kimmel	(drrw)->drr_logical_size)
192eb63303Tom Caputi#define	DRR_SPILL_PAYLOAD_SIZE(drrs) \
193eb63303Tom Caputi	((drrs)->drr_compressed_size ? \
194eb63303Tom Caputi	(drrs)->drr_compressed_size : (drrs)->drr_length)
195eb63303Tom Caputi#define	DRR_OBJECT_PAYLOAD_SIZE(drro) \
196eb63303Tom Caputi	((drro)->drr_raw_bonuslen != 0 ? \
197eb63303Tom Caputi	(drro)->drr_raw_bonuslen : P2ROUNDUP((drro)->drr_bonuslen, 8))
1985602294Dan Kimmel
1998e71447Lori Alt/*
200fa9e406ahrens * zfs ioctl command structure
201fa9e406ahrens */
202fa9e406ahrenstypedef struct dmu_replay_record {
203fa9e406ahrens	enum {
204fa9e406ahrens		DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
2059e69d7dLori Alt		DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
206eb63303Tom Caputi		DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_OBJECT_RANGE,
207eb63303Tom Caputi		DRR_NUMTYPES
208fa9e406ahrens	} drr_type;
2093cb34c6ahrens	uint32_t drr_payloadlen;
210fa9e406ahrens	union {
211fa9e406ahrens		struct drr_begin {
212fa9e406ahrens			uint64_t drr_magic;
2139e69d7dLori Alt			uint64_t drr_versioninfo; /* was drr_version */
214fa9e406ahrens			uint64_t drr_creation_time;
215fa9e406ahrens			dmu_objset_type_t drr_type;
2163cb34c6ahrens			uint32_t drr_flags;
217fa9e406ahrens			uint64_t drr_toguid;
218fa9e406ahrens			uint64_t drr_fromguid;
219fa9e406ahrens			char drr_toname[MAXNAMELEN];
220fa9e406ahrens		} drr_begin;
221fa9e406ahrens		struct drr_end {
222ea8dc4beschrock			zio_cksum_t drr_checksum;
2239e69d7dLori Alt			uint64_t drr_toguid;
224fa9e406ahrens		} drr_end;
225fa9e406ahrens		struct drr_object {
226fa9e406ahrens			uint64_t drr_object;
227fa9e406ahrens			dmu_object_type_t drr_type;
228fa9e406ahrens			dmu_object_type_t drr_bonustype;
229fa9e406ahrens			uint32_t drr_blksz;
230fa9e406ahrens			uint32_t drr_bonuslen;
2319e69d7dLori Alt			uint8_t drr_checksumtype;
232fa9e406ahrens			uint8_t drr_compress;
23354811daToomas Soome			uint8_t drr_dn_slots;
234eb63303Tom Caputi			uint8_t drr_flags;
235eb63303Tom Caputi			uint32_t drr_raw_bonuslen;
2369e69d7dLori Alt			uint64_t drr_toguid;
237eb63303Tom Caputi			/* only (possibly) nonzero for raw streams */
238eb63303Tom Caputi			uint8_t drr_indblkshift;
239eb63303Tom Caputi			uint8_t drr_nlevels;
240eb63303Tom Caputi			uint8_t drr_nblkptr;
241eb63303Tom Caputi			uint8_t drr_pad[5];
242eb63303Tom Caputi			uint64_t drr_maxblkid;
243a2eea2eahrens			/* bonus content follows */
244fa9e406ahrens		} drr_object;
245fa9e406ahrens		struct drr_freeobjects {
246fa9e406ahrens			uint64_t drr_firstobj;
247fa9e406ahrens			uint64_t drr_numobjs;
2489e69d7dLori Alt			uint64_t drr_toguid;
249fa9e406ahrens		} drr_freeobjects;
250fa9e406ahrens		struct drr_write {
251fa9e406ahrens			uint64_t drr_object;
252fa9e406ahrens			dmu_object_type_t drr_type;
253fa9e406ahrens			uint32_t drr_pad;
254fa9e406ahrens			uint64_t drr_offset;
2555602294Dan Kimmel			uint64_t drr_logical_size;
2569e69d7dLori Alt			uint64_t drr_toguid;
2579e69d7dLori Alt			uint8_t drr_checksumtype;
258eb63303Tom Caputi			uint8_t drr_flags;
2595602294Dan Kimmel			uint8_t drr_compressiontype;
2605602294Dan Kimmel			uint8_t drr_pad2[5];
2615602294Dan Kimmel			/* deduplication key */
2625602294Dan Kimmel			ddt_key_t drr_key;
2635602294Dan Kimmel			/* only nonzero if drr_compressiontype is not 0 */
2645602294Dan Kimmel			uint64_t drr_compressed_size;
265eb63303Tom Caputi			/* only nonzero for raw streams */
266eb63303Tom Caputi			uint8_t drr_salt[ZIO_DATA_SALT_LEN];
267eb63303Tom Caputi			uint8_t drr_iv[ZIO_DATA_IV_LEN];
268eb63303Tom Caputi			uint8_t drr_mac[ZIO_DATA_MAC_LEN];
269a2eea2eahrens			/* content follows */
270fa9e406ahrens		} drr_write;
271fa9e406ahrens		struct drr_free {
272fa9e406ahrens			uint64_t drr_object;
273fa9e406ahrens			uint64_t drr_offset;
274fa9e406ahrens			uint64_t drr_length;
2759e69d7dLori Alt			uint64_t drr_toguid;
276fa9e406ahrens		} drr_free;
2779e69d7dLori Alt		struct drr_write_byref {
2789e69d7dLori Alt			/* where to put the data */
2799e69d7dLori Alt			uint64_t drr_object;
2809e69d7dLori Alt			uint64_t drr_offset;
2819e69d7dLori Alt			uint64_t drr_length;
2829e69d7dLori Alt			uint64_t drr_toguid;
2839e69d7dLori Alt			/* where to find the prior copy of the data */
2849e69d7dLori Alt			uint64_t drr_refguid;
2859e69d7dLori Alt			uint64_t drr_refobject;
2869e69d7dLori Alt			uint64_t drr_refoffset;
2878e71447Lori Alt			/* properties of the data */
2889e69d7dLori Alt			uint8_t drr_checksumtype;
289eb63303Tom Caputi			uint8_t drr_flags;
2908e71447Lori Alt			uint8_t drr_pad2[6];
2918e71447Lori Alt			ddt_key_t drr_key; /* deduplication key */
2929e69d7dLori Alt		} drr_write_byref;
2930a586ceMark Shellenbaum		struct drr_spill {
2940a586ceMark Shellenbaum			uint64_t drr_object;
2950a586ceMark Shellenbaum			uint64_t drr_length;
2960a586ceMark Shellenbaum			uint64_t drr_toguid;
297eb63303Tom Caputi			uint8_t drr_flags;
298eb63303Tom Caputi			uint8_t drr_compressiontype;
299eb63303Tom Caputi			uint8_t drr_pad[6];
300eb63303Tom Caputi			/* only nonzero for raw streams */
301eb63303Tom Caputi			uint64_t drr_compressed_size;
302eb63303Tom Caputi			uint8_t drr_salt[ZIO_DATA_SALT_LEN];
303eb63303Tom Caputi			uint8_t drr_iv[ZIO_DATA_IV_LEN];
304eb63303Tom Caputi			uint8_t drr_mac[ZIO_DATA_MAC_LEN];
305eb63303Tom Caputi			dmu_object_type_t drr_type;
3060a586ceMark Shellenbaum			/* spill data follows */
3070a586ceMark Shellenbaum		} drr_spill;
3085d7b4d4Matthew Ahrens		struct drr_write_embedded {
3095d7b4d4Matthew Ahrens			uint64_t drr_object;
3105d7b4d4Matthew Ahrens			uint64_t drr_offset;
3115d7b4d4Matthew Ahrens			/* logical length, should equal blocksize */
3125d7b4d4Matthew Ahrens			uint64_t drr_length;
3135d7b4d4Matthew Ahrens			uint64_t drr_toguid;
3145d7b4d4Matthew Ahrens			uint8_t drr_compression;
3155d7b4d4Matthew Ahrens			uint8_t drr_etype;
3165d7b4d4Matthew Ahrens			uint8_t drr_pad[6];
3175d7b4d4Matthew Ahrens			uint32_t drr_lsize; /* uncompressed size of payload */
3185d7b4d4Matthew Ahrens			uint32_t drr_psize; /* compr. (real) size of payload */
3195d7b4d4Matthew Ahrens			/* (possibly compressed) content follows */
3205d7b4d4Matthew Ahrens		} drr_write_embedded;
321eb63303Tom Caputi		struct drr_object_range {
322eb63303Tom Caputi			uint64_t drr_firstobj;
323eb63303Tom Caputi			uint64_t drr_numslots;
324eb63303Tom Caputi			uint64_t drr_toguid;
325eb63303Tom Caputi			uint8_t drr_salt[ZIO_DATA_SALT_LEN];
326eb63303Tom Caputi			uint8_t drr_iv[ZIO_DATA_IV_LEN];
327eb63303Tom Caputi			uint8_t drr_mac[ZIO_DATA_MAC_LEN];
328eb63303Tom Caputi			uint8_t drr_flags;
329eb63303Tom Caputi			uint8_t drr_pad[3];
330eb63303Tom Caputi		} drr_object_range;
33198110f0Matthew Ahrens
33298110f0Matthew Ahrens		/*
33398110f0Matthew Ahrens		 * Nore: drr_checksum is overlaid with all record types
33498110f0Matthew Ahrens		 * except DRR_BEGIN.  Therefore its (non-pad) members
33598110f0Matthew Ahrens		 * must not overlap with members from the other structs.
33698110f0Matthew Ahrens		 * We accomplish this by putting its members at the very
33798110f0Matthew Ahrens		 * end of the struct.
33898110f0Matthew Ahrens		 */
33998110f0Matthew Ahrens		struct drr_checksum {
34098110f0Matthew Ahrens			uint64_t drr_pad[34];
34198110f0Matthew Ahrens			/*
34298110f0Matthew Ahrens			 * fletcher-4 checksum of everything preceding the
34398110f0Matthew Ahrens			 * checksum.
34498110f0Matthew Ahrens			 */
34598110f0Matthew Ahrens			zio_cksum_t drr_checksum;
34698110f0Matthew Ahrens		} drr_checksum;
347fa9e406ahrens	} drr_u;
348fa9e406ahrens} dmu_replay_record_t;
349fa9e406ahrens
35099d5e17Tim Haley/* diff record range types */
35199d5e17Tim Haleytypedef enum diff_type {
35299d5e17Tim Haley	DDR_NONE = 0x1,
35399d5e17Tim Haley	DDR_INUSE = 0x2,
35499d5e17Tim Haley	DDR_FREE = 0x4
35599d5e17Tim Haley} diff_type_t;
35699d5e17Tim Haley
35799d5e17Tim Haley/*
35899d5e17Tim Haley * The diff reports back ranges of free or in-use objects.
35999d5e17Tim Haley */
36099d5e17Tim Haleytypedef struct dmu_diff_record {
36199d5e17Tim Haley	uint64_t ddr_type;
36299d5e17Tim Haley	uint64_t ddr_first;
36399d5e17Tim Haley	uint64_t ddr_last;
36499d5e17Tim Haley} dmu_diff_record_t;
36599d5e17Tim Haley
366ea8dc4beschrocktypedef struct zinject_record {
367ea8dc4beschrock	uint64_t	zi_objset;
368ea8dc4beschrock	uint64_t	zi_object;
369ea8dc4beschrock	uint64_t	zi_start;
370ea8dc4beschrock	uint64_t	zi_end;
371ea8dc4beschrock	uint64_t	zi_guid;
372ea8dc4beschrock	uint32_t	zi_level;
373ea8dc4beschrock	uint32_t	zi_error;
374ea8dc4beschrock	uint64_t	zi_type;
375ea8dc4beschrock	uint32_t	zi_freq;
3768956713Eric Schrock	uint32_t	zi_failfast;
37788ecc94George Wilson	char		zi_func[MAXNAMELEN];
3788f18d1fGeorge Wilson	uint32_t	zi_iotype;
379468c413Tim Haley	int32_t		zi_duration;
380468c413Tim Haley	uint64_t	zi_timer;
38197e8130Prakash Surya	uint64_t	zi_nlanes;
382283b846George.Wilson	uint32_t	zi_cmd;
38312a8814Tom Caputi	uint32_t	zi_dvas;
384ea8dc4beschrock} zinject_record_t;
385ea8dc4beschrock
386ea8dc4beschrock#define	ZINJECT_NULL		0x1
387ea8dc4beschrock#define	ZINJECT_FLUSH_ARC	0x2
388ea8dc4beschrock#define	ZINJECT_UNLOAD_SPA	0x4
389d8ab6e1Don Brady#define	ZINJECT_CALC_RANGE	0x8
390ea8dc4beschrock
39112a8814Tom Caputi#define	ZI_NO_DVA		(-1)
39212a8814Tom Caputi
393b853d39Don Brady/* scaled frequency ranges */
394b853d39Don Brady#define	ZI_PERCENTAGE_MIN	4294UL
395b853d39Don Brady#define	ZI_PERCENTAGE_MAX	UINT32_MAX
396b853d39Don Brady
397283b846George.Wilsontypedef enum zinject_type {
398283b846George.Wilson	ZINJECT_UNINITIALIZED,
399283b846George.Wilson	ZINJECT_DATA_FAULT,
400283b846George.Wilson	ZINJECT_DEVICE_FAULT,
401283b846George.Wilson	ZINJECT_LABEL_FAULT,
402283b846George.Wilson	ZINJECT_IGNORED_WRITES,
403283b846George.Wilson	ZINJECT_PANIC,
404283b846George.Wilson	ZINJECT_DELAY_IO,
405eb63303Tom Caputi	ZINJECT_DECRYPT_FAULT,
406283b846George.Wilson} zinject_type_t;
407283b846George.Wilson
408ecd6cf8markstypedef struct zfs_share {
409ecd6cf8marks	uint64_t	z_exportdata;
410ecd6cf8marks	uint64_t	z_sharedata;
411ecd6cf8marks	uint64_t	z_sharetype;	/* 0 = share, 1 = unshare */
412ecd6cf8marks	uint64_t	z_sharemax;  /* max length of share string */
413ecd6cf8marks} zfs_share_t;
414ecd6cf8marks
415de8267etimh/*
416de8267etimh * ZFS file systems may behave the usual, POSIX-compliant way, where
417de8267etimh * name lookups are case-sensitive.  They may also be set up so that
418de8267etimh * all the name lookups are case-insensitive, or so that only some
419de8267etimh * lookups, the ones that set an FIGNORECASE flag, are case-insensitive.
420de8267etimh */
421de8267etimhtypedef enum zfs_case {
422de8267etimh	ZFS_CASE_SENSITIVE,
423de8267etimh	ZFS_CASE_INSENSITIVE,
424de8267etimh	ZFS_CASE_MIXED
425de8267etimh} zfs_case_t;
426de8267etimh
427ea4a67fMatthew Ahrens/*
428ea4a67fMatthew Ahrens * Note: this struct must have the same layout in 32-bit and 64-bit, so
429ea4a67fMatthew Ahrens * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit
430ea4a67fMatthew Ahrens * kernel.  Therefore, we add padding to it so that no "hidden" padding
431ea4a67fMatthew Ahrens * is automatically added on 64-bit (but not on 32-bit).
432ea4a67fMatthew Ahrens */
433fa9e406ahrenstypedef struct zfs_cmd {
4344445fffMatthew Ahrens	char		zc_name[MAXPATHLEN];	/* name of pool or dataset */
4354445fffMatthew Ahrens	uint64_t	zc_nvlist_src;		/* really (char *) */
4364445fffMatthew Ahrens	uint64_t	zc_nvlist_src_size;
4374445fffMatthew Ahrens	uint64_t	zc_nvlist_dst;		/* really (char *) */
4384445fffMatthew Ahrens	uint64_t	zc_nvlist_dst_size;
4394445fffMatthew Ahrens	boolean_t	zc_nvlist_dst_filled;	/* put an nvlist in dst? */
4404445fffMatthew Ahrens	int		zc_pad2;
4414445fffMatthew Ahrens
4424445fffMatthew Ahrens	/*
4434445fffMatthew Ahrens	 * The following members are for legacy ioctls which haven't been
4444445fffMatthew Ahrens	 * converted to the new method.
4454445fffMatthew Ahrens	 */
4464445fffMatthew Ahrens	uint64_t	zc_history;		/* really (char *) */
44755434c7ek	char		zc_value[MAXPATHLEN * 2];
4483cb34c6ahrens	char		zc_string[MAXNAMELEN];
449ea8dc4beschrock	uint64_t	zc_guid;
450990b485lling	uint64_t	zc_nvlist_conf;		/* really (char *) */
451990b485lling	uint64_t	zc_nvlist_conf_size;
452fa9e406ahrens	uint64_t	zc_cookie;
453fa9e406ahrens	uint64_t	zc_objset_type;
454ecd6cf8marks	uint64_t	zc_perm_action;
4554445fffMatthew Ahrens	uint64_t	zc_history_len;
45606eeb2aek	uint64_t	zc_history_offset;
45755434c7ek	uint64_t	zc_obj;
458478ed9aEric Taylor	uint64_t	zc_iflags;		/* internal to zfs(7fs) */
459ecd6cf8marks	zfs_share_t	zc_share;
460fa9e406ahrens	dmu_objset_stats_t zc_objset_stats;
4619c3fd12Matthew Ahrens	dmu_replay_record_t zc_begin_record;
462ea8dc4beschrock	zinject_record_t zc_inject_record;
4635d7b4d4Matthew Ahrens	uint32_t	zc_defer_destroy;
4645d7b4d4Matthew Ahrens	uint32_t	zc_flags;
465c99e4bdChris Kirby	uint64_t	zc_action_handle;
466c99e4bdChris Kirby	int		zc_cleanup_fd;
4670d8fa8fMartin Matuska	uint8_t		zc_simple;
468ea4a67fMatthew Ahrens	uint8_t		zc_pad3[3];
4699c3fd12Matthew Ahrens	boolean_t	zc_resumable;
470ea4a67fMatthew Ahrens	uint32_t	zc_pad4;
471a7f53a5Chris Kirby	uint64_t	zc_sendobj;
472a7f53a5Chris Kirby	uint64_t	zc_fromobj;
473a7f53a5Chris Kirby	uint64_t	zc_createtxg;
47499d5e17Tim Haley	zfs_stat_t	zc_stat;
475fa9e406ahrens} zfs_cmd_t;
476fa9e406ahrens
4771484342Matthew Ahrenstypedef struct zfs_useracct {
4781484342Matthew Ahrens	char zu_domain[256];
4791484342Matthew Ahrens	uid_t zu_rid;
4801484342Matthew Ahrens	uint32_t zu_pad;
4811484342Matthew Ahrens	uint64_t zu_space;
4821484342Matthew Ahrens} zfs_useracct_t;
4831484342Matthew Ahrens
484c99e4bdChris Kirby#define	ZFSDEV_MAX_MINOR	(1 << 16)
485c99e4bdChris Kirby#define	ZFS_MIN_MINOR	(ZFSDEV_MAX_MINOR + 1)
486a0965f3bonwick
4871195e68Mark J Musante#define	ZPOOL_EXPORT_AFTER_SPLIT 0x1
4881195e68Mark J Musante
489fa9e406ahrens#ifdef _KERNEL
490dfc1153Chris Williamsonstruct objset;
491dfc1153Chris Williamsonstruct zfsvfs;
492fa9e406ahrens
493da6c28aamwtypedef struct zfs_creat {
494de8267etimh	nvlist_t	*zct_zplprops;
495da6c28aamw	nvlist_t	*zct_props;
496da6c28aamw} zfs_creat_t;
497da6c28aamw
498fa9e406ahrensextern dev_info_t *zfs_dip;
499fa9e406ahrens
500dfc1153Chris Williamsonextern int zfs_secpolicy_snapshot_perms(const char *, cred_t *);
501dfc1153Chris Williamsonextern int zfs_secpolicy_rename_perms(const char *, const char *, cred_t *);
502dfc1153Chris Williamsonextern int zfs_secpolicy_destroy_perms(const char *, cred_t *);
503fa9e406ahrensextern int zfs_busy(void);
504ed992b0Serapheim Dimitropoulosextern void zfs_unmount_snap(const char *);
5053b2aab1Matthew Ahrensextern void zfs_destroy_unmount_origin(const char *);
506dfc1153Chris Williamsonextern int getzfsvfs_impl(struct objset *, struct zfsvfs **);
507ed992b0Serapheim Dimitropoulosextern int getzfsvfs(const char *, struct zfsvfs **);
508fa9e406ahrens
509c99e4bdChris Kirby/*
510c99e4bdChris Kirby * ZFS minor numbers can refer to either a control device instance or
511c99e4bdChris Kirby * a zvol. Depending on the value of zss_type, zss_data points to either
512c99e4bdChris Kirby * a zvol_state_t or a zfs_onexit_t.
513c99e4bdChris Kirby */
514c99e4bdChris Kirbyenum zfs_soft_state_type {
515c99e4bdChris Kirby	ZSST_ZVOL,
516c99e4bdChris Kirby	ZSST_CTLDEV
517c99e4bdChris Kirby};
518c99e4bdChris Kirby
519c99e4bdChris Kirbytypedef struct zfs_soft_state {
520c99e4bdChris Kirby	enum zfs_soft_state_type zss_type;
521c99e4bdChris Kirby	void *zss_data;
522c99e4bdChris Kirby} zfs_soft_state_t;
523c99e4bdChris Kirby
524c99e4bdChris Kirbyextern void *zfsdev_get_soft_state(minor_t minor,
525c99e4bdChris Kirby    enum zfs_soft_state_type which);
526c99e4bdChris Kirbyextern minor_t zfsdev_minor_alloc(void);
527c99e4bdChris Kirby
528c99e4bdChris Kirbyextern void *zfsdev_state;
529c99e4bdChris Kirbyextern kmutex_t zfsdev_state_lock;
530c99e4bdChris Kirby
531fa9e406ahrens#endif	/* _KERNEL */
532fa9e406ahrens
533fa9e406ahrens#ifdef	__cplusplus
534fa9e406ahrens}
535fa9e406ahrens#endif
536fa9e406ahrens
537fa9e406ahrens#endif	/* _SYS_ZFS_IOCTL_H */
538