Print this page
3748 zfs headers should be C++ compatible
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Will Andrews <willa@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>


  75 #define DMU_GET_FEATUREFLAGS(vi)        BF64_GET((vi), 2, 30)
  76 #define DMU_SET_FEATUREFLAGS(vi, x)     BF64_SET((vi), 2, 30, x)
  77 
  78 /*
  79  * Feature flags for zfs send streams (flags in drr_versioninfo)
  80  */
  81 
  82 #define DMU_BACKUP_FEATURE_DEDUP        (0x1)
  83 #define DMU_BACKUP_FEATURE_DEDUPPROPS   (0x2)
  84 #define DMU_BACKUP_FEATURE_SA_SPILL     (0x4)
  85 
  86 /*
  87  * Mask of all supported backup features
  88  */
  89 #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \
  90                 DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL)
  91 
  92 /* Are all features in the given flag word currently supported? */
  93 #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK))
  94 
  95 /*
  96  * The drr_versioninfo field of the dmu_replay_record has the
  97  * following layout:
  98  *
  99  *      64      56      48      40      32      24      16      8       0
 100  *      +-------+-------+-------+-------+-------+-------+-------+-------+
 101  *      |               reserved        |        feature-flags      |C|S|
 102  *      +-------+-------+-------+-------+-------+-------+-------+-------+
 103  *
 104  * The low order two bits indicate the header type: SUBSTREAM (0x1)
 105  * or COMPOUNDSTREAM (0x2).  Using two bits for this is historical:
 106  * this field used to be a version number, where the two version types
 107  * were 1 and 2.  Using two bits for this allows earlier versions of
 108  * the code to be able to recognize send streams that don't use any
 109  * of the features indicated by feature flags.
 110  */
 111 
 112 #define DMU_BACKUP_MAGIC 0x2F5bacbacULL
 113 
 114 #define DRR_FLAG_CLONE          (1<<0)
 115 #define DRR_FLAG_CI_DATA        (1<<1)
 116 
 117 /*
 118  * flags in the drr_checksumflags field in the DRR_WRITE and
 119  * DRR_WRITE_BYREF blocks
 120  */
 121 #define DRR_CHECKSUM_DEDUP      (1<<0)
 122 
 123 #define DRR_IS_DEDUP_CAPABLE(flags)     ((flags) & DRR_CHECKSUM_DEDUP)
 124 
 125 /*
 126  * zfs ioctl command structure
 127  */
 128 typedef struct dmu_replay_record {
 129         enum {
 130                 DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
 131                 DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
 132                 DRR_SPILL, DRR_NUMTYPES
 133         } drr_type;
 134         uint32_t drr_payloadlen;
 135         union {
 136                 struct drr_begin {
 137                         uint64_t drr_magic;
 138                         uint64_t drr_versioninfo; /* was drr_version */















 139                         uint64_t drr_creation_time;
 140                         dmu_objset_type_t drr_type;
 141                         uint32_t drr_flags;
 142                         uint64_t drr_toguid;
 143                         uint64_t drr_fromguid;
 144                         char drr_toname[MAXNAMELEN];
 145                 } drr_begin;
 146                 struct drr_end {

 147                         zio_cksum_t drr_checksum;
 148                         uint64_t drr_toguid;
 149                 } drr_end;
 150                 struct drr_object {

 151                         uint64_t drr_object;
 152                         dmu_object_type_t drr_type;
 153                         dmu_object_type_t drr_bonustype;
 154                         uint32_t drr_blksz;
 155                         uint32_t drr_bonuslen;
 156                         uint8_t drr_checksumtype;
 157                         uint8_t drr_compress;
 158                         uint8_t drr_pad[6];
 159                         uint64_t drr_toguid;
 160                         /* bonus content follows */
 161                 } drr_object;
 162                 struct drr_freeobjects {

 163                         uint64_t drr_firstobj;
 164                         uint64_t drr_numobjs;
 165                         uint64_t drr_toguid;
 166                 } drr_freeobjects;
 167                 struct drr_write {

 168                         uint64_t drr_object;
 169                         dmu_object_type_t drr_type;
 170                         uint32_t drr_pad;
 171                         uint64_t drr_offset;
 172                         uint64_t drr_length;
 173                         uint64_t drr_toguid;
 174                         uint8_t drr_checksumtype;
 175                         uint8_t drr_checksumflags;
 176                         uint8_t drr_pad2[6];
 177                         ddt_key_t drr_key; /* deduplication key */
 178                         /* content follows */
 179                 } drr_write;
 180                 struct drr_free {

 181                         uint64_t drr_object;
 182                         uint64_t drr_offset;
 183                         uint64_t drr_length;
 184                         uint64_t drr_toguid;
 185                 } drr_free;
 186                 struct drr_write_byref {
 187                         /* where to put the data */
 188                         uint64_t drr_object;
 189                         uint64_t drr_offset;
 190                         uint64_t drr_length;
 191                         uint64_t drr_toguid;
 192                         /* where to find the prior copy of the data */
 193                         uint64_t drr_refguid;
 194                         uint64_t drr_refobject;
 195                         uint64_t drr_refoffset;
 196                         /* properties of the data */
 197                         uint8_t drr_checksumtype;
 198                         uint8_t drr_checksumflags;
 199                         uint8_t drr_pad2[6];
 200                         ddt_key_t drr_key; /* deduplication key */
 201                 } drr_write_byref;
 202                 struct drr_spill {

 203                         uint64_t drr_object;
 204                         uint64_t drr_length;
 205                         uint64_t drr_toguid;
 206                         uint64_t drr_pad[4]; /* needed for crypto */
 207                         /* spill data follows */
 208                 } drr_spill;













 209         } drr_u;
 210 } dmu_replay_record_t;
 211 
 212 /* diff record range types */
 213 typedef enum diff_type {
 214         DDR_NONE = 0x1,
 215         DDR_INUSE = 0x2,
 216         DDR_FREE = 0x4
 217 } diff_type_t;
 218 
 219 /*
 220  * The diff reports back ranges of free or in-use objects.
 221  */
 222 typedef struct dmu_diff_record {
 223         uint64_t ddr_type;
 224         uint64_t ddr_first;
 225         uint64_t ddr_last;
 226 } dmu_diff_record_t;
 227 
 228 typedef struct zinject_record {




  75 #define DMU_GET_FEATUREFLAGS(vi)        BF64_GET((vi), 2, 30)
  76 #define DMU_SET_FEATUREFLAGS(vi, x)     BF64_SET((vi), 2, 30, x)
  77 
  78 /*
  79  * Feature flags for zfs send streams (flags in drr_versioninfo)
  80  */
  81 
  82 #define DMU_BACKUP_FEATURE_DEDUP        (0x1)
  83 #define DMU_BACKUP_FEATURE_DEDUPPROPS   (0x2)
  84 #define DMU_BACKUP_FEATURE_SA_SPILL     (0x4)
  85 
  86 /*
  87  * Mask of all supported backup features
  88  */
  89 #define DMU_BACKUP_FEATURE_MASK (DMU_BACKUP_FEATURE_DEDUP | \
  90                 DMU_BACKUP_FEATURE_DEDUPPROPS | DMU_BACKUP_FEATURE_SA_SPILL)
  91 
  92 /* Are all features in the given flag word currently supported? */
  93 #define DMU_STREAM_SUPPORTED(x) (!((x) & ~DMU_BACKUP_FEATURE_MASK))
  94 

















  95 #define DMU_BACKUP_MAGIC 0x2F5bacbacULL
  96 
  97 #define DRR_FLAG_CLONE          (1<<0)
  98 #define DRR_FLAG_CI_DATA        (1<<1)
  99 
 100 /*
 101  * flags in the drr_checksumflags field in the DRR_WRITE and
 102  * DRR_WRITE_BYREF blocks
 103  */
 104 #define DRR_CHECKSUM_DEDUP      (1<<0)
 105 
 106 #define DRR_IS_DEDUP_CAPABLE(flags)     ((flags) & DRR_CHECKSUM_DEDUP)
 107 
 108 /*
 109  * zfs ioctl command structure
 110  */
 111 enum drr_type {

 112         DRR_BEGIN, DRR_OBJECT, DRR_FREEOBJECTS,
 113         DRR_WRITE, DRR_FREE, DRR_END, DRR_WRITE_BYREF,
 114         DRR_SPILL, DRR_NUMTYPES
 115 };
 116 
 117 struct drr_begin {

 118         uint64_t drr_magic;
 119         /*
 120          * Formerly named drr_version, this field has the following layout:
 121          *
 122          *  64      56      48      40      32      24      16      8       0
 123          *  +-------+-------+-------+-------+-------+-------+-------+-------+
 124          *  |               reserved        |        feature-flags      |C|S|
 125          *  +-------+-------+-------+-------+-------+-------+-------+-------+
 126          *
 127          * The low order two bits indicate the header type: SUBSTREAM (0x1)
 128          * or COMPOUNDSTREAM (0x2).  Using two bits for this is historical:
 129          * this field used to be a version number, where the two version types
 130          * were 1 and 2.  Using two bits for this allows earlier versions of
 131          * the code to be able to recognize send streams that don't use any
 132          * of the features indicated by feature flags.
 133          */
 134         uint64_t drr_versioninfo;
 135         uint64_t drr_creation_time;
 136         dmu_objset_type_t drr_type;
 137         uint32_t drr_flags;
 138         uint64_t drr_toguid;
 139         uint64_t drr_fromguid;
 140         char drr_toname[MAXNAMELEN];
 141 };
 142 
 143 struct drr_end {
 144         zio_cksum_t drr_checksum;
 145         uint64_t drr_toguid;
 146 };
 147 
 148 struct drr_object {
 149         uint64_t drr_object;
 150         dmu_object_type_t drr_type;
 151         dmu_object_type_t drr_bonustype;
 152         uint32_t drr_blksz;
 153         uint32_t drr_bonuslen;
 154         uint8_t drr_checksumtype;
 155         uint8_t drr_compress;
 156         uint8_t drr_pad[6];
 157         uint64_t drr_toguid;
 158         /* bonus content follows */
 159 };
 160 
 161 struct drr_freeobjects {
 162         uint64_t drr_firstobj;
 163         uint64_t drr_numobjs;
 164         uint64_t drr_toguid;
 165 };
 166 
 167 struct drr_write {
 168         uint64_t drr_object;
 169         dmu_object_type_t drr_type;
 170         uint32_t drr_pad;
 171         uint64_t drr_offset;
 172         uint64_t drr_length;
 173         uint64_t drr_toguid;
 174         uint8_t drr_checksumtype;
 175         uint8_t drr_checksumflags;
 176         uint8_t drr_pad2[6];
 177         ddt_key_t drr_key;      /* deduplication key */
 178         /* content follows */
 179 };
 180 
 181 struct drr_free {
 182         uint64_t drr_object;
 183         uint64_t drr_offset;
 184         uint64_t drr_length;
 185         uint64_t drr_toguid;
 186 };
 187 
 188 struct drr_write_byref {
 189         uint64_t drr_object;    /* where to put the data */
 190         uint64_t drr_offset;
 191         uint64_t drr_length;
 192         uint64_t drr_toguid;    /* where to find the prior copy of the data */

 193         uint64_t drr_refguid;
 194         uint64_t drr_refobject;
 195         uint64_t drr_refoffset; /* properties of the data */

 196         uint8_t drr_checksumtype;
 197         uint8_t drr_checksumflags;
 198         uint8_t drr_pad2[6];
 199         ddt_key_t drr_key;      /* deduplication key */
 200 };
 201 
 202 struct drr_spill {
 203         uint64_t drr_object;
 204         uint64_t drr_length;
 205         uint64_t drr_toguid;
 206         uint64_t drr_pad[4];    /* needed for crypto */
 207         /* spill data follows */
 208 };
 209 
 210 typedef struct dmu_replay_record {
 211         enum drr_type drr_type;
 212         uint32_t drr_payloadlen;
 213         union {
 214                 struct drr_begin drr_begin;
 215                 struct drr_end drr_end;
 216                 struct drr_object drr_object;
 217                 struct drr_freeobjects drr_freeobjects;
 218                 struct drr_write drr_write;
 219                 struct drr_free drr_free;
 220                 struct drr_write_byref drr_write_byref;
 221                 struct drr_spill drr_spill;
 222         } drr_u;
 223 } dmu_replay_record_t;
 224 
 225 /* diff record range types */
 226 typedef enum diff_type {
 227         DDR_NONE = 0x1,
 228         DDR_INUSE = 0x2,
 229         DDR_FREE = 0x4
 230 } diff_type_t;
 231 
 232 /*
 233  * The diff reports back ranges of free or in-use objects.
 234  */
 235 typedef struct dmu_diff_record {
 236         uint64_t ddr_type;
 237         uint64_t ddr_first;
 238         uint64_t ddr_last;
 239 } dmu_diff_record_t;
 240 
 241 typedef struct zinject_record {