128
129 /* Checksum Functions */
130 static void
131 zio_checksum_off(const void *buf, uint64_t size, zio_cksum_t *zcp)
132 {
133 ZIO_SET_CHECKSUM(zcp, 0, 0, 0, 0);
134 }
135
136 /* Checksum Table and Values */
137 zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
138 {{NULL, NULL}, 0, 0, "inherit"},
139 {{NULL, NULL}, 0, 0, "on"},
140 {{zio_checksum_off, zio_checksum_off}, 0, 0, "off"},
141 {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 1, "label"},
142 {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 1, "gang_header"},
143 {{NULL, NULL}, 0, 0, "zilog"},
144 {{fletcher_2_native, fletcher_2_byteswap}, 0, 0, "fletcher2"},
145 {{fletcher_4_native, fletcher_4_byteswap}, 1, 0, "fletcher4"},
146 {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 0, "SHA256"},
147 {{NULL, NULL}, 0, 0, "zilog2"},
148 };
149
150 /*
151 * zio_checksum_verify: Provides support for checksum verification.
152 *
153 * Fletcher2, Fletcher4, and SHA256 are supported.
154 *
155 * Return:
156 * -1 = Failure
157 * 0 = Success
158 */
159 static int
160 zio_checksum_verify(blkptr_t *bp, char *data, int size)
161 {
162 zio_cksum_t zc = bp->blk_cksum;
163 uint32_t checksum = BP_GET_CHECKSUM(bp);
164 int byteswap = BP_SHOULD_BYTESWAP(bp);
165 zio_eck_t *zec = (zio_eck_t *)(data + size) - 1;
166 zio_checksum_info_t *ci = &zio_checksum_table[checksum];
167 zio_cksum_t actual_cksum, expected_cksum;
168
169 /* byteswap is not supported */
170 if (byteswap)
171 return (-1);
172
173 if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
949 if (zap_lookup(dn, ZPOOL_PROP_BOOTFS, &objnum, stack))
950 return (ERR_FILESYSTEM_NOT_FOUND);
951
952 if (!objnum)
953 return (ERR_FILESYSTEM_NOT_FOUND);
954
955 *obj = objnum;
956 return (0);
957 }
958
959 /*
960 * List of pool features that the grub implementation of ZFS supports for
961 * read. Note that features that are only required for write do not need
962 * to be listed here since grub opens pools in read-only mode.
963 *
964 * When this list is updated the version number in usr/src/grub/capability
965 * must be incremented to ensure the new grub gets installed.
966 */
967 static const char *spa_feature_names[] = {
968 "org.illumos:lz4_compress",
969 NULL
970 };
971
972 /*
973 * Checks whether the MOS features that are active are supported by this
974 * (GRUB's) implementation of ZFS.
975 *
976 * Return:
977 * 0: Success.
978 * errnum: Failure.
979 */
980 static int
981 check_mos_features(dnode_phys_t *mosmdn, char *stack)
982 {
983 uint64_t objnum;
984 dnode_phys_t *dn;
985 uint8_t error = 0;
986
987 dn = (dnode_phys_t *)stack;
988 stack += DNODE_SIZE;
|
128
129 /* Checksum Functions */
130 static void
131 zio_checksum_off(const void *buf, uint64_t size, zio_cksum_t *zcp)
132 {
133 ZIO_SET_CHECKSUM(zcp, 0, 0, 0, 0);
134 }
135
136 /* Checksum Table and Values */
137 zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
138 {{NULL, NULL}, 0, 0, "inherit"},
139 {{NULL, NULL}, 0, 0, "on"},
140 {{zio_checksum_off, zio_checksum_off}, 0, 0, "off"},
141 {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 1, "label"},
142 {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 1, "gang_header"},
143 {{NULL, NULL}, 0, 0, "zilog"},
144 {{fletcher_2_native, fletcher_2_byteswap}, 0, 0, "fletcher2"},
145 {{fletcher_4_native, fletcher_4_byteswap}, 1, 0, "fletcher4"},
146 {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 0, "SHA256"},
147 {{NULL, NULL}, 0, 0, "zilog2"},
148 {{zio_checksum_SHA512, NULL}, 0, 0, "SHA512"}
149 };
150
151 /*
152 * zio_checksum_verify: Provides support for checksum verification.
153 *
154 * Fletcher2, Fletcher4, SHA-256 and SHA-512/256 are supported.
155 *
156 * Return:
157 * -1 = Failure
158 * 0 = Success
159 */
160 static int
161 zio_checksum_verify(blkptr_t *bp, char *data, int size)
162 {
163 zio_cksum_t zc = bp->blk_cksum;
164 uint32_t checksum = BP_GET_CHECKSUM(bp);
165 int byteswap = BP_SHOULD_BYTESWAP(bp);
166 zio_eck_t *zec = (zio_eck_t *)(data + size) - 1;
167 zio_checksum_info_t *ci = &zio_checksum_table[checksum];
168 zio_cksum_t actual_cksum, expected_cksum;
169
170 /* byteswap is not supported */
171 if (byteswap)
172 return (-1);
173
174 if (checksum >= ZIO_CHECKSUM_FUNCTIONS || ci->ci_func[0] == NULL)
950 if (zap_lookup(dn, ZPOOL_PROP_BOOTFS, &objnum, stack))
951 return (ERR_FILESYSTEM_NOT_FOUND);
952
953 if (!objnum)
954 return (ERR_FILESYSTEM_NOT_FOUND);
955
956 *obj = objnum;
957 return (0);
958 }
959
960 /*
961 * List of pool features that the grub implementation of ZFS supports for
962 * read. Note that features that are only required for write do not need
963 * to be listed here since grub opens pools in read-only mode.
964 *
965 * When this list is updated the version number in usr/src/grub/capability
966 * must be incremented to ensure the new grub gets installed.
967 */
968 static const char *spa_feature_names[] = {
969 "org.illumos:lz4_compress",
970 "org.illumos:sha512",
971 NULL
972 };
973
974 /*
975 * Checks whether the MOS features that are active are supported by this
976 * (GRUB's) implementation of ZFS.
977 *
978 * Return:
979 * 0: Success.
980 * errnum: Failure.
981 */
982 static int
983 check_mos_features(dnode_phys_t *mosmdn, char *stack)
984 {
985 uint64_t objnum;
986 dnode_phys_t *dn;
987 uint8_t error = 0;
988
989 dn = (dnode_phys_t *)stack;
990 stack += DNODE_SIZE;
|