Print this page
3756 want lz4 support for metadata compression


   4  * The contents of this file are subject to the terms of the
   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  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013 by Delphix. All rights reserved.

  24  */
  25 
  26 /* Portions Copyright 2010 Robert Milkowski */
  27 
  28 #include <sys/cred.h>
  29 #include <sys/zfs_context.h>
  30 #include <sys/dmu_objset.h>
  31 #include <sys/dsl_dir.h>
  32 #include <sys/dsl_dataset.h>
  33 #include <sys/dsl_prop.h>
  34 #include <sys/dsl_pool.h>
  35 #include <sys/dsl_synctask.h>
  36 #include <sys/dsl_deleg.h>
  37 #include <sys/dnode.h>
  38 #include <sys/dbuf.h>
  39 #include <sys/zvol.h>
  40 #include <sys/dmu_tx.h>
  41 #include <sys/zap.h>
  42 #include <sys/zil.h>
  43 #include <sys/dmu_impl.h>


 971         /* XXX the write_done callback should really give us the tx... */
 972         os->os_synctx = tx;
 973 
 974         if (os->os_dsl_dataset == NULL) {
 975                 /*
 976                  * This is the MOS.  If we have upgraded,
 977                  * spa_max_replication() could change, so reset
 978                  * os_copies here.
 979                  */
 980                 os->os_copies = spa_max_replication(os->os_spa);
 981         }
 982 
 983         /*
 984          * Create the root block IO
 985          */
 986         SET_BOOKMARK(&zb, os->os_dsl_dataset ?
 987             os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
 988             ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
 989         arc_release(os->os_phys_buf, &os->os_phys_buf);
 990 
 991         dmu_write_policy(os, NULL, 0, 0, &zp);
 992 
 993         zio = arc_write(pio, os->os_spa, tx->tx_txg,
 994             os->os_rootbp, os->os_phys_buf, DMU_OS_IS_L2CACHEABLE(os), &zp,
 995             dmu_objset_write_ready, dmu_objset_write_done, os,
 996             ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
 997 
 998         /*
 999          * Sync special dnodes - the parent IO for the sync is the root block
1000          */
1001         DMU_META_DNODE(os)->dn_zio = zio;
1002         dnode_sync(DMU_META_DNODE(os), tx);
1003 
1004         os->os_phys->os_flags = os->os_flags;
1005 
1006         if (DMU_USERUSED_DNODE(os) &&
1007             DMU_USERUSED_DNODE(os)->dn_type != DMU_OT_NONE) {
1008                 DMU_USERUSED_DNODE(os)->dn_zio = zio;
1009                 dnode_sync(DMU_USERUSED_DNODE(os), tx);
1010                 DMU_GROUPUSED_DNODE(os)->dn_zio = zio;
1011                 dnode_sync(DMU_GROUPUSED_DNODE(os), tx);




   4  * The contents of this file are subject to the terms of the
   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  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013 by Delphix. All rights reserved.
  24  * Copyright (c) 2013 Martin Matuska. All rights reserved.
  25  */
  26 
  27 /* Portions Copyright 2010 Robert Milkowski */
  28 
  29 #include <sys/cred.h>
  30 #include <sys/zfs_context.h>
  31 #include <sys/dmu_objset.h>
  32 #include <sys/dsl_dir.h>
  33 #include <sys/dsl_dataset.h>
  34 #include <sys/dsl_prop.h>
  35 #include <sys/dsl_pool.h>
  36 #include <sys/dsl_synctask.h>
  37 #include <sys/dsl_deleg.h>
  38 #include <sys/dnode.h>
  39 #include <sys/dbuf.h>
  40 #include <sys/zvol.h>
  41 #include <sys/dmu_tx.h>
  42 #include <sys/zap.h>
  43 #include <sys/zil.h>
  44 #include <sys/dmu_impl.h>


 972         /* XXX the write_done callback should really give us the tx... */
 973         os->os_synctx = tx;
 974 
 975         if (os->os_dsl_dataset == NULL) {
 976                 /*
 977                  * This is the MOS.  If we have upgraded,
 978                  * spa_max_replication() could change, so reset
 979                  * os_copies here.
 980                  */
 981                 os->os_copies = spa_max_replication(os->os_spa);
 982         }
 983 
 984         /*
 985          * Create the root block IO
 986          */
 987         SET_BOOKMARK(&zb, os->os_dsl_dataset ?
 988             os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
 989             ZB_ROOT_OBJECT, ZB_ROOT_LEVEL, ZB_ROOT_BLKID);
 990         arc_release(os->os_phys_buf, &os->os_phys_buf);
 991 
 992         dmu_write_policy(os, NULL, 0, 0, &zp, tx->tx_txg);
 993 
 994         zio = arc_write(pio, os->os_spa, tx->tx_txg,
 995             os->os_rootbp, os->os_phys_buf, DMU_OS_IS_L2CACHEABLE(os), &zp,
 996             dmu_objset_write_ready, dmu_objset_write_done, os,
 997             ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
 998 
 999         /*
1000          * Sync special dnodes - the parent IO for the sync is the root block
1001          */
1002         DMU_META_DNODE(os)->dn_zio = zio;
1003         dnode_sync(DMU_META_DNODE(os), tx);
1004 
1005         os->os_phys->os_flags = os->os_flags;
1006 
1007         if (DMU_USERUSED_DNODE(os) &&
1008             DMU_USERUSED_DNODE(os)->dn_type != DMU_OT_NONE) {
1009                 DMU_USERUSED_DNODE(os)->dn_zio = zio;
1010                 dnode_sync(DMU_USERUSED_DNODE(os), tx);
1011                 DMU_GROUPUSED_DNODE(os)->dn_zio = zio;
1012                 dnode_sync(DMU_GROUPUSED_DNODE(os), tx);