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


   5  * Common Development and Distribution License (the "License").
   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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  25  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  26  */
  27 
  28 /*
  29  * SPA: Storage Pool Allocator
  30  *
  31  * This file contains all the routines used when modifying on-disk SPA state.
  32  * This includes opening, importing, destroying, exporting a pool, and syncing a
  33  * pool.
  34  */
  35 
  36 #include <sys/zfs_context.h>
  37 #include <sys/fm/fs/zfs.h>
  38 #include <sys/spa_impl.h>
  39 #include <sys/zio.h>
  40 #include <sys/zio_checksum.h>
  41 #include <sys/dmu.h>
  42 #include <sys/dmu_tx.h>
  43 #include <sys/zap.h>
  44 #include <sys/zil.h>
  45 #include <sys/ddt.h>


6089                 spa->spa_minref += 3;
6090         }
6091 
6092         if (spa->spa_ubsync.ub_version < SPA_VERSION_NEXT_CLONES &&
6093             spa->spa_uberblock.ub_version >= SPA_VERSION_NEXT_CLONES) {
6094                 dsl_pool_upgrade_clones(dp, tx);
6095         }
6096 
6097         if (spa->spa_ubsync.ub_version < SPA_VERSION_DIR_CLONES &&
6098             spa->spa_uberblock.ub_version >= SPA_VERSION_DIR_CLONES) {
6099                 dsl_pool_upgrade_dir_clones(dp, tx);
6100 
6101                 /* Keeping the freedir open increases spa_minref */
6102                 spa->spa_minref += 3;
6103         }
6104 
6105         if (spa->spa_ubsync.ub_version < SPA_VERSION_FEATURES &&
6106             spa->spa_uberblock.ub_version >= SPA_VERSION_FEATURES) {
6107                 spa_feature_create_zap_objects(spa, tx);
6108         }










6109         rrw_exit(&dp->dp_config_rwlock, FTAG);
6110 }
6111 
6112 /*
6113  * Sync the specified transaction group.  New blocks may be dirtied as
6114  * part of the process, so we iterate until it converges.
6115  */
6116 void
6117 spa_sync(spa_t *spa, uint64_t txg)
6118 {
6119         dsl_pool_t *dp = spa->spa_dsl_pool;
6120         objset_t *mos = spa->spa_meta_objset;
6121         bplist_t *free_bpl = &spa->spa_free_bplist[txg & TXG_MASK];
6122         vdev_t *rvd = spa->spa_root_vdev;
6123         vdev_t *vd;
6124         dmu_tx_t *tx;
6125         int error;
6126 
6127         VERIFY(spa_writeable(spa));
6128 




   5  * Common Development and Distribution License (the "License").
   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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  25  * Copyright (c) 2013, 2014, Nexenta Systems, Inc.  All rights reserved.
  26  */
  27 
  28 /*
  29  * SPA: Storage Pool Allocator
  30  *
  31  * This file contains all the routines used when modifying on-disk SPA state.
  32  * This includes opening, importing, destroying, exporting a pool, and syncing a
  33  * pool.
  34  */
  35 
  36 #include <sys/zfs_context.h>
  37 #include <sys/fm/fs/zfs.h>
  38 #include <sys/spa_impl.h>
  39 #include <sys/zio.h>
  40 #include <sys/zio_checksum.h>
  41 #include <sys/dmu.h>
  42 #include <sys/dmu_tx.h>
  43 #include <sys/zap.h>
  44 #include <sys/zil.h>
  45 #include <sys/ddt.h>


6089                 spa->spa_minref += 3;
6090         }
6091 
6092         if (spa->spa_ubsync.ub_version < SPA_VERSION_NEXT_CLONES &&
6093             spa->spa_uberblock.ub_version >= SPA_VERSION_NEXT_CLONES) {
6094                 dsl_pool_upgrade_clones(dp, tx);
6095         }
6096 
6097         if (spa->spa_ubsync.ub_version < SPA_VERSION_DIR_CLONES &&
6098             spa->spa_uberblock.ub_version >= SPA_VERSION_DIR_CLONES) {
6099                 dsl_pool_upgrade_dir_clones(dp, tx);
6100 
6101                 /* Keeping the freedir open increases spa_minref */
6102                 spa->spa_minref += 3;
6103         }
6104 
6105         if (spa->spa_ubsync.ub_version < SPA_VERSION_FEATURES &&
6106             spa->spa_uberblock.ub_version >= SPA_VERSION_FEATURES) {
6107                 spa_feature_create_zap_objects(spa, tx);
6108         }
6109 
6110         if (spa->spa_uberblock.ub_version >= SPA_VERSION_FEATURES) {
6111                 boolean_t lz4_en = spa_feature_is_enabled(spa,
6112                     SPA_FEATURE_LZ4_COMPRESS);
6113                 boolean_t lz4_ac = spa_feature_is_active(spa,
6114                     SPA_FEATURE_LZ4_COMPRESS);
6115 
6116                 if (lz4_en && !lz4_ac)
6117                         spa_feature_incr(spa, SPA_FEATURE_LZ4_COMPRESS, tx);
6118         }
6119         rrw_exit(&dp->dp_config_rwlock, FTAG);
6120 }
6121 
6122 /*
6123  * Sync the specified transaction group.  New blocks may be dirtied as
6124  * part of the process, so we iterate until it converges.
6125  */
6126 void
6127 spa_sync(spa_t *spa, uint64_t txg)
6128 {
6129         dsl_pool_t *dp = spa->spa_dsl_pool;
6130         objset_t *mos = spa->spa_meta_objset;
6131         bplist_t *free_bpl = &spa->spa_free_bplist[txg & TXG_MASK];
6132         vdev_t *rvd = spa->spa_root_vdev;
6133         vdev_t *vd;
6134         dmu_tx_t *tx;
6135         int error;
6136 
6137         VERIFY(spa_writeable(spa));
6138