]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/sys/zfs_ioctl.h
Fix send/recv lost spill block
[mirror_zfs.git] / include / sys / zfs_ioctl.h
index 301f83232bd2244a2995c850bef419fb0e7f3938..a883c335857c3b97c70dbcc0037349ef2e1a1ceb 100644 (file)
@@ -20,7 +20,9 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
+ * Copyright 2016 RackTop Systems.
+ * Copyright (c) 2017, Intel Corporation.
  */
 
 #ifndef        _SYS_ZFS_IOCTL_H
@@ -90,34 +92,46 @@ typedef enum drr_headertype {
  * Feature flags for zfs send streams (flags in drr_versioninfo)
  */
 
-#define        DMU_BACKUP_FEATURE_DEDUP                (1<<0)
-#define        DMU_BACKUP_FEATURE_DEDUPPROPS           (1<<1)
-#define        DMU_BACKUP_FEATURE_SA_SPILL             (1<<2)
+#define        DMU_BACKUP_FEATURE_DEDUP                (1 << 0)
+#define        DMU_BACKUP_FEATURE_DEDUPPROPS           (1 << 1)
+#define        DMU_BACKUP_FEATURE_SA_SPILL             (1 << 2)
 /* flags #3 - #15 are reserved for incompatible closed-source implementations */
-#define        DMU_BACKUP_FEATURE_EMBED_DATA           (1<<16)
-#define        DMU_BACKUP_FEATURE_EMBED_DATA_LZ4       (1<<17)
+#define        DMU_BACKUP_FEATURE_EMBED_DATA           (1 << 16)
+#define        DMU_BACKUP_FEATURE_LZ4                  (1 << 17)
 /* flag #18 is reserved for a Delphix feature */
-#define        DMU_BACKUP_FEATURE_LARGE_BLOCKS         (1<<19)
-#define        DMU_BACKUP_FEATURE_LARGE_DNODE          (1<<20)
+#define        DMU_BACKUP_FEATURE_LARGE_BLOCKS         (1 << 19)
+#define        DMU_BACKUP_FEATURE_RESUMING             (1 << 20)
+/* flag #21 is reserved for the redacted send/receive feature */
+#define        DMU_BACKUP_FEATURE_COMPRESSED           (1 << 22)
+#define        DMU_BACKUP_FEATURE_LARGE_DNODE          (1 << 23)
+#define        DMU_BACKUP_FEATURE_RAW                  (1 << 24)
+/* flag #25 is reserved for the ZSTD compression feature */
+#define        DMU_BACKUP_FEATURE_HOLDS                (1 << 26)
 
 /*
  * Mask of all supported backup features
  */
 #define        DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \
     DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL | \
-    DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_EMBED_DATA_LZ4 | \
-    DMU_BACKUP_FEATURE_LARGE_BLOCKS | DMU_BACKUP_FEATURE_LARGE_DNODE)
+    DMU_BACKUP_FEATURE_EMBED_DATA | DMU_BACKUP_FEATURE_LZ4 | \
+    DMU_BACKUP_FEATURE_RESUMING | DMU_BACKUP_FEATURE_LARGE_BLOCKS | \
+    DMU_BACKUP_FEATURE_COMPRESSED | DMU_BACKUP_FEATURE_LARGE_DNODE | \
+    DMU_BACKUP_FEATURE_RAW | DMU_BACKUP_FEATURE_HOLDS)
 
 /* Are all features in the given flag word currently supported? */
 #define        DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK))
 
+typedef enum dmu_send_resume_token_version {
+       ZFS_SEND_RESUME_TOKEN_VERSION = 1
+} dmu_send_resume_token_version_t;
+
 /*
  * The drr_versioninfo field of the dmu_replay_record has the
  * following layout:
  *
  *     64      56      48      40      32      24      16      8       0
  *     +-------+-------+-------+-------+-------+-------+-------+-------+
- *     |               reserved        |        feature-flags      |C|S|
+ *     |               reserved        |        feature-flags      |C|S|
  *     +-------+-------+-------+-------+-------+-------+-------+-------+
  *
  * The low order two bits indicate the header type: SUBSTREAM (0x1)
@@ -130,16 +144,66 @@ typedef enum drr_headertype {
 
 #define        DMU_BACKUP_MAGIC 0x2F5bacbacULL
 
+/*
+ * Send stream flags.  Bits 24-31 are reserved for vendor-specific
+ * implementations and should not be used.
+ */
 #define        DRR_FLAG_CLONE          (1<<0)
 #define        DRR_FLAG_CI_DATA        (1<<1)
+/*
+ * This send stream, if it is a full send, includes the FREE and FREEOBJECT
+ * records that are created by the sending process.  This means that the send
+ * stream can be received as a clone, even though it is not an incremental.
+ * This is not implemented as a feature flag, because the receiving side does
+ * not need to have implemented it to receive this stream; it is fully backwards
+ * compatible.  We need a flag, though, because full send streams without it
+ * cannot necessarily be received as a clone correctly.
+ */
+#define        DRR_FLAG_FREERECORDS    (1<<2)
+/*
+ * When DRR_FLAG_SPILL_BLOCK is set it indicates the DRR_OBJECT_SPILL
+ * and DRR_SPILL_UNMODIFIED flags are meaningful in the send stream.
+ *
+ * When DRR_FLAG_SPILL_BLOCK is set, DRR_OBJECT records will have
+ * DRR_OBJECT_SPILL set if and only if they should have a spill block
+ * (either an existing one, or a new one in the send stream).  When clear
+ * the object does not have a spill block and any existing spill block
+ * should be freed.
+ *
+ * Similarly, when DRR_FLAG_SPILL_BLOCK is set, DRR_SPILL records will
+ * have DRR_SPILL_UNMODIFIED set if and only if they were included for
+ * backward compatibility purposes, and can be safely ignored by new versions
+ * of zfs receive.  Previous versions of ZFS which do not understand the
+ * DRR_FLAG_SPILL_BLOCK will process this record and recreate any missing
+ * spill blocks.
+ */
+#define        DRR_FLAG_SPILL_BLOCK    (1<<3)
 
 /*
- * flags in the drr_checksumflags field in the DRR_WRITE and
- * DRR_WRITE_BYREF blocks
+ * flags in the drr_flags field in the DRR_WRITE, DRR_SPILL, DRR_OBJECT,
+ * DRR_WRITE_BYREF, and DRR_OBJECT_RANGE blocks
  */
-#define        DRR_CHECKSUM_DEDUP      (1<<0)
+#define        DRR_CHECKSUM_DEDUP      (1<<0) /* not used for SPILL records */
+#define        DRR_RAW_BYTESWAP        (1<<1)
+#define        DRR_OBJECT_SPILL        (1<<2) /* OBJECT record has a spill block */
+#define        DRR_SPILL_UNMODIFIED    (1<<2) /* SPILL record for unmodified block */
 
 #define        DRR_IS_DEDUP_CAPABLE(flags)     ((flags) & DRR_CHECKSUM_DEDUP)
+#define        DRR_IS_RAW_BYTESWAPPED(flags)   ((flags) & DRR_RAW_BYTESWAP)
+#define        DRR_OBJECT_HAS_SPILL(flags)     ((flags) & DRR_OBJECT_SPILL)
+#define        DRR_SPILL_IS_UNMODIFIED(flags)  ((flags) & DRR_SPILL_UNMODIFIED)
+
+/* deal with compressed drr_write replay records */
+#define        DRR_WRITE_COMPRESSED(drrw)      ((drrw)->drr_compressiontype != 0)
+#define        DRR_WRITE_PAYLOAD_SIZE(drrw) \
+       (DRR_WRITE_COMPRESSED(drrw) ? (drrw)->drr_compressed_size : \
+       (drrw)->drr_logical_size)
+#define        DRR_SPILL_PAYLOAD_SIZE(drrs) \
+       ((drrs)->drr_compressed_size ? \
+       (drrs)->drr_compressed_size : (drrs)->drr_length)
+#define        DRR_OBJECT_PAYLOAD_SIZE(drro) \
+       ((drro)->drr_raw_bonuslen != 0 ? \
+       (drro)->drr_raw_bonuslen : P2ROUNDUP((drro)->drr_bonuslen, 8))
 
 /*
  * zfs ioctl command structure
@@ -148,7 +212,8 @@ typedef struct dmu_replay_record {
        enum {
                DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
                DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
-               DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_NUMTYPES
+               DRR_SPILL, DRR_WRITE_EMBEDDED, DRR_OBJECT_RANGE,
+               DRR_NUMTYPES
        } drr_type;
        uint32_t drr_payloadlen;
        union {
@@ -175,8 +240,15 @@ typedef struct dmu_replay_record {
                        uint8_t drr_checksumtype;
                        uint8_t drr_compress;
                        uint8_t drr_dn_slots;
-                       uint8_t drr_pad[5];
+                       uint8_t drr_flags;
+                       uint32_t drr_raw_bonuslen;
                        uint64_t drr_toguid;
+                       /* only (possibly) nonzero for raw streams */
+                       uint8_t drr_indblkshift;
+                       uint8_t drr_nlevels;
+                       uint8_t drr_nblkptr;
+                       uint8_t drr_pad[5];
+                       uint64_t drr_maxblkid;
                        /* bonus content follows */
                } drr_object;
                struct drr_freeobjects {
@@ -189,12 +261,20 @@ typedef struct dmu_replay_record {
                        dmu_object_type_t drr_type;
                        uint32_t drr_pad;
                        uint64_t drr_offset;
-                       uint64_t drr_length;
+                       uint64_t drr_logical_size;
                        uint64_t drr_toguid;
                        uint8_t drr_checksumtype;
-                       uint8_t drr_checksumflags;
-                       uint8_t drr_pad2[6];
-                       ddt_key_t drr_key; /* deduplication key */
+                       uint8_t drr_flags;
+                       uint8_t drr_compressiontype;
+                       uint8_t drr_pad2[5];
+                       /* deduplication key */
+                       ddt_key_t drr_key;
+                       /* only nonzero if drr_compressiontype is not 0 */
+                       uint64_t drr_compressed_size;
+                       /* only nonzero for raw streams */
+                       uint8_t drr_salt[ZIO_DATA_SALT_LEN];
+                       uint8_t drr_iv[ZIO_DATA_IV_LEN];
+                       uint8_t drr_mac[ZIO_DATA_MAC_LEN];
                        /* content follows */
                } drr_write;
                struct drr_free {
@@ -215,7 +295,7 @@ typedef struct dmu_replay_record {
                        uint64_t drr_refoffset;
                        /* properties of the data */
                        uint8_t drr_checksumtype;
-                       uint8_t drr_checksumflags;
+                       uint8_t drr_flags;
                        uint8_t drr_pad2[6];
                        ddt_key_t drr_key; /* deduplication key */
                } drr_write_byref;
@@ -223,7 +303,15 @@ typedef struct dmu_replay_record {
                        uint64_t drr_object;
                        uint64_t drr_length;
                        uint64_t drr_toguid;
-                       uint64_t drr_pad[4]; /* needed for crypto */
+                       uint8_t drr_flags;
+                       uint8_t drr_compressiontype;
+                       uint8_t drr_pad[6];
+                       /* only nonzero for raw streams */
+                       uint64_t drr_compressed_size;
+                       uint8_t drr_salt[ZIO_DATA_SALT_LEN];
+                       uint8_t drr_iv[ZIO_DATA_IV_LEN];
+                       uint8_t drr_mac[ZIO_DATA_MAC_LEN];
+                       dmu_object_type_t drr_type;
                        /* spill data follows */
                } drr_spill;
                struct drr_write_embedded {
@@ -239,6 +327,16 @@ typedef struct dmu_replay_record {
                        uint32_t drr_psize; /* compr. (real) size of payload */
                        /* (possibly compressed) content follows */
                } drr_write_embedded;
+               struct drr_object_range {
+                       uint64_t drr_firstobj;
+                       uint64_t drr_numslots;
+                       uint64_t drr_toguid;
+                       uint8_t drr_salt[ZIO_DATA_SALT_LEN];
+                       uint8_t drr_iv[ZIO_DATA_IV_LEN];
+                       uint8_t drr_mac[ZIO_DATA_MAC_LEN];
+                       uint8_t drr_flags;
+                       uint8_t drr_pad[3];
+               } drr_object_range;
 
                /*
                 * Nore: drr_checksum is overlaid with all record types
@@ -291,12 +389,13 @@ typedef struct zinject_record {
        uint64_t        zi_timer;
        uint64_t        zi_nlanes;
        uint32_t        zi_cmd;
-       uint32_t        zi_pad;
+       uint32_t        zi_dvas;
 } zinject_record_t;
 
 #define        ZINJECT_NULL            0x1
 #define        ZINJECT_FLUSH_ARC       0x2
 #define        ZINJECT_UNLOAD_SPA      0x4
+#define        ZINJECT_CALC_RANGE      0x8
 
 #define        ZEVENT_NONE             0x0
 #define        ZEVENT_NONBLOCK         0x1
@@ -305,6 +404,12 @@ typedef struct zinject_record {
 #define        ZEVENT_SEEK_START       0
 #define        ZEVENT_SEEK_END         UINT64_MAX
 
+/* scaled frequency ranges */
+#define        ZI_PERCENTAGE_MIN       4294UL
+#define        ZI_PERCENTAGE_MAX       UINT32_MAX
+
+#define        ZI_NO_DVA               (-1)
+
 typedef enum zinject_type {
        ZINJECT_UNINITIALIZED,
        ZINJECT_DATA_FAULT,
@@ -313,6 +418,7 @@ typedef enum zinject_type {
        ZINJECT_IGNORED_WRITES,
        ZINJECT_PANIC,
        ZINJECT_DELAY_IO,
+       ZINJECT_DECRYPT_FAULT,
 } zinject_type_t;
 
 typedef struct zfs_share {
@@ -334,6 +440,12 @@ typedef enum zfs_case {
        ZFS_CASE_MIXED
 } zfs_case_t;
 
+/*
+ * Note: this struct must have the same layout in 32-bit and 64-bit, so
+ * that 32-bit processes (like /sbin/zfs) can pass it to the 64-bit
+ * kernel.  Therefore, we add padding to it so that no "hidden" padding
+ * is automatically added on 64-bit (but not on 32-bit).
+ */
 typedef struct zfs_cmd {
        char            zc_name[MAXPATHLEN];    /* name of pool or dataset */
        uint64_t        zc_nvlist_src;          /* really (char *) */
@@ -389,20 +501,21 @@ typedef struct zfs_useracct {
 #define        ZPOOL_EXPORT_AFTER_SPLIT 0x1
 
 #ifdef _KERNEL
+struct objset;
+struct zfsvfs;
 
 typedef struct zfs_creat {
        nvlist_t        *zct_zplprops;
        nvlist_t        *zct_props;
 } zfs_creat_t;
 
-extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
-extern int zfs_secpolicy_rename_perms(const char *from,
-    const char *to, cred_t *cr);
-extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
-extern int zfs_unmount_snap(const char *);
+extern int zfs_secpolicy_snapshot_perms(const char *, cred_t *);
+extern int zfs_secpolicy_rename_perms(const char *, const char *, cred_t *);
+extern int zfs_secpolicy_destroy_perms(const char *, cred_t *);
+extern void zfs_unmount_snap(const char *);
 extern void zfs_destroy_unmount_origin(const char *);
-
-extern boolean_t dataset_name_hidden(const char *name);
+extern int getzfsvfs_impl(struct objset *, struct zfsvfs **);
+extern int getzfsvfs(const char *, struct zfsvfs **);
 
 enum zfsdev_state_type {
        ZST_ONEXIT,