Print this page
    
6536 zfs send: want a way to disable sending of free records
Reviewed by: Alexander Stetsenko <astetsenko@racktopsystems.com>
Reviewed by: Kim Shrier <kshrier@racktopsystems.com>
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
          +++ new/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  
    | ↓ open down ↓ | 17 lines elided | ↑ open up ↑ | 
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  /*
  26   26   * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  27   27   * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
       28 + * Copyright 2015 RackTop Systems.
  28   29   */
  29   30  
  30   31  #ifndef _SYS_DMU_IMPL_H
  31   32  #define _SYS_DMU_IMPL_H
  32   33  
  33   34  #include <sys/txg_impl.h>
  34   35  #include <sys/zio.h>
  35   36  #include <sys/dnode.h>
  36   37  #include <sys/zfs_context.h>
  37   38  #include <sys/zfs_ioctl.h>
  38   39  
  39   40  #ifdef  __cplusplus
  40   41  extern "C" {
  41   42  #endif
  42   43  
  43   44  /*
  44   45   * This is the locking strategy for the DMU.  Numbers in parenthesis are
  45   46   * cases that use that lock order, referenced below:
  46   47   *
  47   48   * ARC is self-contained
  48   49   * bplist is self-contained
  49   50   * refcount is self-contained
  50   51   * txg is self-contained (hopefully!)
  51   52   * zst_lock
  52   53   * zf_rwlock
  53   54   *
  54   55   * XXX try to improve evicting path?
  55   56   *
  56   57   * dp_config_rwlock > os_obj_lock > dn_struct_rwlock >
  57   58   *      dn_dbufs_mtx > hash_mutexes > db_mtx > dd_lock > leafs
  58   59   *
  59   60   * dp_config_rwlock
  60   61   *    must be held before: everything
  61   62   *    protects dd namespace changes
  62   63   *    protects property changes globally
  63   64   *    held from:
  64   65   *      dsl_dir_open/r:
  65   66   *      dsl_dir_create_sync/w:
  66   67   *      dsl_dir_sync_destroy/w:
  67   68   *      dsl_dir_rename_sync/w:
  68   69   *      dsl_prop_changed_notify/r:
  69   70   *
  70   71   * os_obj_lock
  71   72   *   must be held before:
  72   73   *      everything except dp_config_rwlock
  73   74   *   protects os_obj_next
  74   75   *   held from:
  75   76   *      dmu_object_alloc: dn_dbufs_mtx, db_mtx, hash_mutexes, dn_struct_rwlock
  76   77   *
  77   78   * dn_struct_rwlock
  78   79   *   must be held before:
  79   80   *      everything except dp_config_rwlock and os_obj_lock
  80   81   *   protects structure of dnode (eg. nlevels)
  81   82   *      db_blkptr can change when syncing out change to nlevels
  82   83   *      dn_maxblkid
  83   84   *      dn_nlevels
  84   85   *      dn_*blksz*
  85   86   *      phys nlevels, maxblkid, physical blkptr_t's (?)
  86   87   *   held from:
  87   88   *      callers of dbuf_read_impl, dbuf_hold[_impl], dbuf_prefetch
  88   89   *      dmu_object_info_from_dnode: dn_dirty_mtx (dn_datablksz)
  89   90   *      dmu_tx_count_free:
  90   91   *      dbuf_read_impl: db_mtx, dmu_zfetch()
  91   92   *      dmu_zfetch: zf_rwlock/r, zst_lock, dbuf_prefetch()
  92   93   *      dbuf_new_size: db_mtx
  93   94   *      dbuf_dirty: db_mtx
  94   95   *      dbuf_findbp: (callers, phys? - the real need)
  95   96   *      dbuf_create: dn_dbufs_mtx, hash_mutexes, db_mtx (phys?)
  96   97   *      dbuf_prefetch: dn_dirty_mtx, hash_mutexes, db_mtx, dn_dbufs_mtx
  97   98   *      dbuf_hold_impl: hash_mutexes, db_mtx, dn_dbufs_mtx, dbuf_findbp()
  98   99   *      dnode_sync/w (increase_indirection): db_mtx (phys)
  99  100   *      dnode_set_blksz/w: dn_dbufs_mtx (dn_*blksz*)
 100  101   *      dnode_new_blkid/w: (dn_maxblkid)
 101  102   *      dnode_free_range/w: dn_dirty_mtx (dn_maxblkid)
 102  103   *      dnode_next_offset: (phys)
 103  104   *
 104  105   * dn_dbufs_mtx
 105  106   *    must be held before:
 106  107   *      db_mtx, hash_mutexes
 107  108   *    protects:
 108  109   *      dn_dbufs
 109  110   *      dn_evicted
 110  111   *    held from:
 111  112   *      dmu_evict_user: db_mtx (dn_dbufs)
 112  113   *      dbuf_free_range: db_mtx (dn_dbufs)
 113  114   *      dbuf_remove_ref: db_mtx, callees:
 114  115   *              dbuf_hash_remove: hash_mutexes, db_mtx
 115  116   *      dbuf_create: hash_mutexes, db_mtx (dn_dbufs)
 116  117   *      dnode_set_blksz: (dn_dbufs)
 117  118   *
 118  119   * hash_mutexes (global)
 119  120   *   must be held before:
 120  121   *      db_mtx
 121  122   *   protects dbuf_hash_table (global) and db_hash_next
 122  123   *   held from:
 123  124   *      dbuf_find: db_mtx
 124  125   *      dbuf_hash_insert: db_mtx
 125  126   *      dbuf_hash_remove: db_mtx
 126  127   *
 127  128   * db_mtx (meta-leaf)
 128  129   *   must be held before:
 129  130   *      dn_mtx, dn_dirty_mtx, dd_lock (leaf mutexes)
 130  131   *   protects:
 131  132   *      db_state
 132  133   *      db_holds
 133  134   *      db_buf
 134  135   *      db_changed
 135  136   *      db_data_pending
 136  137   *      db_dirtied
 137  138   *      db_link
 138  139   *      db_dirty_node (??)
 139  140   *      db_dirtycnt
 140  141   *      db_d.*
 141  142   *      db.*
 142  143   *   held from:
 143  144   *      dbuf_dirty: dn_mtx, dn_dirty_mtx
 144  145   *      dbuf_dirty->dsl_dir_willuse_space: dd_lock
 145  146   *      dbuf_dirty->dbuf_new_block->dsl_dataset_block_freeable: dd_lock
 146  147   *      dbuf_undirty: dn_dirty_mtx (db_d)
 147  148   *      dbuf_write_done: dn_dirty_mtx (db_state)
 148  149   *      dbuf_*
 149  150   *      dmu_buf_update_user: none (db_d)
 150  151   *      dmu_evict_user: none (db_d) (maybe can eliminate)
 151  152   *      dbuf_find: none (db_holds)
 152  153   *      dbuf_hash_insert: none (db_holds)
 153  154   *      dmu_buf_read_array_impl: none (db_state, db_changed)
 154  155   *      dmu_sync: none (db_dirty_node, db_d)
 155  156   *      dnode_reallocate: none (db)
 156  157   *
 157  158   * dn_mtx (leaf)
 158  159   *   protects:
 159  160   *      dn_dirty_dbufs
 160  161   *      dn_ranges
 161  162   *      phys accounting
 162  163   *      dn_allocated_txg
 163  164   *      dn_free_txg
 164  165   *      dn_assigned_txg
 165  166   *      dd_assigned_tx
 166  167   *      dn_notxholds
 167  168   *      dn_dirtyctx
 168  169   *      dn_dirtyctx_firstset
 169  170   *      (dn_phys copy fields?)
 170  171   *      (dn_phys contents?)
 171  172   *   held from:
 172  173   *      dnode_*
 173  174   *      dbuf_dirty: none
 174  175   *      dbuf_sync: none (phys accounting)
 175  176   *      dbuf_undirty: none (dn_ranges, dn_dirty_dbufs)
 176  177   *      dbuf_write_done: none (phys accounting)
 177  178   *      dmu_object_info_from_dnode: none (accounting)
 178  179   *      dmu_tx_commit: none
 179  180   *      dmu_tx_hold_object_impl: none
 180  181   *      dmu_tx_try_assign: dn_notxholds(cv)
 181  182   *      dmu_tx_unassign: none
 182  183   *
 183  184   * dd_lock
 184  185   *    must be held before:
 185  186   *      ds_lock
 186  187   *      ancestors' dd_lock
 187  188   *    protects:
 188  189   *      dd_prop_cbs
 189  190   *      dd_sync_*
 190  191   *      dd_used_bytes
 191  192   *      dd_tempreserved
 192  193   *      dd_space_towrite
 193  194   *      dd_myname
 194  195   *      dd_phys accounting?
 195  196   *    held from:
 196  197   *      dsl_dir_*
 197  198   *      dsl_prop_changed_notify: none (dd_prop_cbs)
 198  199   *      dsl_prop_register: none (dd_prop_cbs)
 199  200   *      dsl_prop_unregister: none (dd_prop_cbs)
 200  201   *      dsl_dataset_block_freeable: none (dd_sync_*)
 201  202   *
 202  203   * os_lock (leaf)
 203  204   *   protects:
 204  205   *      os_dirty_dnodes
 205  206   *      os_free_dnodes
 206  207   *      os_dnodes
 207  208   *      os_downgraded_dbufs
 208  209   *      dn_dirtyblksz
 209  210   *      dn_dirty_link
 210  211   *   held from:
 211  212   *      dnode_create: none (os_dnodes)
 212  213   *      dnode_destroy: none (os_dnodes)
 213  214   *      dnode_setdirty: none (dn_dirtyblksz, os_*_dnodes)
 214  215   *      dnode_free: none (dn_dirtyblksz, os_*_dnodes)
 215  216   *
 216  217   * ds_lock
 217  218   *    protects:
 218  219   *      ds_objset
 219  220   *      ds_open_refcount
 220  221   *      ds_snapname
 221  222   *      ds_phys accounting
 222  223   *      ds_phys userrefs zapobj
 223  224   *      ds_reserved
 224  225   *    held from:
 225  226   *      dsl_dataset_*
 226  227   *
 227  228   * dr_mtx (leaf)
 228  229   *    protects:
 229  230   *      dr_children
 230  231   *    held from:
 231  232   *      dbuf_dirty
 232  233   *      dbuf_undirty
 233  234   *      dbuf_sync_indirect
 234  235   *      dnode_new_blkid
 235  236   */
 236  237  
 237  238  struct objset;
 238  239  struct dmu_pool;
 239  240  
 240  241  typedef struct dmu_xuio {
 241  242          int next;
 242  243          int cnt;
 243  244          struct arc_buf **bufs;
 244  245          iovec_t *iovp;
 245  246  } dmu_xuio_t;
 246  247  
 247  248  typedef struct xuio_stats {
 248  249          /* loaned yet not returned arc_buf */
 249  250          kstat_named_t xuiostat_onloan_rbuf;
 250  251          kstat_named_t xuiostat_onloan_wbuf;
 251  252          /* whether a copy is made when loaning out a read buffer */
 252  253          kstat_named_t xuiostat_rbuf_copied;
 253  254          kstat_named_t xuiostat_rbuf_nocopy;
 254  255          /* whether a copy is made when assigning a write buffer */
 255  256          kstat_named_t xuiostat_wbuf_copied;
 256  257          kstat_named_t xuiostat_wbuf_nocopy;
 257  258  } xuio_stats_t;
 258  259  
 259  260  static xuio_stats_t xuio_stats = {
 260  261          { "onloan_read_buf",    KSTAT_DATA_UINT64 },
 261  262          { "onloan_write_buf",   KSTAT_DATA_UINT64 },
 262  263          { "read_buf_copied",    KSTAT_DATA_UINT64 },
 263  264          { "read_buf_nocopy",    KSTAT_DATA_UINT64 },
 264  265          { "write_buf_copied",   KSTAT_DATA_UINT64 },
 265  266          { "write_buf_nocopy",   KSTAT_DATA_UINT64 }
 266  267  };
 267  268  
 268  269  #define XUIOSTAT_INCR(stat, val)        \
 269  270          atomic_add_64(&xuio_stats.stat.value.ui64, (val))
 270  271  #define XUIOSTAT_BUMP(stat)     XUIOSTAT_INCR(stat, 1)
 271  272  
 272  273  /*
 273  274   * The list of data whose inclusion in a send stream can be pending from
 274  275   * one call to backup_cb to another.  Multiple calls to dump_free() and
 275  276   * dump_freeobjects() can be aggregated into a single DRR_FREE or
 276  277   * DRR_FREEOBJECTS replay record.
 277  278   */
 278  279  typedef enum {
 279  280          PENDING_NONE,
 280  281          PENDING_FREE,
 281  282          PENDING_FREEOBJECTS
 282  283  } dmu_pendop_t;
 283  284  
 284  285  typedef struct dmu_sendarg {
 285  286          list_node_t dsa_link;
 286  287          dmu_replay_record_t *dsa_drr;
 287  288          vnode_t *dsa_vp;
 288  289          int dsa_outfd;
 289  290          struct proc *dsa_proc;
 290  291          offset_t *dsa_off;
  
    | ↓ open down ↓ | 253 lines elided | ↑ open up ↑ | 
 291  292          objset_t *dsa_os;
 292  293          zio_cksum_t dsa_zc;
 293  294          uint64_t dsa_toguid;
 294  295          int dsa_err;
 295  296          dmu_pendop_t dsa_pending_op;
 296  297          uint64_t dsa_featureflags;
 297  298          uint64_t dsa_last_data_object;
 298  299          uint64_t dsa_last_data_offset;
 299  300          uint64_t dsa_resume_object;
 300  301          uint64_t dsa_resume_offset;
      302 +        boolean_t dsa_skip_free;
 301  303  } dmu_sendarg_t;
 302  304  
 303  305  void dmu_object_zapify(objset_t *, uint64_t, dmu_object_type_t, dmu_tx_t *);
 304  306  void dmu_object_free_zapified(objset_t *, uint64_t, dmu_tx_t *);
 305  307  int dmu_buf_hold_noread(objset_t *, uint64_t, uint64_t,
 306  308      void *, dmu_buf_t **);
 307  309  
 308  310  #ifdef  __cplusplus
 309  311  }
 310  312  #endif
 311  313  
 312  314  #endif  /* _SYS_DMU_IMPL_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX