Print this page
3756 want lz4 support for metadata compression


   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 2011 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 2013 by Delphix. All rights reserved.

  25  */
  26 
  27 #include <sys/zfs_context.h>
  28 #include <sys/dmu.h>
  29 #include <sys/dmu_impl.h>
  30 #include <sys/dbuf.h>
  31 #include <sys/dmu_objset.h>
  32 #include <sys/dsl_dataset.h>
  33 #include <sys/dsl_dir.h>
  34 #include <sys/dmu_tx.h>
  35 #include <sys/spa.h>
  36 #include <sys/zio.h>
  37 #include <sys/dmu_zfetch.h>
  38 #include <sys/sa.h>
  39 #include <sys/sa_impl.h>
  40 
  41 static void dbuf_destroy(dmu_buf_impl_t *db);
  42 static boolean_t dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
  43 static void dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx);
  44 


2665                     db->db_blkid != DMU_SPILL_BLKID) ||
2666                     (db->db_blkid == DMU_SPILL_BLKID && db->db_level == 0));
2667                 if (db->db_blkid != DMU_SPILL_BLKID)
2668                         ASSERT3P(db->db_blkptr, ==,
2669                             &dn->dn_phys->dn_blkptr[db->db_blkid]);
2670                 zio = dn->dn_zio;
2671         }
2672 
2673         ASSERT(db->db_level == 0 || data == db->db_buf);
2674         ASSERT3U(db->db_blkptr->blk_birth, <=, txg);
2675         ASSERT(zio);
2676 
2677         SET_BOOKMARK(&zb, os->os_dsl_dataset ?
2678             os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
2679             db->db.db_object, db->db_level, db->db_blkid);
2680 
2681         if (db->db_blkid == DMU_SPILL_BLKID)
2682                 wp_flag = WP_SPILL;
2683         wp_flag |= (db->db_state == DB_NOFILL) ? WP_NOFILL : 0;
2684 
2685         dmu_write_policy(os, dn, db->db_level, wp_flag, &zp);
2686         DB_DNODE_EXIT(db);
2687 
2688         if (db->db_level == 0 && dr->dt.dl.dr_override_state == DR_OVERRIDDEN) {
2689                 ASSERT(db->db_state != DB_NOFILL);
2690                 dr->dr_zio = zio_write(zio, os->os_spa, txg,
2691                     db->db_blkptr, data->b_data, arc_buf_size(data), &zp,
2692                     dbuf_write_override_ready, dbuf_write_override_done, dr,
2693                     ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
2694                 mutex_enter(&db->db_mtx);
2695                 dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;
2696                 zio_write_override(dr->dr_zio, &dr->dt.dl.dr_overridden_by,
2697                     dr->dt.dl.dr_copies, dr->dt.dl.dr_nopwrite);
2698                 mutex_exit(&db->db_mtx);
2699         } else if (db->db_state == DB_NOFILL) {
2700                 ASSERT(zp.zp_checksum == ZIO_CHECKSUM_OFF);
2701                 dr->dr_zio = zio_write(zio, os->os_spa, txg,
2702                     db->db_blkptr, NULL, db->db.db_size, &zp,
2703                     dbuf_write_nofill_ready, dbuf_write_nofill_done, db,
2704                     ZIO_PRIORITY_ASYNC_WRITE,
2705                     ZIO_FLAG_MUSTSUCCEED | ZIO_FLAG_NODATA, &zb);


   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 2011 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 2013 by Delphix. All rights reserved.
  25  * Copyright (c) 2013 Martin Matuska. All rights reserved.
  26  */
  27 
  28 #include <sys/zfs_context.h>
  29 #include <sys/dmu.h>
  30 #include <sys/dmu_impl.h>
  31 #include <sys/dbuf.h>
  32 #include <sys/dmu_objset.h>
  33 #include <sys/dsl_dataset.h>
  34 #include <sys/dsl_dir.h>
  35 #include <sys/dmu_tx.h>
  36 #include <sys/spa.h>
  37 #include <sys/zio.h>
  38 #include <sys/dmu_zfetch.h>
  39 #include <sys/sa.h>
  40 #include <sys/sa_impl.h>
  41 
  42 static void dbuf_destroy(dmu_buf_impl_t *db);
  43 static boolean_t dbuf_undirty(dmu_buf_impl_t *db, dmu_tx_t *tx);
  44 static void dbuf_write(dbuf_dirty_record_t *dr, arc_buf_t *data, dmu_tx_t *tx);
  45 


2666                     db->db_blkid != DMU_SPILL_BLKID) ||
2667                     (db->db_blkid == DMU_SPILL_BLKID && db->db_level == 0));
2668                 if (db->db_blkid != DMU_SPILL_BLKID)
2669                         ASSERT3P(db->db_blkptr, ==,
2670                             &dn->dn_phys->dn_blkptr[db->db_blkid]);
2671                 zio = dn->dn_zio;
2672         }
2673 
2674         ASSERT(db->db_level == 0 || data == db->db_buf);
2675         ASSERT3U(db->db_blkptr->blk_birth, <=, txg);
2676         ASSERT(zio);
2677 
2678         SET_BOOKMARK(&zb, os->os_dsl_dataset ?
2679             os->os_dsl_dataset->ds_object : DMU_META_OBJSET,
2680             db->db.db_object, db->db_level, db->db_blkid);
2681 
2682         if (db->db_blkid == DMU_SPILL_BLKID)
2683                 wp_flag = WP_SPILL;
2684         wp_flag |= (db->db_state == DB_NOFILL) ? WP_NOFILL : 0;
2685 
2686         dmu_write_policy(os, dn, db->db_level, wp_flag, &zp, txg);
2687         DB_DNODE_EXIT(db);
2688 
2689         if (db->db_level == 0 && dr->dt.dl.dr_override_state == DR_OVERRIDDEN) {
2690                 ASSERT(db->db_state != DB_NOFILL);
2691                 dr->dr_zio = zio_write(zio, os->os_spa, txg,
2692                     db->db_blkptr, data->b_data, arc_buf_size(data), &zp,
2693                     dbuf_write_override_ready, dbuf_write_override_done, dr,
2694                     ZIO_PRIORITY_ASYNC_WRITE, ZIO_FLAG_MUSTSUCCEED, &zb);
2695                 mutex_enter(&db->db_mtx);
2696                 dr->dt.dl.dr_override_state = DR_NOT_OVERRIDDEN;
2697                 zio_write_override(dr->dr_zio, &dr->dt.dl.dr_overridden_by,
2698                     dr->dt.dl.dr_copies, dr->dt.dl.dr_nopwrite);
2699                 mutex_exit(&db->db_mtx);
2700         } else if (db->db_state == DB_NOFILL) {
2701                 ASSERT(zp.zp_checksum == ZIO_CHECKSUM_OFF);
2702                 dr->dr_zio = zio_write(zio, os->os_spa, txg,
2703                     db->db_blkptr, NULL, db->db.db_size, &zp,
2704                     dbuf_write_nofill_ready, dbuf_write_nofill_done, db,
2705                     ZIO_PRIORITY_ASYNC_WRITE,
2706                     ZIO_FLAG_MUSTSUCCEED | ZIO_FLAG_NODATA, &zb);