46 /*
47 * DDT classes, in the desired search order (highest replication level first).
48 */
49 enum ddt_class {
50 DDT_CLASS_DITTO = 0,
51 DDT_CLASS_DUPLICATE,
52 DDT_CLASS_UNIQUE,
53 DDT_CLASSES
54 };
55
56 #define DDT_TYPE_CURRENT 0
57
58 #define DDT_COMPRESS_BYTEORDER_MASK 0x80
59 #define DDT_COMPRESS_FUNCTION_MASK 0x7f
60
61 /*
62 * On-disk ddt entry: key (name) and physical storage (value).
63 */
64 typedef struct ddt_key {
65 zio_cksum_t ddk_cksum; /* 256-bit block checksum */
66 uint64_t ddk_prop; /* LSIZE, PSIZE, compression */
67 } ddt_key_t;
68
69 /*
70 * ddk_prop layout:
71 *
72 * +-------+-------+-------+-------+-------+-------+-------+-------+
73 * | 0 | 0 | 0 | comp | PSIZE | LSIZE |
74 * +-------+-------+-------+-------+-------+-------+-------+-------+
75 */
76 #define DDK_GET_LSIZE(ddk) \
77 BF64_GET_SB((ddk)->ddk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
78 #define DDK_SET_LSIZE(ddk, x) \
79 BF64_SET_SB((ddk)->ddk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
80
81 #define DDK_GET_PSIZE(ddk) \
82 BF64_GET_SB((ddk)->ddk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)
83 #define DDK_SET_PSIZE(ddk, x) \
84 BF64_SET_SB((ddk)->ddk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)
85
86 #define DDK_GET_COMPRESS(ddk) BF64_GET((ddk)->ddk_prop, 32, 8)
87 #define DDK_SET_COMPRESS(ddk, x) BF64_SET((ddk)->ddk_prop, 32, 8, x)
88
89 #define DDT_KEY_WORDS (sizeof (ddt_key_t) / sizeof (uint64_t))
90
91 typedef struct ddt_phys {
92 dva_t ddp_dva[SPA_DVAS_PER_BP];
93 uint64_t ddp_refcnt;
94 uint64_t ddp_phys_birth;
95 } ddt_phys_t;
|
46 /*
47 * DDT classes, in the desired search order (highest replication level first).
48 */
49 enum ddt_class {
50 DDT_CLASS_DITTO = 0,
51 DDT_CLASS_DUPLICATE,
52 DDT_CLASS_UNIQUE,
53 DDT_CLASSES
54 };
55
56 #define DDT_TYPE_CURRENT 0
57
58 #define DDT_COMPRESS_BYTEORDER_MASK 0x80
59 #define DDT_COMPRESS_FUNCTION_MASK 0x7f
60
61 /*
62 * On-disk ddt entry: key (name) and physical storage (value).
63 */
64 typedef struct ddt_key {
65 zio_cksum_t ddk_cksum; /* 256-bit block checksum */
66 /*
67 * Encoded with logical & physical size, and compression, as follows:
68 * +-------+-------+-------+-------+-------+-------+-------+-------+
69 * | 0 | 0 | 0 | comp | PSIZE | LSIZE |
70 * +-------+-------+-------+-------+-------+-------+-------+-------+
71 */
72 uint64_t ddk_prop;
73 } ddt_key_t;
74
75 #define DDK_GET_LSIZE(ddk) \
76 BF64_GET_SB((ddk)->ddk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1)
77 #define DDK_SET_LSIZE(ddk, x) \
78 BF64_SET_SB((ddk)->ddk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x)
79
80 #define DDK_GET_PSIZE(ddk) \
81 BF64_GET_SB((ddk)->ddk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1)
82 #define DDK_SET_PSIZE(ddk, x) \
83 BF64_SET_SB((ddk)->ddk_prop, 16, 16, SPA_MINBLOCKSHIFT, 1, x)
84
85 #define DDK_GET_COMPRESS(ddk) BF64_GET((ddk)->ddk_prop, 32, 8)
86 #define DDK_SET_COMPRESS(ddk, x) BF64_SET((ddk)->ddk_prop, 32, 8, x)
87
88 #define DDT_KEY_WORDS (sizeof (ddt_key_t) / sizeof (uint64_t))
89
90 typedef struct ddt_phys {
91 dva_t ddp_dva[SPA_DVAS_PER_BP];
92 uint64_t ddp_refcnt;
93 uint64_t ddp_phys_birth;
94 } ddt_phys_t;
|