Print this page
%B


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */



  26 
  27 #include <sys/zfs_context.h>
  28 #include <sys/compress.h>
  29 #include <sys/spa.h>
  30 #include <sys/zio.h>
  31 #include <sys/zio_compress.h>
  32 
  33 /*
  34  * Compression vectors.
  35  */
  36 
  37 zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
  38         {NULL,                  NULL,                   0,      "inherit"},
  39         {NULL,                  NULL,                   0,      "on"},
  40         {NULL,                  NULL,                   0,      "uncompressed"},
  41         {lzjb_compress,         lzjb_decompress,        0,      "lzjb"},
  42         {NULL,                  NULL,                   0,      "empty"},
  43         {gzip_compress,         gzip_decompress,        1,      "gzip-1"},
  44         {gzip_compress,         gzip_decompress,        2,      "gzip-2"},
  45         {gzip_compress,         gzip_decompress,        3,      "gzip-3"},
  46         {gzip_compress,         gzip_decompress,        4,      "gzip-4"},
  47         {gzip_compress,         gzip_decompress,        5,      "gzip-5"},
  48         {gzip_compress,         gzip_decompress,        6,      "gzip-6"},
  49         {gzip_compress,         gzip_decompress,        7,      "gzip-7"},
  50         {gzip_compress,         gzip_decompress,        8,      "gzip-8"},
  51         {gzip_compress,         gzip_decompress,        9,      "gzip-9"},
  52         {zle_compress,          zle_decompress,         64,     "zle"},


  53 };
  54 
  55 enum zio_compress
  56 zio_compress_select(enum zio_compress child, enum zio_compress parent)
  57 {
  58         ASSERT(child < ZIO_COMPRESS_FUNCTIONS);
  59         ASSERT(parent < ZIO_COMPRESS_FUNCTIONS);
  60         ASSERT(parent != ZIO_COMPRESS_INHERIT && parent != ZIO_COMPRESS_ON);
  61 
  62         if (child == ZIO_COMPRESS_INHERIT)
  63                 return (parent);
  64 
  65         if (child == ZIO_COMPRESS_ON)
  66                 return (ZIO_COMPRESS_ON_VALUE);
  67 
  68         return (child);
  69 }
  70 
  71 size_t
  72 zio_compress_data(enum zio_compress c, void *src, void *dst, size_t s_len)




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  28  */
  29 
  30 #include <sys/zfs_context.h>
  31 #include <sys/compress.h>
  32 #include <sys/spa.h>
  33 #include <sys/zio.h>
  34 #include <sys/zio_compress.h>
  35 
  36 /*
  37  * Compression vectors.
  38  */
  39 
  40 zio_compress_info_t zio_compress_table[ZIO_COMPRESS_FUNCTIONS] = {
  41         {NULL,                  NULL,                   0,      "inherit"},
  42         {NULL,                  NULL,                   0,      "on"},
  43         {NULL,                  NULL,                   0,      "uncompressed"},
  44         {lzjb_compress,         lzjb_decompress,        0,      "lzjb"},
  45         {NULL,                  NULL,                   0,      "empty"},
  46         {gzip_compress,         gzip_decompress,        1,      "gzip-1"},
  47         {gzip_compress,         gzip_decompress,        2,      "gzip-2"},
  48         {gzip_compress,         gzip_decompress,        3,      "gzip-3"},
  49         {gzip_compress,         gzip_decompress,        4,      "gzip-4"},
  50         {gzip_compress,         gzip_decompress,        5,      "gzip-5"},
  51         {gzip_compress,         gzip_decompress,        6,      "gzip-6"},
  52         {gzip_compress,         gzip_decompress,        7,      "gzip-7"},
  53         {gzip_compress,         gzip_decompress,        8,      "gzip-8"},
  54         {gzip_compress,         gzip_decompress,        9,      "gzip-9"},
  55         {zle_compress,          zle_decompress,         64,     "zle"},
  56         {lz4_compress,          lz4_decompress,         0,      "lz4"},
  57         {lz4_compress,          lz4_decompress,         1,      "lz4hc"},
  58 };
  59 
  60 enum zio_compress
  61 zio_compress_select(enum zio_compress child, enum zio_compress parent)
  62 {
  63         ASSERT(child < ZIO_COMPRESS_FUNCTIONS);
  64         ASSERT(parent < ZIO_COMPRESS_FUNCTIONS);
  65         ASSERT(parent != ZIO_COMPRESS_INHERIT && parent != ZIO_COMPRESS_ON);
  66 
  67         if (child == ZIO_COMPRESS_INHERIT)
  68                 return (parent);
  69 
  70         if (child == ZIO_COMPRESS_ON)
  71                 return (ZIO_COMPRESS_ON_VALUE);
  72 
  73         return (child);
  74 }
  75 
  76 size_t
  77 zio_compress_data(enum zio_compress c, void *src, void *dst, size_t s_len)