Print this page
4374 dn_free_ranges should use range_tree_t
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Max Grossman <max.grossman@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Dan McDonald <danmcd@omniti.com>


   3  *
   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 #include <sys/zio.h>
  27 #include <sys/spa.h>
  28 #include <sys/dmu.h>
  29 #include <sys/zfs_context.h>
  30 #include <sys/zap.h>
  31 #include <sys/refcount.h>
  32 #include <sys/zap_impl.h>
  33 #include <sys/zap_leaf.h>
  34 #include <sys/avl.h>
  35 #include <sys/arc.h>
  36 
  37 #ifdef _KERNEL
  38 #include <sys/sunddi.h>
  39 #endif
  40 
  41 static int mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags);
  42 
  43 uint64_t


 357 }
 358 
 359 static zap_t *
 360 mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
 361 {
 362         zap_t *winner;
 363         zap_t *zap;
 364         int i;
 365 
 366         ASSERT3U(MZAP_ENT_LEN, ==, sizeof (mzap_ent_phys_t));
 367 
 368         zap = kmem_zalloc(sizeof (zap_t), KM_SLEEP);
 369         rw_init(&zap->zap_rwlock, 0, 0, 0);
 370         rw_enter(&zap->zap_rwlock, RW_WRITER);
 371         zap->zap_objset = os;
 372         zap->zap_object = obj;
 373         zap->zap_dbuf = db;
 374 
 375         if (*(uint64_t *)db->db_data != ZBT_MICRO) {
 376                 mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0);
 377                 zap->zap_f.zap_block_shift = highbit(db->db_size) - 1;
 378         } else {
 379                 zap->zap_ismicro = TRUE;
 380         }
 381 
 382         /*
 383          * Make sure that zap_ismicro is set before we let others see
 384          * it, because zap_lockdir() checks zap_ismicro without the lock
 385          * held.
 386          */
 387         winner = dmu_buf_set_user(db, zap, &zap->zap_m.zap_phys, zap_evict);
 388 
 389         if (winner != NULL) {
 390                 rw_exit(&zap->zap_rwlock);
 391                 rw_destroy(&zap->zap_rwlock);
 392                 if (!zap->zap_ismicro)
 393                         mutex_destroy(&zap->zap_f.zap_num_entries_mtx);
 394                 kmem_free(zap, sizeof (zap_t));
 395                 return (winner);
 396         }
 397 




   3  *
   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) 2011, 2014 by Delphix. All rights reserved.
  24  */
  25 
  26 #include <sys/zio.h>
  27 #include <sys/spa.h>
  28 #include <sys/dmu.h>
  29 #include <sys/zfs_context.h>
  30 #include <sys/zap.h>
  31 #include <sys/refcount.h>
  32 #include <sys/zap_impl.h>
  33 #include <sys/zap_leaf.h>
  34 #include <sys/avl.h>
  35 #include <sys/arc.h>
  36 
  37 #ifdef _KERNEL
  38 #include <sys/sunddi.h>
  39 #endif
  40 
  41 static int mzap_upgrade(zap_t **zapp, dmu_tx_t *tx, zap_flags_t flags);
  42 
  43 uint64_t


 357 }
 358 
 359 static zap_t *
 360 mzap_open(objset_t *os, uint64_t obj, dmu_buf_t *db)
 361 {
 362         zap_t *winner;
 363         zap_t *zap;
 364         int i;
 365 
 366         ASSERT3U(MZAP_ENT_LEN, ==, sizeof (mzap_ent_phys_t));
 367 
 368         zap = kmem_zalloc(sizeof (zap_t), KM_SLEEP);
 369         rw_init(&zap->zap_rwlock, 0, 0, 0);
 370         rw_enter(&zap->zap_rwlock, RW_WRITER);
 371         zap->zap_objset = os;
 372         zap->zap_object = obj;
 373         zap->zap_dbuf = db;
 374 
 375         if (*(uint64_t *)db->db_data != ZBT_MICRO) {
 376                 mutex_init(&zap->zap_f.zap_num_entries_mtx, 0, 0, 0);
 377                 zap->zap_f.zap_block_shift = highbit64(db->db_size) - 1;
 378         } else {
 379                 zap->zap_ismicro = TRUE;
 380         }
 381 
 382         /*
 383          * Make sure that zap_ismicro is set before we let others see
 384          * it, because zap_lockdir() checks zap_ismicro without the lock
 385          * held.
 386          */
 387         winner = dmu_buf_set_user(db, zap, &zap->zap_m.zap_phys, zap_evict);
 388 
 389         if (winner != NULL) {
 390                 rw_exit(&zap->zap_rwlock);
 391                 rw_destroy(&zap->zap_rwlock);
 392                 if (!zap->zap_ismicro)
 393                         mutex_destroy(&zap->zap_f.zap_num_entries_mtx);
 394                 kmem_free(zap, sizeof (zap_t));
 395                 return (winner);
 396         }
 397