Print this page
Integrated Edon-R hash function.


 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;


 946         if (errnum = dnode_get(mosmdn, objnum, DMU_OT_POOL_PROPS, dn, stack))
 947                 return (errnum);
 948 
 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 static const char *spa_feature_names[] = {
 965         "org.illumos:lz4_compress",

 966         NULL
 967 };
 968 
 969 /*
 970  * Checks whether the MOS features that are active are supported by this
 971  * (GRUB's) implementation of ZFS.
 972  *
 973  * Return:
 974  *      0: Success.
 975  *      errnum: Failure.
 976  */
 977 static int
 978 check_mos_features(dnode_phys_t *mosmdn, char *stack)
 979 {
 980         uint64_t objnum;
 981         dnode_phys_t *dn;
 982         uint8_t error = 0;
 983 
 984         dn = (dnode_phys_t *)stack;
 985         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_EdonR512_256,    zio_checksum_EdonR512_256_byteswap},
 149             1, 0,       "edonr512/256"}
 150 };
 151 
 152 /*
 153  * zio_checksum_verify: Provides support for checksum verification.
 154  *
 155  * Fletcher2, Fletcher4, and SHA256 are supported.
 156  *
 157  * Return:
 158  *      -1 = Failure
 159  *       0 = Success
 160  */
 161 static int
 162 zio_checksum_verify(blkptr_t *bp, char *data, int size)
 163 {
 164         zio_cksum_t zc = bp->blk_cksum;
 165         uint32_t checksum = BP_GET_CHECKSUM(bp);
 166         int byteswap = BP_SHOULD_BYTESWAP(bp);
 167         zio_eck_t *zec = (zio_eck_t *)(data + size) - 1;
 168         zio_checksum_info_t *ci = &zio_checksum_table[checksum];
 169         zio_cksum_t actual_cksum, expected_cksum;


 948         if (errnum = dnode_get(mosmdn, objnum, DMU_OT_POOL_PROPS, dn, stack))
 949                 return (errnum);
 950 
 951         if (zap_lookup(dn, ZPOOL_PROP_BOOTFS, &objnum, stack))
 952                 return (ERR_FILESYSTEM_NOT_FOUND);
 953 
 954         if (!objnum)
 955                 return (ERR_FILESYSTEM_NOT_FOUND);
 956 
 957         *obj = objnum;
 958         return (0);
 959 }
 960 
 961 /*
 962  * List of pool features that the grub implementation of ZFS supports for
 963  * read. Note that features that are only required for write do not need
 964  * to be listed here since grub opens pools in read-only mode.
 965  */
 966 static const char *spa_feature_names[] = {
 967         "org.illumos:lz4_compress",
 968         "org.illumos:edonr_cksum",
 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;