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 9eda14cbcSMatt Macy * or http://www.opensolaris.org/os/licensing. 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 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23eda14cbcSMatt Macy * Copyright (c) 2012, 2020 by Delphix. All rights reserved. 24eda14cbcSMatt Macy * Copyright 2016 RackTop Systems. 25eda14cbcSMatt Macy * Copyright (c) 2017, Intel Corporation. 26eda14cbcSMatt Macy */ 27eda14cbcSMatt Macy 28eda14cbcSMatt Macy #ifndef _SYS_ZFS_IOCTL_H 29eda14cbcSMatt Macy #define _SYS_ZFS_IOCTL_H 30eda14cbcSMatt Macy 31eda14cbcSMatt Macy #include <sys/cred.h> 32eda14cbcSMatt Macy #include <sys/dmu.h> 33eda14cbcSMatt Macy #include <sys/zio.h> 34eda14cbcSMatt Macy #include <sys/dsl_deleg.h> 35eda14cbcSMatt Macy #include <sys/spa.h> 36eda14cbcSMatt Macy #include <sys/zfs_stat.h> 37eda14cbcSMatt Macy 38eda14cbcSMatt Macy #ifdef _KERNEL 39eda14cbcSMatt Macy #include <sys/nvpair.h> 40eda14cbcSMatt Macy #endif /* _KERNEL */ 41eda14cbcSMatt Macy 42eda14cbcSMatt Macy #ifdef __cplusplus 43eda14cbcSMatt Macy extern "C" { 44eda14cbcSMatt Macy #endif 45eda14cbcSMatt Macy 46eda14cbcSMatt Macy /* 47eda14cbcSMatt Macy * The structures in this file are passed between userland and the 48eda14cbcSMatt Macy * kernel. Userland may be running a 32-bit process, while the kernel 49eda14cbcSMatt Macy * is 64-bit. Therefore, these structures need to compile the same in 50eda14cbcSMatt Macy * 32-bit and 64-bit. This means not using type "long", and adding 51eda14cbcSMatt Macy * explicit padding so that the 32-bit structure will not be packed more 52eda14cbcSMatt Macy * tightly than the 64-bit structure (which requires 64-bit alignment). 53eda14cbcSMatt Macy */ 54eda14cbcSMatt Macy 55eda14cbcSMatt Macy /* 56eda14cbcSMatt Macy * Property values for snapdir 57eda14cbcSMatt Macy */ 58eda14cbcSMatt Macy #define ZFS_SNAPDIR_HIDDEN 0 59eda14cbcSMatt Macy #define ZFS_SNAPDIR_VISIBLE 1 60eda14cbcSMatt Macy 61eda14cbcSMatt Macy /* 62eda14cbcSMatt Macy * Property values for snapdev 63eda14cbcSMatt Macy */ 64eda14cbcSMatt Macy #define ZFS_SNAPDEV_HIDDEN 0 65eda14cbcSMatt Macy #define ZFS_SNAPDEV_VISIBLE 1 66eda14cbcSMatt Macy /* 67eda14cbcSMatt Macy * Property values for acltype 68eda14cbcSMatt Macy */ 69eda14cbcSMatt Macy #define ZFS_ACLTYPE_OFF 0 70*2c48331dSMatt Macy #define ZFS_ACLTYPE_POSIX 1 71eda14cbcSMatt Macy 72eda14cbcSMatt Macy /* 73eda14cbcSMatt Macy * Field manipulation macros for the drr_versioninfo field of the 74eda14cbcSMatt Macy * send stream header. 75eda14cbcSMatt Macy */ 76eda14cbcSMatt Macy 77eda14cbcSMatt Macy /* 78eda14cbcSMatt Macy * Header types for zfs send streams. 79eda14cbcSMatt Macy */ 80eda14cbcSMatt Macy typedef enum drr_headertype { 81eda14cbcSMatt Macy DMU_SUBSTREAM = 0x1, 82eda14cbcSMatt Macy DMU_COMPOUNDSTREAM = 0x2 83eda14cbcSMatt Macy } drr_headertype_t; 84eda14cbcSMatt Macy 85eda14cbcSMatt Macy #define DMU_GET_STREAM_HDRTYPE(vi) BF64_GET((vi), 0, 2) 86eda14cbcSMatt Macy #define DMU_SET_STREAM_HDRTYPE(vi, x) BF64_SET((vi), 0, 2, x) 87eda14cbcSMatt Macy 88eda14cbcSMatt Macy #define DMU_GET_FEATUREFLAGS(vi) BF64_GET((vi), 2, 30) 89eda14cbcSMatt Macy #define DMU_SET_FEATUREFLAGS(vi, x) BF64_SET((vi), 2, 30, x) 90eda14cbcSMatt Macy 91eda14cbcSMatt Macy /* 92eda14cbcSMatt Macy * Feature flags for zfs send streams (flags in drr_versioninfo) 93eda14cbcSMatt Macy */ 94eda14cbcSMatt Macy 95eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_DEDUP (1 << 0) 96eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_DEDUPPROPS (1 << 1) 97eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_SA_SPILL (1 << 2) 98eda14cbcSMatt Macy /* flags #3 - #15 are reserved for incompatible closed-source implementations */ 99eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_EMBED_DATA (1 << 16) 100eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_LZ4 (1 << 17) 101eda14cbcSMatt Macy /* flag #18 is reserved for a Delphix feature */ 102eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_LARGE_BLOCKS (1 << 19) 103eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_RESUMING (1 << 20) 104eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_REDACTED (1 << 21) 105eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_COMPRESSED (1 << 22) 106eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_LARGE_DNODE (1 << 23) 107eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_RAW (1 << 24) 108eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_ZSTD (1 << 25) 109eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_HOLDS (1 << 26) 110eda14cbcSMatt Macy /* 111eda14cbcSMatt Macy * The SWITCH_TO_LARGE_BLOCKS feature indicates that we can receive 112eda14cbcSMatt Macy * incremental LARGE_BLOCKS streams (those with WRITE records of >128KB) even 113eda14cbcSMatt Macy * if the previous send did not use LARGE_BLOCKS, and thus its large blocks 114eda14cbcSMatt Macy * were split into multiple 128KB WRITE records. (See 115eda14cbcSMatt Macy * flush_write_batch_impl() and receive_object()). Older software that does 116eda14cbcSMatt Macy * not support this flag may encounter a bug when switching to large blocks, 117eda14cbcSMatt Macy * which causes files to incorrectly be zeroed. 118eda14cbcSMatt Macy * 119eda14cbcSMatt Macy * This flag is currently not set on any send streams. In the future, we 120eda14cbcSMatt Macy * intend for incremental send streams of snapshots that have large blocks to 121eda14cbcSMatt Macy * use LARGE_BLOCKS by default, and these streams will also have the 122eda14cbcSMatt Macy * SWITCH_TO_LARGE_BLOCKS feature set. This ensures that streams from the 123eda14cbcSMatt Macy * default use of "zfs send" won't encounter the bug mentioned above. 124eda14cbcSMatt Macy */ 125eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS (1 << 27) 126eda14cbcSMatt Macy 127eda14cbcSMatt Macy /* 128eda14cbcSMatt Macy * Mask of all supported backup features 129eda14cbcSMatt Macy */ 130eda14cbcSMatt Macy #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_SA_SPILL | \ 131eda14cbcSMatt Macy DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_LZ4 | \ 132eda14cbcSMatt Macy DMU_BACKUP_FEATURE_RESUMING | DMU_BACKUP_FEATURE_LARGE_BLOCKS | \ 133eda14cbcSMatt Macy DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \ 134eda14cbcSMatt Macy DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS | \ 135eda14cbcSMatt Macy DMU_BACKUP_FEATURE_REDACTED | DMU_BACKUP_FEATURE_SWITCH_TO_LARGE_BLOCKS | \ 136eda14cbcSMatt Macy DMU_BACKUP_FEATURE_ZSTD) 137eda14cbcSMatt Macy 138eda14cbcSMatt Macy /* Are all features in the given flag word currently supported? */ 139eda14cbcSMatt Macy #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK)) 140eda14cbcSMatt Macy 141eda14cbcSMatt Macy typedef enum dmu_send_resume_token_version { 142eda14cbcSMatt Macy ZFS_SEND_RESUME_TOKEN_VERSION = 1 143eda14cbcSMatt Macy } dmu_send_resume_token_version_t; 144eda14cbcSMatt Macy 145eda14cbcSMatt Macy /* 146eda14cbcSMatt Macy * The drr_versioninfo field of the dmu_replay_record has the 147eda14cbcSMatt Macy * following layout: 148eda14cbcSMatt Macy * 149eda14cbcSMatt Macy * 64 56 48 40 32 24 16 8 0 150eda14cbcSMatt Macy * +-------+-------+-------+-------+-------+-------+-------+-------+ 151eda14cbcSMatt Macy * | reserved | feature-flags |C|S| 152eda14cbcSMatt Macy * +-------+-------+-------+-------+-------+-------+-------+-------+ 153eda14cbcSMatt Macy * 154eda14cbcSMatt Macy * The low order two bits indicate the header type: SUBSTREAM (0x1) 155eda14cbcSMatt Macy * or COMPOUNDSTREAM (0x2). Using two bits for this is historical: 156eda14cbcSMatt Macy * this field used to be a version number, where the two version types 157eda14cbcSMatt Macy * were 1 and 2. Using two bits for this allows earlier versions of 158eda14cbcSMatt Macy * the code to be able to recognize send streams that don't use any 159eda14cbcSMatt Macy * of the features indicated by feature flags. 160eda14cbcSMatt Macy */ 161eda14cbcSMatt Macy 162eda14cbcSMatt Macy #define DMU_BACKUP_MAGIC 0x2F5bacbacULL 163eda14cbcSMatt Macy 164eda14cbcSMatt Macy /* 165eda14cbcSMatt Macy * Send stream flags. Bits 24-31 are reserved for vendor-specific 166eda14cbcSMatt Macy * implementations and should not be used. 167eda14cbcSMatt Macy */ 168eda14cbcSMatt Macy #define DRR_FLAG_CLONE (1<<0) 169eda14cbcSMatt Macy #define DRR_FLAG_CI_DATA (1<<1) 170eda14cbcSMatt Macy /* 171eda14cbcSMatt Macy * This send stream, if it is a full send, includes the FREE and FREEOBJECT 172eda14cbcSMatt Macy * records that are created by the sending process. This means that the send 173eda14cbcSMatt Macy * stream can be received as a clone, even though it is not an incremental. 174eda14cbcSMatt Macy * This is not implemented as a feature flag, because the receiving side does 175eda14cbcSMatt Macy * not need to have implemented it to receive this stream; it is fully backwards 176eda14cbcSMatt Macy * compatible. We need a flag, though, because full send streams without it 177eda14cbcSMatt Macy * cannot necessarily be received as a clone correctly. 178eda14cbcSMatt Macy */ 179eda14cbcSMatt Macy #define DRR_FLAG_FREERECORDS (1<<2) 180eda14cbcSMatt Macy /* 181eda14cbcSMatt Macy * When DRR_FLAG_SPILL_BLOCK is set it indicates the DRR_OBJECT_SPILL 182eda14cbcSMatt Macy * and DRR_SPILL_UNMODIFIED flags are meaningful in the send stream. 183eda14cbcSMatt Macy * 184eda14cbcSMatt Macy * When DRR_FLAG_SPILL_BLOCK is set, DRR_OBJECT records will have 185eda14cbcSMatt Macy * DRR_OBJECT_SPILL set if and only if they should have a spill block 186eda14cbcSMatt Macy * (either an existing one, or a new one in the send stream). When clear 187eda14cbcSMatt Macy * the object does not have a spill block and any existing spill block 188eda14cbcSMatt Macy * should be freed. 189eda14cbcSMatt Macy * 190eda14cbcSMatt Macy * Similarly, when DRR_FLAG_SPILL_BLOCK is set, DRR_SPILL records will 191eda14cbcSMatt Macy * have DRR_SPILL_UNMODIFIED set if and only if they were included for 192eda14cbcSMatt Macy * backward compatibility purposes, and can be safely ignored by new versions 193eda14cbcSMatt Macy * of zfs receive. Previous versions of ZFS which do not understand the 194eda14cbcSMatt Macy * DRR_FLAG_SPILL_BLOCK will process this record and recreate any missing 195eda14cbcSMatt Macy * spill blocks. 196eda14cbcSMatt Macy */ 197eda14cbcSMatt Macy #define DRR_FLAG_SPILL_BLOCK (1<<3) 198eda14cbcSMatt Macy 199eda14cbcSMatt Macy /* 200eda14cbcSMatt Macy * flags in the drr_flags field in the DRR_WRITE, DRR_SPILL, DRR_OBJECT, 201eda14cbcSMatt Macy * DRR_WRITE_BYREF, and DRR_OBJECT_RANGE blocks 202eda14cbcSMatt Macy */ 203eda14cbcSMatt Macy #define DRR_CHECKSUM_DEDUP (1<<0) /* not used for SPILL records */ 204eda14cbcSMatt Macy #define DRR_RAW_BYTESWAP (1<<1) 205eda14cbcSMatt Macy #define DRR_OBJECT_SPILL (1<<2) /* OBJECT record has a spill block */ 206eda14cbcSMatt Macy #define DRR_SPILL_UNMODIFIED (1<<2) /* SPILL record for unmodified block */ 207eda14cbcSMatt Macy 208eda14cbcSMatt Macy #define DRR_IS_DEDUP_CAPABLE(flags) ((flags) & DRR_CHECKSUM_DEDUP) 209eda14cbcSMatt Macy #define DRR_IS_RAW_BYTESWAPPED(flags) ((flags) & DRR_RAW_BYTESWAP) 210eda14cbcSMatt Macy #define DRR_OBJECT_HAS_SPILL(flags) ((flags) & DRR_OBJECT_SPILL) 211eda14cbcSMatt Macy #define DRR_SPILL_IS_UNMODIFIED(flags) ((flags) & DRR_SPILL_UNMODIFIED) 212eda14cbcSMatt Macy 213eda14cbcSMatt Macy /* deal with compressed drr_write replay records */ 214eda14cbcSMatt Macy #define DRR_WRITE_COMPRESSED(drrw) ((drrw)->drr_compressiontype != 0) 215eda14cbcSMatt Macy #define DRR_WRITE_PAYLOAD_SIZE(drrw) \ 216eda14cbcSMatt Macy (DRR_WRITE_COMPRESSED(drrw) ? (drrw)->drr_compressed_size : \ 217eda14cbcSMatt Macy (drrw)->drr_logical_size) 218eda14cbcSMatt Macy #define DRR_SPILL_PAYLOAD_SIZE(drrs) \ 219eda14cbcSMatt Macy ((drrs)->drr_compressed_size ? \ 220eda14cbcSMatt Macy (drrs)->drr_compressed_size : (drrs)->drr_length) 221eda14cbcSMatt Macy #define DRR_OBJECT_PAYLOAD_SIZE(drro) \ 222eda14cbcSMatt Macy ((drro)->drr_raw_bonuslen != 0 ? \ 223eda14cbcSMatt Macy (drro)->drr_raw_bonuslen : P2ROUNDUP((drro)->drr_bonuslen, 8)) 224eda14cbcSMatt Macy 225eda14cbcSMatt Macy /* 226eda14cbcSMatt Macy * zfs ioctl command structure 227eda14cbcSMatt Macy */ 228eda14cbcSMatt Macy 229eda14cbcSMatt Macy /* Header is used in C++ so can't forward declare untagged struct */ 230eda14cbcSMatt Macy struct drr_begin { 231eda14cbcSMatt Macy uint64_t drr_magic; 232eda14cbcSMatt Macy uint64_t drr_versioninfo; /* was drr_version */ 233eda14cbcSMatt Macy uint64_t drr_creation_time; 234eda14cbcSMatt Macy dmu_objset_type_t drr_type; 235eda14cbcSMatt Macy uint32_t drr_flags; 236eda14cbcSMatt Macy uint64_t drr_toguid; 237eda14cbcSMatt Macy uint64_t drr_fromguid; 238eda14cbcSMatt Macy char drr_toname[MAXNAMELEN]; 239eda14cbcSMatt Macy }; 240eda14cbcSMatt Macy 241eda14cbcSMatt Macy typedef struct dmu_replay_record { 242eda14cbcSMatt Macy enum { 243eda14cbcSMatt Macy DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS, 244eda14cbcSMatt Macy DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF, 245eda14cbcSMatt Macy DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_OBJECT_RANGE, DRR_REDACT, 246eda14cbcSMatt Macy DRR_NUMTYPES 247eda14cbcSMatt Macy } drr_type; 248eda14cbcSMatt Macy uint32_t drr_payloadlen; 249eda14cbcSMatt Macy union { 250eda14cbcSMatt Macy struct drr_begin drr_begin; 251eda14cbcSMatt Macy struct drr_end { 252eda14cbcSMatt Macy zio_cksum_t drr_checksum; 253eda14cbcSMatt Macy uint64_t drr_toguid; 254eda14cbcSMatt Macy } drr_end; 255eda14cbcSMatt Macy struct drr_object { 256eda14cbcSMatt Macy uint64_t drr_object; 257eda14cbcSMatt Macy dmu_object_type_t drr_type; 258eda14cbcSMatt Macy dmu_object_type_t drr_bonustype; 259eda14cbcSMatt Macy uint32_t drr_blksz; 260eda14cbcSMatt Macy uint32_t drr_bonuslen; 261eda14cbcSMatt Macy uint8_t drr_checksumtype; 262eda14cbcSMatt Macy uint8_t drr_compress; 263eda14cbcSMatt Macy uint8_t drr_dn_slots; 264eda14cbcSMatt Macy uint8_t drr_flags; 265eda14cbcSMatt Macy uint32_t drr_raw_bonuslen; 266eda14cbcSMatt Macy uint64_t drr_toguid; 267eda14cbcSMatt Macy /* only (possibly) nonzero for raw streams */ 268eda14cbcSMatt Macy uint8_t drr_indblkshift; 269eda14cbcSMatt Macy uint8_t drr_nlevels; 270eda14cbcSMatt Macy uint8_t drr_nblkptr; 271eda14cbcSMatt Macy uint8_t drr_pad[5]; 272eda14cbcSMatt Macy uint64_t drr_maxblkid; 273eda14cbcSMatt Macy /* bonus content follows */ 274eda14cbcSMatt Macy } drr_object; 275eda14cbcSMatt Macy struct drr_freeobjects { 276eda14cbcSMatt Macy uint64_t drr_firstobj; 277eda14cbcSMatt Macy uint64_t drr_numobjs; 278eda14cbcSMatt Macy uint64_t drr_toguid; 279eda14cbcSMatt Macy } drr_freeobjects; 280eda14cbcSMatt Macy struct drr_write { 281eda14cbcSMatt Macy uint64_t drr_object; 282eda14cbcSMatt Macy dmu_object_type_t drr_type; 283eda14cbcSMatt Macy uint32_t drr_pad; 284eda14cbcSMatt Macy uint64_t drr_offset; 285eda14cbcSMatt Macy uint64_t drr_logical_size; 286eda14cbcSMatt Macy uint64_t drr_toguid; 287eda14cbcSMatt Macy uint8_t drr_checksumtype; 288eda14cbcSMatt Macy uint8_t drr_flags; 289eda14cbcSMatt Macy uint8_t drr_compressiontype; 290eda14cbcSMatt Macy uint8_t drr_pad2[5]; 291eda14cbcSMatt Macy /* deduplication key */ 292eda14cbcSMatt Macy ddt_key_t drr_key; 293eda14cbcSMatt Macy /* only nonzero if drr_compressiontype is not 0 */ 294eda14cbcSMatt Macy uint64_t drr_compressed_size; 295eda14cbcSMatt Macy /* only nonzero for raw streams */ 296eda14cbcSMatt Macy uint8_t drr_salt[ZIO_DATA_SALT_LEN]; 297eda14cbcSMatt Macy uint8_t drr_iv[ZIO_DATA_IV_LEN]; 298eda14cbcSMatt Macy uint8_t drr_mac[ZIO_DATA_MAC_LEN]; 299eda14cbcSMatt Macy /* content follows */ 300eda14cbcSMatt Macy } drr_write; 301eda14cbcSMatt Macy struct drr_free { 302eda14cbcSMatt Macy uint64_t drr_object; 303eda14cbcSMatt Macy uint64_t drr_offset; 304eda14cbcSMatt Macy uint64_t drr_length; 305eda14cbcSMatt Macy uint64_t drr_toguid; 306eda14cbcSMatt Macy } drr_free; 307eda14cbcSMatt Macy struct drr_write_byref { 308eda14cbcSMatt Macy /* where to put the data */ 309eda14cbcSMatt Macy uint64_t drr_object; 310eda14cbcSMatt Macy uint64_t drr_offset; 311eda14cbcSMatt Macy uint64_t drr_length; 312eda14cbcSMatt Macy uint64_t drr_toguid; 313eda14cbcSMatt Macy /* where to find the prior copy of the data */ 314eda14cbcSMatt Macy uint64_t drr_refguid; 315eda14cbcSMatt Macy uint64_t drr_refobject; 316eda14cbcSMatt Macy uint64_t drr_refoffset; 317eda14cbcSMatt Macy /* properties of the data */ 318eda14cbcSMatt Macy uint8_t drr_checksumtype; 319eda14cbcSMatt Macy uint8_t drr_flags; 320eda14cbcSMatt Macy uint8_t drr_pad2[6]; 321eda14cbcSMatt Macy ddt_key_t drr_key; /* deduplication key */ 322eda14cbcSMatt Macy } drr_write_byref; 323eda14cbcSMatt Macy struct drr_spill { 324eda14cbcSMatt Macy uint64_t drr_object; 325eda14cbcSMatt Macy uint64_t drr_length; 326eda14cbcSMatt Macy uint64_t drr_toguid; 327eda14cbcSMatt Macy uint8_t drr_flags; 328eda14cbcSMatt Macy uint8_t drr_compressiontype; 329eda14cbcSMatt Macy uint8_t drr_pad[6]; 330eda14cbcSMatt Macy /* only nonzero for raw streams */ 331eda14cbcSMatt Macy uint64_t drr_compressed_size; 332eda14cbcSMatt Macy uint8_t drr_salt[ZIO_DATA_SALT_LEN]; 333eda14cbcSMatt Macy uint8_t drr_iv[ZIO_DATA_IV_LEN]; 334eda14cbcSMatt Macy uint8_t drr_mac[ZIO_DATA_MAC_LEN]; 335eda14cbcSMatt Macy dmu_object_type_t drr_type; 336eda14cbcSMatt Macy /* spill data follows */ 337eda14cbcSMatt Macy } drr_spill; 338eda14cbcSMatt Macy struct drr_write_embedded { 339eda14cbcSMatt Macy uint64_t drr_object; 340eda14cbcSMatt Macy uint64_t drr_offset; 341eda14cbcSMatt Macy /* logical length, should equal blocksize */ 342eda14cbcSMatt Macy uint64_t drr_length; 343eda14cbcSMatt Macy uint64_t drr_toguid; 344eda14cbcSMatt Macy uint8_t drr_compression; 345eda14cbcSMatt Macy uint8_t drr_etype; 346eda14cbcSMatt Macy uint8_t drr_pad[6]; 347eda14cbcSMatt Macy uint32_t drr_lsize; /* uncompressed size of payload */ 348eda14cbcSMatt Macy uint32_t drr_psize; /* compr. (real) size of payload */ 349eda14cbcSMatt Macy /* (possibly compressed) content follows */ 350eda14cbcSMatt Macy } drr_write_embedded; 351eda14cbcSMatt Macy struct drr_object_range { 352eda14cbcSMatt Macy uint64_t drr_firstobj; 353eda14cbcSMatt Macy uint64_t drr_numslots; 354eda14cbcSMatt Macy uint64_t drr_toguid; 355eda14cbcSMatt Macy uint8_t drr_salt[ZIO_DATA_SALT_LEN]; 356eda14cbcSMatt Macy uint8_t drr_iv[ZIO_DATA_IV_LEN]; 357eda14cbcSMatt Macy uint8_t drr_mac[ZIO_DATA_MAC_LEN]; 358eda14cbcSMatt Macy uint8_t drr_flags; 359eda14cbcSMatt Macy uint8_t drr_pad[3]; 360eda14cbcSMatt Macy } drr_object_range; 361eda14cbcSMatt Macy struct drr_redact { 362eda14cbcSMatt Macy uint64_t drr_object; 363eda14cbcSMatt Macy uint64_t drr_offset; 364eda14cbcSMatt Macy uint64_t drr_length; 365eda14cbcSMatt Macy uint64_t drr_toguid; 366eda14cbcSMatt Macy } drr_redact; 367eda14cbcSMatt Macy 368eda14cbcSMatt Macy /* 369eda14cbcSMatt Macy * Note: drr_checksum is overlaid with all record types 370eda14cbcSMatt Macy * except DRR_BEGIN. Therefore its (non-pad) members 371eda14cbcSMatt Macy * must not overlap with members from the other structs. 372eda14cbcSMatt Macy * We accomplish this by putting its members at the very 373eda14cbcSMatt Macy * end of the struct. 374eda14cbcSMatt Macy */ 375eda14cbcSMatt Macy struct drr_checksum { 376eda14cbcSMatt Macy uint64_t drr_pad[34]; 377eda14cbcSMatt Macy /* 378eda14cbcSMatt Macy * fletcher-4 checksum of everything preceding the 379eda14cbcSMatt Macy * checksum. 380eda14cbcSMatt Macy */ 381eda14cbcSMatt Macy zio_cksum_t drr_checksum; 382eda14cbcSMatt Macy } drr_checksum; 383eda14cbcSMatt Macy } drr_u; 384eda14cbcSMatt Macy } dmu_replay_record_t; 385eda14cbcSMatt Macy 386eda14cbcSMatt Macy /* diff record range types */ 387eda14cbcSMatt Macy typedef enum diff_type { 388eda14cbcSMatt Macy DDR_NONE = 0x1, 389eda14cbcSMatt Macy DDR_INUSE = 0x2, 390eda14cbcSMatt Macy DDR_FREE = 0x4 391eda14cbcSMatt Macy } diff_type_t; 392eda14cbcSMatt Macy 393eda14cbcSMatt Macy /* 394eda14cbcSMatt Macy * The diff reports back ranges of free or in-use objects. 395eda14cbcSMatt Macy */ 396eda14cbcSMatt Macy typedef struct dmu_diff_record { 397eda14cbcSMatt Macy uint64_t ddr_type; 398eda14cbcSMatt Macy uint64_t ddr_first; 399eda14cbcSMatt Macy uint64_t ddr_last; 400eda14cbcSMatt Macy } dmu_diff_record_t; 401eda14cbcSMatt Macy 402eda14cbcSMatt Macy typedef struct zinject_record { 403eda14cbcSMatt Macy uint64_t zi_objset; 404eda14cbcSMatt Macy uint64_t zi_object; 405eda14cbcSMatt Macy uint64_t zi_start; 406eda14cbcSMatt Macy uint64_t zi_end; 407eda14cbcSMatt Macy uint64_t zi_guid; 408eda14cbcSMatt Macy uint32_t zi_level; 409eda14cbcSMatt Macy uint32_t zi_error; 410eda14cbcSMatt Macy uint64_t zi_type; 411eda14cbcSMatt Macy uint32_t zi_freq; 412eda14cbcSMatt Macy uint32_t zi_failfast; 413eda14cbcSMatt Macy char zi_func[MAXNAMELEN]; 414eda14cbcSMatt Macy uint32_t zi_iotype; 415eda14cbcSMatt Macy int32_t zi_duration; 416eda14cbcSMatt Macy uint64_t zi_timer; 417eda14cbcSMatt Macy uint64_t zi_nlanes; 418eda14cbcSMatt Macy uint32_t zi_cmd; 419eda14cbcSMatt Macy uint32_t zi_dvas; 420eda14cbcSMatt Macy } zinject_record_t; 421eda14cbcSMatt Macy 422eda14cbcSMatt Macy #define ZINJECT_NULL 0x1 423eda14cbcSMatt Macy #define ZINJECT_FLUSH_ARC 0x2 424eda14cbcSMatt Macy #define ZINJECT_UNLOAD_SPA 0x4 425eda14cbcSMatt Macy #define ZINJECT_CALC_RANGE 0x8 426eda14cbcSMatt Macy 427eda14cbcSMatt Macy #define ZEVENT_NONE 0x0 428eda14cbcSMatt Macy #define ZEVENT_NONBLOCK 0x1 429eda14cbcSMatt Macy #define ZEVENT_SIZE 1024 430eda14cbcSMatt Macy 431eda14cbcSMatt Macy #define ZEVENT_SEEK_START 0 432eda14cbcSMatt Macy #define ZEVENT_SEEK_END UINT64_MAX 433eda14cbcSMatt Macy 434eda14cbcSMatt Macy /* scaled frequency ranges */ 435eda14cbcSMatt Macy #define ZI_PERCENTAGE_MIN 4294UL 436eda14cbcSMatt Macy #define ZI_PERCENTAGE_MAX UINT32_MAX 437eda14cbcSMatt Macy 438eda14cbcSMatt Macy #define ZI_NO_DVA (-1) 439eda14cbcSMatt Macy 440eda14cbcSMatt Macy typedef enum zinject_type { 441eda14cbcSMatt Macy ZINJECT_UNINITIALIZED, 442eda14cbcSMatt Macy ZINJECT_DATA_FAULT, 443eda14cbcSMatt Macy ZINJECT_DEVICE_FAULT, 444eda14cbcSMatt Macy ZINJECT_LABEL_FAULT, 445eda14cbcSMatt Macy ZINJECT_IGNORED_WRITES, 446eda14cbcSMatt Macy ZINJECT_PANIC, 447eda14cbcSMatt Macy ZINJECT_DELAY_IO, 448eda14cbcSMatt Macy ZINJECT_DECRYPT_FAULT, 449eda14cbcSMatt Macy } zinject_type_t; 450eda14cbcSMatt Macy 451eda14cbcSMatt Macy typedef struct zfs_share { 452eda14cbcSMatt Macy uint64_t z_exportdata; 453eda14cbcSMatt Macy uint64_t z_sharedata; 454eda14cbcSMatt Macy uint64_t z_sharetype; /* 0 = share, 1 = unshare */ 455eda14cbcSMatt Macy uint64_t z_sharemax; /* max length of share string */ 456eda14cbcSMatt Macy } zfs_share_t; 457eda14cbcSMatt Macy 458eda14cbcSMatt Macy /* 459eda14cbcSMatt Macy * ZFS file systems may behave the usual, POSIX-compliant way, where 460eda14cbcSMatt Macy * name lookups are case-sensitive. They may also be set up so that 461eda14cbcSMatt Macy * all the name lookups are case-insensitive, or so that only some 462eda14cbcSMatt Macy * lookups, the ones that set an FIGNORECASE flag, are case-insensitive. 463eda14cbcSMatt Macy */ 464eda14cbcSMatt Macy typedef enum zfs_case { 465eda14cbcSMatt Macy ZFS_CASE_SENSITIVE, 466eda14cbcSMatt Macy ZFS_CASE_INSENSITIVE, 467eda14cbcSMatt Macy ZFS_CASE_MIXED 468eda14cbcSMatt Macy } zfs_case_t; 469eda14cbcSMatt Macy 470eda14cbcSMatt Macy /* 471eda14cbcSMatt Macy * Note: this struct must have the same layout in 32-bit and 64-bit, so 472eda14cbcSMatt Macy * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit 473eda14cbcSMatt Macy * kernel. Therefore, we add padding to it so that no "hidden" padding 474eda14cbcSMatt Macy * is automatically added on 64-bit (but not on 32-bit). 475eda14cbcSMatt Macy */ 476eda14cbcSMatt Macy typedef struct zfs_cmd { 477eda14cbcSMatt Macy char zc_name[MAXPATHLEN]; /* name of pool or dataset */ 478eda14cbcSMatt Macy uint64_t zc_nvlist_src; /* really (char *) */ 479eda14cbcSMatt Macy uint64_t zc_nvlist_src_size; 480eda14cbcSMatt Macy uint64_t zc_nvlist_dst; /* really (char *) */ 481eda14cbcSMatt Macy uint64_t zc_nvlist_dst_size; 482eda14cbcSMatt Macy boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */ 483eda14cbcSMatt Macy int zc_pad2; 484eda14cbcSMatt Macy 485eda14cbcSMatt Macy /* 486eda14cbcSMatt Macy * The following members are for legacy ioctls which haven't been 487eda14cbcSMatt Macy * converted to the new method. 488eda14cbcSMatt Macy */ 489eda14cbcSMatt Macy uint64_t zc_history; /* really (char *) */ 490eda14cbcSMatt Macy char zc_value[MAXPATHLEN * 2]; 491eda14cbcSMatt Macy char zc_string[MAXNAMELEN]; 492eda14cbcSMatt Macy uint64_t zc_guid; 493eda14cbcSMatt Macy uint64_t zc_nvlist_conf; /* really (char *) */ 494eda14cbcSMatt Macy uint64_t zc_nvlist_conf_size; 495eda14cbcSMatt Macy uint64_t zc_cookie; 496eda14cbcSMatt Macy uint64_t zc_objset_type; 497eda14cbcSMatt Macy uint64_t zc_perm_action; 498eda14cbcSMatt Macy uint64_t zc_history_len; 499eda14cbcSMatt Macy uint64_t zc_history_offset; 500eda14cbcSMatt Macy uint64_t zc_obj; 501eda14cbcSMatt Macy uint64_t zc_iflags; /* internal to zfs(7fs) */ 502eda14cbcSMatt Macy zfs_share_t zc_share; 503eda14cbcSMatt Macy dmu_objset_stats_t zc_objset_stats; 504eda14cbcSMatt Macy struct drr_begin zc_begin_record; 505eda14cbcSMatt Macy zinject_record_t zc_inject_record; 506eda14cbcSMatt Macy uint32_t zc_defer_destroy; 507eda14cbcSMatt Macy uint32_t zc_flags; 508eda14cbcSMatt Macy uint64_t zc_action_handle; 509eda14cbcSMatt Macy int zc_cleanup_fd; 510eda14cbcSMatt Macy uint8_t zc_simple; 511eda14cbcSMatt Macy uint8_t zc_pad[3]; /* alignment */ 512eda14cbcSMatt Macy uint64_t zc_sendobj; 513eda14cbcSMatt Macy uint64_t zc_fromobj; 514eda14cbcSMatt Macy uint64_t zc_createtxg; 515eda14cbcSMatt Macy zfs_stat_t zc_stat; 516eda14cbcSMatt Macy uint64_t zc_zoneid; 517eda14cbcSMatt Macy } zfs_cmd_t; 518eda14cbcSMatt Macy 519eda14cbcSMatt Macy typedef struct zfs_useracct { 520eda14cbcSMatt Macy char zu_domain[256]; 521eda14cbcSMatt Macy uid_t zu_rid; 522eda14cbcSMatt Macy uint32_t zu_pad; 523eda14cbcSMatt Macy uint64_t zu_space; 524eda14cbcSMatt Macy } zfs_useracct_t; 525eda14cbcSMatt Macy 526eda14cbcSMatt Macy #define ZFSDEV_MAX_MINOR (1 << 16) 527eda14cbcSMatt Macy #define ZFS_MIN_MINOR (ZFSDEV_MAX_MINOR + 1) 528eda14cbcSMatt Macy 529eda14cbcSMatt Macy #define ZPOOL_EXPORT_AFTER_SPLIT 0x1 530eda14cbcSMatt Macy 531eda14cbcSMatt Macy #ifdef _KERNEL 532eda14cbcSMatt Macy struct objset; 533eda14cbcSMatt Macy struct zfsvfs; 534eda14cbcSMatt Macy 535eda14cbcSMatt Macy typedef struct zfs_creat { 536eda14cbcSMatt Macy nvlist_t *zct_zplprops; 537eda14cbcSMatt Macy nvlist_t *zct_props; 538eda14cbcSMatt Macy } zfs_creat_t; 539eda14cbcSMatt Macy 540eda14cbcSMatt Macy extern int zfs_secpolicy_snapshot_perms(const char *, cred_t *); 541eda14cbcSMatt Macy extern int zfs_secpolicy_rename_perms(const char *, const char *, cred_t *); 542eda14cbcSMatt Macy extern int zfs_secpolicy_destroy_perms(const char *, cred_t *); 543eda14cbcSMatt Macy extern void zfs_unmount_snap(const char *); 544eda14cbcSMatt Macy extern void zfs_destroy_unmount_origin(const char *); 545eda14cbcSMatt Macy extern int getzfsvfs_impl(struct objset *, struct zfsvfs **); 546eda14cbcSMatt Macy extern int getzfsvfs(const char *, struct zfsvfs **); 547eda14cbcSMatt Macy 548eda14cbcSMatt Macy enum zfsdev_state_type { 549eda14cbcSMatt Macy ZST_ONEXIT, 550eda14cbcSMatt Macy ZST_ZEVENT, 551eda14cbcSMatt Macy ZST_ALL, 552eda14cbcSMatt Macy }; 553eda14cbcSMatt Macy 554eda14cbcSMatt Macy /* 555eda14cbcSMatt Macy * The zfsdev_state_t structure is managed as a singly-linked list 556eda14cbcSMatt Macy * from which items are never deleted. This allows for lock-free 557eda14cbcSMatt Macy * reading of the list so long as assignments to the zs_next and 558eda14cbcSMatt Macy * reads from zs_minor are performed atomically. Empty items are 559eda14cbcSMatt Macy * indicated by storing -1 into zs_minor. 560eda14cbcSMatt Macy */ 561eda14cbcSMatt Macy typedef struct zfsdev_state { 562eda14cbcSMatt Macy struct zfsdev_state *zs_next; /* next zfsdev_state_t link */ 563eda14cbcSMatt Macy minor_t zs_minor; /* made up minor number */ 564eda14cbcSMatt Macy void *zs_onexit; /* onexit data */ 565eda14cbcSMatt Macy void *zs_zevent; /* zevent data */ 566eda14cbcSMatt Macy } zfsdev_state_t; 567eda14cbcSMatt Macy 568eda14cbcSMatt Macy extern void *zfsdev_get_state(minor_t minor, enum zfsdev_state_type which); 569eda14cbcSMatt Macy extern int zfsdev_getminor(int fd, minor_t *minorp); 570eda14cbcSMatt Macy extern minor_t zfsdev_minor_alloc(void); 571eda14cbcSMatt Macy 572eda14cbcSMatt Macy extern uint_t zfs_fsyncer_key; 573eda14cbcSMatt Macy extern uint_t zfs_allow_log_key; 574eda14cbcSMatt Macy 575eda14cbcSMatt Macy #endif /* _KERNEL */ 576eda14cbcSMatt Macy 577eda14cbcSMatt Macy #ifdef __cplusplus 578eda14cbcSMatt Macy } 579eda14cbcSMatt Macy #endif 580eda14cbcSMatt Macy 581eda14cbcSMatt Macy #endif /* _SYS_ZFS_IOCTL_H */ 582