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>


   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) 2012, 2014 by Delphix. All rights reserved.

  24  */
  25 
  26 #ifndef _SYS_DNODE_H
  27 #define _SYS_DNODE_H
  28 
  29 #include <sys/zfs_context.h>
  30 #include <sys/avl.h>
  31 #include <sys/spa.h>
  32 #include <sys/txg.h>
  33 #include <sys/zio.h>
  34 #include <sys/refcount.h>
  35 #include <sys/dmu_zfetch.h>
  36 #include <sys/zrlock.h>
  37 
  38 #ifdef  __cplusplus
  39 extern "C" {
  40 #endif
  41 
  42 /*
  43  * dnode_hold() flags.


 238         uint64_t dn_olduid, dn_oldgid;
 239         uint64_t dn_newuid, dn_newgid;
 240         int dn_id_flags;
 241 
 242         /* holds prefetch structure */
 243         struct zfetch   dn_zfetch;
 244 } dnode_t;
 245 
 246 /*
 247  * Adds a level of indirection between the dbuf and the dnode to avoid
 248  * iterating descendent dbufs in dnode_move(). Handles are not allocated
 249  * individually, but as an array of child dnodes in dnode_hold_impl().
 250  */
 251 typedef struct dnode_handle {
 252         /* Protects dnh_dnode from modification by dnode_move(). */
 253         zrlock_t dnh_zrlock;
 254         dnode_t *dnh_dnode;
 255 } dnode_handle_t;
 256 
 257 typedef struct dnode_children {

 258         size_t dnc_count;               /* number of children */
 259         dnode_handle_t dnc_children[];  /* sized dynamically */
 260 } dnode_children_t;
 261 
 262 typedef struct free_range {
 263         avl_node_t fr_node;
 264         uint64_t fr_blkid;
 265         uint64_t fr_nblks;
 266 } free_range_t;
 267 
 268 dnode_t *dnode_special_open(struct objset *dd, dnode_phys_t *dnp,
 269     uint64_t object, dnode_handle_t *dnh);
 270 void dnode_special_close(dnode_handle_t *dnh);
 271 
 272 void dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx);
 273 void dnode_setbonus_type(dnode_t *dn, dmu_object_type_t, dmu_tx_t *tx);
 274 void dnode_rm_spill(dnode_t *dn, dmu_tx_t *tx);
 275 
 276 int dnode_hold(struct objset *dd, uint64_t object,
 277     void *ref, dnode_t **dnp);
 278 int dnode_hold_impl(struct objset *dd, uint64_t object, int flag,
 279     void *ref, dnode_t **dnp);
 280 boolean_t dnode_add_ref(dnode_t *dn, void *ref);
 281 void dnode_rele(dnode_t *dn, void *ref);
 282 void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx);
 283 void dnode_sync(dnode_t *dn, dmu_tx_t *tx);
 284 void dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs,
 285     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 286 void dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize,
 287     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 288 void dnode_free(dnode_t *dn, dmu_tx_t *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) 2012, 2014 by Delphix. All rights reserved.
  24  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  25  */
  26 
  27 #ifndef _SYS_DNODE_H
  28 #define _SYS_DNODE_H
  29 
  30 #include <sys/zfs_context.h>
  31 #include <sys/avl.h>
  32 #include <sys/spa.h>
  33 #include <sys/txg.h>
  34 #include <sys/zio.h>
  35 #include <sys/refcount.h>
  36 #include <sys/dmu_zfetch.h>
  37 #include <sys/zrlock.h>
  38 
  39 #ifdef  __cplusplus
  40 extern "C" {
  41 #endif
  42 
  43 /*
  44  * dnode_hold() flags.


 239         uint64_t dn_olduid, dn_oldgid;
 240         uint64_t dn_newuid, dn_newgid;
 241         int dn_id_flags;
 242 
 243         /* holds prefetch structure */
 244         struct zfetch   dn_zfetch;
 245 } dnode_t;
 246 
 247 /*
 248  * Adds a level of indirection between the dbuf and the dnode to avoid
 249  * iterating descendent dbufs in dnode_move(). Handles are not allocated
 250  * individually, but as an array of child dnodes in dnode_hold_impl().
 251  */
 252 typedef struct dnode_handle {
 253         /* Protects dnh_dnode from modification by dnode_move(). */
 254         zrlock_t dnh_zrlock;
 255         dnode_t *dnh_dnode;
 256 } dnode_handle_t;
 257 
 258 typedef struct dnode_children {
 259         dmu_buf_user_t dnc_dbu;         /* User evict data */
 260         size_t dnc_count;               /* number of children */
 261         dnode_handle_t dnc_children[];  /* sized dynamically */
 262 } dnode_children_t;
 263 
 264 typedef struct free_range {
 265         avl_node_t fr_node;
 266         uint64_t fr_blkid;
 267         uint64_t fr_nblks;
 268 } free_range_t;
 269 
 270 void dnode_special_open(struct objset *dd, dnode_phys_t *dnp,
 271     uint64_t object, dnode_handle_t *dnh);
 272 void dnode_special_close(dnode_handle_t *dnh);
 273 
 274 void dnode_setbonuslen(dnode_t *dn, int newsize, dmu_tx_t *tx);
 275 void dnode_setbonus_type(dnode_t *dn, dmu_object_type_t, dmu_tx_t *tx);
 276 void dnode_rm_spill(dnode_t *dn, dmu_tx_t *tx);
 277 
 278 int dnode_hold(struct objset *dd, uint64_t object,
 279     void *ref, dnode_t **dnp);
 280 int dnode_hold_impl(struct objset *dd, uint64_t object, int flag,
 281     void *ref, dnode_t **dnp);
 282 boolean_t dnode_add_ref(dnode_t *dn, void *ref);
 283 void dnode_rele(dnode_t *dn, void *ref);
 284 void dnode_setdirty(dnode_t *dn, dmu_tx_t *tx);
 285 void dnode_sync(dnode_t *dn, dmu_tx_t *tx);
 286 void dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs,
 287     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 288 void dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize,
 289     dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
 290 void dnode_free(dnode_t *dn, dmu_tx_t *tx);