Print this page
Use the LZ4 algorithm to compress metadata when the corresponding feature is enabled

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dmu.c
          +++ new/usr/src/uts/common/fs/zfs/dmu.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
  24   24   */
  25   25  /* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */
  26   26  /* Copyright (c) 2013, Joyent, Inc. All rights reserved. */
       27 +/* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved. */
  27   28  
  28   29  #include <sys/dmu.h>
  29   30  #include <sys/dmu_impl.h>
  30   31  #include <sys/dmu_tx.h>
  31   32  #include <sys/dbuf.h>
  32   33  #include <sys/dnode.h>
  33   34  #include <sys/zfs_context.h>
  34   35  #include <sys/dmu_objset.h>
  35   36  #include <sys/dmu_traverse.h>
  36   37  #include <sys/dsl_dataset.h>
  37   38  #include <sys/dsl_dir.h>
  38   39  #include <sys/dsl_pool.h>
  39   40  #include <sys/dsl_synctask.h>
  40   41  #include <sys/dsl_prop.h>
  41   42  #include <sys/dmu_zfetch.h>
  42   43  #include <sys/zfs_ioctl.h>
  43   44  #include <sys/zap.h>
  44   45  #include <sys/zio_checksum.h>
  45   46  #include <sys/zio_compress.h>
  46   47  #include <sys/sa.h>
       48 +#include <sys/zfeature.h>
  47   49  #ifdef _KERNEL
  48   50  #include <sys/vmsystm.h>
  49   51  #include <sys/zfs_znode.h>
  50   52  #endif
  51   53  
  52   54  /*
  53   55   * Enable/disable nopwrite feature.
  54   56   */
  55   57  int zfs_nopwrite_enabled = 1;
  56   58  
↓ open down ↓ 1526 lines elided ↑ open up ↑
1583 1585           * types of data:
1584 1586           *       1. metadata
1585 1587           *       2. preallocated blocks (i.e. level-0 blocks of a dump device)
1586 1588           *       3. all other level 0 blocks
1587 1589           */
1588 1590          if (ismd) {
1589 1591                  /*
1590 1592                   * XXX -- we should design a compression algorithm
1591 1593                   * that specializes in arrays of bps.
1592 1594                   */
1593      -                compress = zfs_mdcomp_disable ? ZIO_COMPRESS_EMPTY :
1594      -                    ZIO_COMPRESS_LZJB;
     1595 +                boolean_t lz4_ac = spa_feature_is_active(os->os_spa,
     1596 +                    SPA_FEATURE_LZ4_COMPRESS);
1595 1597  
     1598 +                if (zfs_mdcomp_disable) {
     1599 +                        compress = ZIO_COMPRESS_EMPTY;
     1600 +                } else if (lz4_ac) {
     1601 +                        compress = ZIO_COMPRESS_LZ4;
     1602 +                } else {
     1603 +                        compress = ZIO_COMPRESS_LZJB;
     1604 +                }
     1605 +
1596 1606                  /*
1597 1607                   * Metadata always gets checksummed.  If the data
1598 1608                   * checksum is multi-bit correctable, and it's not a
1599 1609                   * ZBT-style checksum, then it's suitable for metadata
1600 1610                   * as well.  Otherwise, the metadata checksum defaults
1601 1611                   * to fletcher4.
1602 1612                   */
1603 1613                  if (zio_checksum_table[checksum].ci_correctable < 1 ||
1604 1614                      zio_checksum_table[checksum].ci_eck)
1605 1615                          checksum = ZIO_CHECKSUM_FLETCHER_4;
↓ open down ↓ 246 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX