Print this page
5056 ZFS deadlock on db_mtx and dn_holds
Reviewed by: Will Andrews <willa@spectralogic.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Approved by: Dan McDonald <danmcd@omniti.com>


   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  * Copyright (c) 2013 Steven Hartland. All rights reserved.

  25  */
  26 
  27 #include <sys/dsl_pool.h>
  28 #include <sys/dsl_dataset.h>
  29 #include <sys/dsl_prop.h>
  30 #include <sys/dsl_dir.h>
  31 #include <sys/dsl_synctask.h>
  32 #include <sys/dsl_scan.h>
  33 #include <sys/dnode.h>
  34 #include <sys/dmu_tx.h>
  35 #include <sys/dmu_objset.h>
  36 #include <sys/arc.h>
  37 #include <sys/zap.h>
  38 #include <sys/zio.h>
  39 #include <sys/zfs_context.h>
  40 #include <sys/fs/zfs.h>
  41 #include <sys/zfs_znode.h>
  42 #include <sys/spa_impl.h>
  43 #include <sys/dsl_deadlist.h>
  44 #include <sys/bptree.h>


 300                 dsl_dir_rele(dp->dp_free_dir, dp);
 301         if (dp->dp_leak_dir)
 302                 dsl_dir_rele(dp->dp_leak_dir, dp);
 303         if (dp->dp_root_dir)
 304                 dsl_dir_rele(dp->dp_root_dir, dp);
 305 
 306         bpobj_close(&dp->dp_free_bpobj);
 307 
 308         /* undo the dmu_objset_open_impl(mos) from dsl_pool_open() */
 309         if (dp->dp_meta_objset)
 310                 dmu_objset_evict(dp->dp_meta_objset);
 311 
 312         txg_list_destroy(&dp->dp_dirty_datasets);
 313         txg_list_destroy(&dp->dp_dirty_zilogs);
 314         txg_list_destroy(&dp->dp_sync_tasks);
 315         txg_list_destroy(&dp->dp_dirty_dirs);
 316 
 317         arc_flush(dp->dp_spa);
 318         txg_fini(dp);
 319         dsl_scan_fini(dp);


 320         rrw_destroy(&dp->dp_config_rwlock);
 321         mutex_destroy(&dp->dp_lock);
 322         taskq_destroy(dp->dp_vnrele_taskq);
 323         if (dp->dp_blkstats)
 324                 kmem_free(dp->dp_blkstats, sizeof (zfs_all_blkstats_t));
 325         kmem_free(dp, sizeof (dsl_pool_t));
 326 }
 327 
 328 dsl_pool_t *
 329 dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg)
 330 {
 331         int err;
 332         dsl_pool_t *dp = dsl_pool_open_impl(spa, txg);
 333         dmu_tx_t *tx = dmu_tx_create_assigned(dp, txg);
 334         objset_t *os;
 335         dsl_dataset_t *ds;
 336         uint64_t obj;
 337 
 338         rrw_enter(&dp->dp_config_rwlock, RW_WRITER, FTAG);
 339 




   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  * Copyright (c) 2013 Steven Hartland. All rights reserved.
  25  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  26  */
  27 
  28 #include <sys/dsl_pool.h>
  29 #include <sys/dsl_dataset.h>
  30 #include <sys/dsl_prop.h>
  31 #include <sys/dsl_dir.h>
  32 #include <sys/dsl_synctask.h>
  33 #include <sys/dsl_scan.h>
  34 #include <sys/dnode.h>
  35 #include <sys/dmu_tx.h>
  36 #include <sys/dmu_objset.h>
  37 #include <sys/arc.h>
  38 #include <sys/zap.h>
  39 #include <sys/zio.h>
  40 #include <sys/zfs_context.h>
  41 #include <sys/fs/zfs.h>
  42 #include <sys/zfs_znode.h>
  43 #include <sys/spa_impl.h>
  44 #include <sys/dsl_deadlist.h>
  45 #include <sys/bptree.h>


 301                 dsl_dir_rele(dp->dp_free_dir, dp);
 302         if (dp->dp_leak_dir)
 303                 dsl_dir_rele(dp->dp_leak_dir, dp);
 304         if (dp->dp_root_dir)
 305                 dsl_dir_rele(dp->dp_root_dir, dp);
 306 
 307         bpobj_close(&dp->dp_free_bpobj);
 308 
 309         /* undo the dmu_objset_open_impl(mos) from dsl_pool_open() */
 310         if (dp->dp_meta_objset)
 311                 dmu_objset_evict(dp->dp_meta_objset);
 312 
 313         txg_list_destroy(&dp->dp_dirty_datasets);
 314         txg_list_destroy(&dp->dp_dirty_zilogs);
 315         txg_list_destroy(&dp->dp_sync_tasks);
 316         txg_list_destroy(&dp->dp_dirty_dirs);
 317 
 318         arc_flush(dp->dp_spa);
 319         txg_fini(dp);
 320         dsl_scan_fini(dp);
 321         dmu_buf_user_evict_wait();
 322 
 323         rrw_destroy(&dp->dp_config_rwlock);
 324         mutex_destroy(&dp->dp_lock);
 325         taskq_destroy(dp->dp_vnrele_taskq);
 326         if (dp->dp_blkstats)
 327                 kmem_free(dp->dp_blkstats, sizeof (zfs_all_blkstats_t));
 328         kmem_free(dp, sizeof (dsl_pool_t));
 329 }
 330 
 331 dsl_pool_t *
 332 dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg)
 333 {
 334         int err;
 335         dsl_pool_t *dp = dsl_pool_open_impl(spa, txg);
 336         dmu_tx_t *tx = dmu_tx_create_assigned(dp, txg);
 337         objset_t *os;
 338         dsl_dataset_t *ds;
 339         uint64_t obj;
 340 
 341         rrw_enter(&dp->dp_config_rwlock, RW_WRITER, FTAG);
 342