Print this page
3756 want lz4 support for metadata compression

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 ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  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) 2013 by Delphix. All rights reserved.
       24 + * Copyright (c) 2013 Martin Matuska. All rights reserved.
  24   25   */
  25   26  
  26   27  #include <sys/dmu.h>
  27   28  #include <sys/dmu_impl.h>
  28   29  #include <sys/dmu_tx.h>
  29   30  #include <sys/dbuf.h>
  30   31  #include <sys/dnode.h>
  31   32  #include <sys/zfs_context.h>
  32   33  #include <sys/dmu_objset.h>
  33   34  #include <sys/dmu_traverse.h>
↓ open down ↓ 1 lines elided ↑ open up ↑
  35   36  #include <sys/dsl_dir.h>
  36   37  #include <sys/dsl_pool.h>
  37   38  #include <sys/dsl_synctask.h>
  38   39  #include <sys/dsl_prop.h>
  39   40  #include <sys/dmu_zfetch.h>
  40   41  #include <sys/zfs_ioctl.h>
  41   42  #include <sys/zap.h>
  42   43  #include <sys/zio_checksum.h>
  43   44  #include <sys/zio_compress.h>
  44   45  #include <sys/sa.h>
       46 +#include <sys/zfeature.h>
  45   47  #ifdef _KERNEL
  46   48  #include <sys/vmsystm.h>
  47   49  #include <sys/zfs_znode.h>
  48   50  #endif
  49   51  
  50   52  /*
  51   53   * Enable/disable nopwrite feature.
  52   54   */
  53   55  int zfs_nopwrite_enabled = 1;
  54   56  
↓ open down ↓ 1355 lines elided ↑ open up ↑
1410 1412          dnode_t *dn;
1411 1413  
1412 1414          ASSERT(pio != NULL);
1413 1415          ASSERT(txg != 0);
1414 1416  
1415 1417          SET_BOOKMARK(&zb, ds->ds_object,
1416 1418              db->db.db_object, db->db_level, db->db_blkid);
1417 1419  
1418 1420          DB_DNODE_ENTER(db);
1419 1421          dn = DB_DNODE(db);
1420      -        dmu_write_policy(os, dn, db->db_level, WP_DMU_SYNC, &zp);
     1422 +        dmu_write_policy(os, dn, db->db_level, WP_DMU_SYNC, &zp, txg);
1421 1423          DB_DNODE_EXIT(db);
1422 1424  
1423 1425          /*
1424 1426           * If we're frozen (running ziltest), we always need to generate a bp.
1425 1427           */
1426 1428          if (txg > spa_freeze_txg(os->os_spa))
1427 1429                  return (dmu_sync_late_arrival(pio, os, done, zgd, &zp, &zb));
1428 1430  
1429 1431          /*
1430 1432           * Grabbing db_mtx now provides a barrier between dbuf_sync_leaf()
↓ open down ↓ 117 lines elided ↑ open up ↑
1548 1550  
1549 1551          /* XXX assumes dnode_hold will not get an i/o error */
1550 1552          (void) dnode_hold(os, object, FTAG, &dn);
1551 1553          ASSERT(compress < ZIO_COMPRESS_FUNCTIONS);
1552 1554          dn->dn_compress = compress;
1553 1555          dnode_setdirty(dn, tx);
1554 1556          dnode_rele(dn, FTAG);
1555 1557  }
1556 1558  
1557 1559  int zfs_mdcomp_disable = 0;
     1560 +int zfs_mdcomp_lz4 = 0;
1558 1561  
1559 1562  void
1560      -dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
     1563 +dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp,
     1564 +    uint64_t txg)
1561 1565  {
1562 1566          dmu_object_type_t type = dn ? dn->dn_type : DMU_OT_OBJSET;
1563 1567          boolean_t ismd = (level > 0 || DMU_OT_IS_METADATA(type) ||
1564 1568              (wp & WP_SPILL));
1565 1569          enum zio_checksum checksum = os->os_checksum;
1566 1570          enum zio_compress compress = os->os_compress;
1567 1571          enum zio_checksum dedup_checksum = os->os_dedup_checksum;
1568 1572          boolean_t dedup = B_FALSE;
1569 1573          boolean_t nopwrite = B_FALSE;
1570 1574          boolean_t dedup_verify = os->os_dedup_verify;
↓ open down ↓ 4 lines elided ↑ open up ↑
1575 1579           * types of data:
1576 1580           *       1. metadata
1577 1581           *       2. preallocated blocks (i.e. level-0 blocks of a dump device)
1578 1582           *       3. all other level 0 blocks
1579 1583           */
1580 1584          if (ismd) {
1581 1585                  /*
1582 1586                   * XXX -- we should design a compression algorithm
1583 1587                   * that specializes in arrays of bps.
1584 1588                   */
1585      -                compress = zfs_mdcomp_disable ? ZIO_COMPRESS_EMPTY :
1586      -                    ZIO_COMPRESS_LZJB;
     1589 +                if (zfs_mdcomp_disable)
     1590 +                        compress = ZIO_COMPRESS_EMPTY;
     1591 +                else if (zfs_mdcomp_lz4 && os->os_spa != NULL) {
     1592 +                        zfeature_info_t *feat = &spa_feature_table
     1593 +                            [SPA_FEATURE_LZ4_COMPRESS];
     1594 +
     1595 +                        if (spa_feature_is_active(os->os_spa, feat))
     1596 +                                compress = ZIO_COMPRESS_LZ4;
     1597 +                        else if (spa_feature_is_enabled(os->os_spa, feat)) {
     1598 +                                dmu_tx_t *tx;
     1599 +
     1600 +                                tx = dmu_tx_create_assigned(
     1601 +                                    spa_get_dsl(os->os_spa), txg);
     1602 +                                spa_feature_incr(os->os_spa, feat, tx);
     1603 +                                dmu_tx_commit(tx);
     1604 +                                compress = ZIO_COMPRESS_LZ4;
     1605 +                        } else
     1606 +                                compress = ZIO_COMPRESS_LZJB;
     1607 +                } else
     1608 +                        compress = ZIO_COMPRESS_LZJB;
1587 1609  
1588 1610                  /*
1589 1611                   * Metadata always gets checksummed.  If the data
1590 1612                   * checksum is multi-bit correctable, and it's not a
1591 1613                   * ZBT-style checksum, then it's suitable for metadata
1592 1614                   * as well.  Otherwise, the metadata checksum defaults
1593 1615                   * to fletcher4.
1594 1616                   */
1595 1617                  if (zio_checksum_table[checksum].ci_correctable < 1 ||
1596 1618                      zio_checksum_table[checksum].ci_eck)
↓ open down ↓ 240 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX