Print this page
2619 asynchronous destruction of ZFS file systems
2747 SPA versioning with zfs feature flags
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <gwilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>


   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 2011 Nexenta Systems, Inc.  All rights reserved.

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


 210         if (db->db_level != 0 || db->db_evict_func == NULL)
 211                 return;
 212 
 213         if (db->db_user_data_ptr_ptr)
 214                 *db->db_user_data_ptr_ptr = db->db.db_data;
 215         db->db_evict_func(&db->db, db->db_user_ptr);
 216         db->db_user_ptr = NULL;
 217         db->db_user_data_ptr_ptr = NULL;
 218         db->db_evict_func = NULL;
 219 }
 220 
 221 boolean_t
 222 dbuf_is_metadata(dmu_buf_impl_t *db)
 223 {
 224         if (db->db_level > 0) {
 225                 return (B_TRUE);
 226         } else {
 227                 boolean_t is_metadata;
 228 
 229                 DB_DNODE_ENTER(db);
 230                 is_metadata = dmu_ot[DB_DNODE(db)->dn_type].ot_metadata;
 231                 DB_DNODE_EXIT(db);
 232 
 233                 return (is_metadata);
 234         }
 235 }
 236 
 237 void
 238 dbuf_evict(dmu_buf_impl_t *db)
 239 {
 240         ASSERT(MUTEX_HELD(&db->db_mtx));
 241         ASSERT(db->db_buf == NULL);
 242         ASSERT(db->db_data_pending == NULL);
 243 
 244         dbuf_clear(db);
 245         dbuf_destroy(db);
 246 }
 247 
 248 void
 249 dbuf_init(void)
 250 {




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


 211         if (db->db_level != 0 || db->db_evict_func == NULL)
 212                 return;
 213 
 214         if (db->db_user_data_ptr_ptr)
 215                 *db->db_user_data_ptr_ptr = db->db.db_data;
 216         db->db_evict_func(&db->db, db->db_user_ptr);
 217         db->db_user_ptr = NULL;
 218         db->db_user_data_ptr_ptr = NULL;
 219         db->db_evict_func = NULL;
 220 }
 221 
 222 boolean_t
 223 dbuf_is_metadata(dmu_buf_impl_t *db)
 224 {
 225         if (db->db_level > 0) {
 226                 return (B_TRUE);
 227         } else {
 228                 boolean_t is_metadata;
 229 
 230                 DB_DNODE_ENTER(db);
 231                 is_metadata = DMU_OT_IS_METADATA(DB_DNODE(db)->dn_type);
 232                 DB_DNODE_EXIT(db);
 233 
 234                 return (is_metadata);
 235         }
 236 }
 237 
 238 void
 239 dbuf_evict(dmu_buf_impl_t *db)
 240 {
 241         ASSERT(MUTEX_HELD(&db->db_mtx));
 242         ASSERT(db->db_buf == NULL);
 243         ASSERT(db->db_data_pending == NULL);
 244 
 245         dbuf_clear(db);
 246         dbuf_destroy(db);
 247 }
 248 
 249 void
 250 dbuf_init(void)
 251 {