ZFS zlib compression support

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-12-04 00:40:44 +01:00
parent 78ab87f61d
commit 7a6e93788c
2 changed files with 29 additions and 3 deletions

View file

@ -51,6 +51,7 @@
#include <grub/zfs/sa_impl.h> #include <grub/zfs/sa_impl.h>
#include <grub/zfs/dsl_dir.h> #include <grub/zfs/dsl_dir.h>
#include <grub/zfs/dsl_dataset.h> #include <grub/zfs/dsl_dataset.h>
#include <grub/deflate.h>
#define ZPOOL_PROP_BOOTFS "bootfs" #define ZPOOL_PROP_BOOTFS "bootfs"
@ -161,13 +162,30 @@ struct grub_zfs_data
grub_disk_addr_t vdev_phys_sector; grub_disk_addr_t vdev_phys_sector;
}; };
static grub_err_t
zlib_decompress (void *s, void *d,
grub_size_t slen, grub_size_t dlen)
{
if (grub_zlib_decompress (s, slen, 0, d, dlen) < 0)
return grub_errno;
return GRUB_ERR_NONE;
}
decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = { decomp_entry_t decomp_table[ZIO_COMPRESS_FUNCTIONS] = {
{"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */ {"inherit", NULL}, /* ZIO_COMPRESS_INHERIT */
{"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */ {"on", lzjb_decompress}, /* ZIO_COMPRESS_ON */
{"off", NULL}, /* ZIO_COMPRESS_OFF */ {"off", NULL}, /* ZIO_COMPRESS_OFF */
{"lzjb", lzjb_decompress}, /* ZIO_COMPRESS_LZJB */ {"lzjb", lzjb_decompress}, /* ZIO_COMPRESS_LZJB */
{"empty", NULL}, /* ZIO_COMPRESS_EMPTY */ {"empty", NULL}, /* ZIO_COMPRESS_EMPTY */
{"gzip", NULL}, /* ZIO_COMPRESS_GZIP */ {"gzip-1", zlib_decompress}, /* ZIO_COMPRESS_GZIP1 */
{"gzip-2", zlib_decompress}, /* ZIO_COMPRESS_GZIP2 */
{"gzip-3", zlib_decompress}, /* ZIO_COMPRESS_GZIP3 */
{"gzip-4", zlib_decompress}, /* ZIO_COMPRESS_GZIP4 */
{"gzip-5", zlib_decompress}, /* ZIO_COMPRESS_GZIP5 */
{"gzip-6", zlib_decompress}, /* ZIO_COMPRESS_GZIP6 */
{"gzip-7", zlib_decompress}, /* ZIO_COMPRESS_GZIP7 */
{"gzip-8", zlib_decompress}, /* ZIO_COMPRESS_GZIP8 */
{"gzip-9", zlib_decompress}, /* ZIO_COMPRESS_GZIP9 */
}; };
static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, static grub_err_t zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian,
@ -525,7 +543,7 @@ zio_read (blkptr_t * bp, grub_zfs_endian_t endian, void **buf,
*buf = NULL; *buf = NULL;
checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff; checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff;
comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7; comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0xff;
lsize = (BP_IS_HOLE(bp) ? 0 : lsize = (BP_IS_HOLE(bp) ? 0 :
(((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1)
<< SPA_MINBLOCKSHIFT)); << SPA_MINBLOCKSHIFT));

View file

@ -77,7 +77,15 @@ enum zio_compress {
ZIO_COMPRESS_OFF, ZIO_COMPRESS_OFF,
ZIO_COMPRESS_LZJB, ZIO_COMPRESS_LZJB,
ZIO_COMPRESS_EMPTY, ZIO_COMPRESS_EMPTY,
ZIO_COMPRESS_GZIP, ZIO_COMPRESS_GZIP1,
ZIO_COMPRESS_GZIP2,
ZIO_COMPRESS_GZIP3,
ZIO_COMPRESS_GZIP4,
ZIO_COMPRESS_GZIP5,
ZIO_COMPRESS_GZIP6,
ZIO_COMPRESS_GZIP7,
ZIO_COMPRESS_GZIP8,
ZIO_COMPRESS_GZIP9,
ZIO_COMPRESS_FUNCTIONS ZIO_COMPRESS_FUNCTIONS
}; };