Print this page
    
NEX-6859 TX-commit callback that is registered in sync-ctx causes system panic
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Saso Kiselkov <saso.kiselkov@nexenta.com>
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/fs/zfs/sys/txg.h
          +++ new/usr/src/uts/common/fs/zfs/sys/txg.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
  
    | 
      ↓ open down ↓ | 
    15 lines elided | 
    
      ↑ open up ↑ | 
  
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  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 + * Copyright 2016 Nexenta Systems, Inc.  All rights reserved.
  26   27   * Copyright (c) 2012, 2017 by Delphix. All rights reserved.
  27   28   */
  28   29  
  29   30  #ifndef _SYS_TXG_H
  30   31  #define _SYS_TXG_H
  31   32  
  32   33  #include <sys/spa.h>
  33   34  #include <sys/zfs_context.h>
  34   35  
  35   36  #ifdef  __cplusplus
  36   37  extern "C" {
  37   38  #endif
  38   39  
  39   40  #define TXG_CONCURRENT_STATES   3       /* open, quiescing, syncing     */
  40   41  #define TXG_SIZE                4               /* next power of 2      */
  41   42  #define TXG_MASK                (TXG_SIZE - 1)  /* mask for size        */
  42   43  #define TXG_INITIAL             TXG_SIZE        /* initial txg          */
  43   44  #define TXG_IDX                 (txg & TXG_MASK)
  44   45  
  45   46  /* Number of txgs worth of frees we defer adding to in-core spacemaps */
  46   47  #define TXG_DEFER_SIZE          2
  47   48  
  48   49  typedef struct tx_cpu tx_cpu_t;
  49   50  
  50   51  typedef struct txg_handle {
  51   52          tx_cpu_t        *th_cpu;
  52   53          uint64_t        th_txg;
  53   54  } txg_handle_t;
  54   55  
  55   56  typedef struct txg_node {
  56   57          struct txg_node *tn_next[TXG_SIZE];
  57   58          uint8_t         tn_member[TXG_SIZE];
  58   59  } txg_node_t;
  59   60  
  60   61  typedef struct txg_list {
  61   62          kmutex_t        tl_lock;
  62   63          size_t          tl_offset;
  63   64          spa_t           *tl_spa;
  64   65          txg_node_t      *tl_head[TXG_SIZE];
  65   66  } txg_list_t;
  66   67  
  
    | 
      ↓ open down ↓ | 
    31 lines elided | 
    
      ↑ open up ↑ | 
  
  67   68  struct dsl_pool;
  68   69  
  69   70  extern void txg_init(struct dsl_pool *dp, uint64_t txg);
  70   71  extern void txg_fini(struct dsl_pool *dp);
  71   72  extern void txg_sync_start(struct dsl_pool *dp);
  72   73  extern void txg_sync_stop(struct dsl_pool *dp);
  73   74  extern uint64_t txg_hold_open(struct dsl_pool *dp, txg_handle_t *txghp);
  74   75  extern void txg_rele_to_quiesce(txg_handle_t *txghp);
  75   76  extern void txg_rele_to_sync(txg_handle_t *txghp);
  76   77  extern void txg_register_callbacks(txg_handle_t *txghp, list_t *tx_callbacks);
       78 +extern void txg_register_callbacks_sync(struct dsl_pool *dp,
       79 +    uint64_t txg, list_t *tx_callbacks);
  77   80  
  78   81  extern void txg_delay(struct dsl_pool *dp, uint64_t txg, hrtime_t delta,
  79   82      hrtime_t resolution);
  80   83  extern void txg_kick(struct dsl_pool *dp);
  81   84  
  82   85  /*
  83   86   * Wait until the given transaction group has finished syncing.
  84   87   * Try to make this happen as soon as possible (eg. kick off any
  85   88   * necessary syncs immediately).  If txg==0, wait for the currently open
  86   89   * txg to finish syncing.
  87   90   */
  88   91  extern void txg_wait_synced(struct dsl_pool *dp, uint64_t txg);
  89   92  
  90   93  /*
  91   94   * Wait until the given transaction group, or one after it, is
  92   95   * the open transaction group.  Try to make this happen as soon
  93   96   * as possible (eg. kick off any necessary syncs immediately).
  94   97   * If txg == 0, wait for the next open txg.
  95   98   */
  96   99  extern void txg_wait_open(struct dsl_pool *dp, uint64_t txg);
  97  100  
  98  101  /*
  99  102   * Returns TRUE if we are "backed up" waiting for the syncing
 100  103   * transaction to complete; otherwise returns FALSE.
 101  104   */
 102  105  extern boolean_t txg_stalled(struct dsl_pool *dp);
 103  106  
 104  107  /* returns TRUE if someone is waiting for the next txg to sync */
 105  108  extern boolean_t txg_sync_waiting(struct dsl_pool *dp);
 106  109  
 107  110  extern void txg_verify(spa_t *spa, uint64_t txg);
 108  111  
 109  112  /*
 110  113   * Per-txg object lists.
 111  114   */
 112  115  
 113  116  #define TXG_CLEAN(txg)  ((txg) - 1)
 114  117  
 115  118  extern void txg_list_create(txg_list_t *tl, spa_t *spa, size_t offset);
 116  119  extern void txg_list_destroy(txg_list_t *tl);
 117  120  extern boolean_t txg_list_empty(txg_list_t *tl, uint64_t txg);
 118  121  extern boolean_t txg_all_lists_empty(txg_list_t *tl);
 119  122  extern boolean_t txg_list_add(txg_list_t *tl, void *p, uint64_t txg);
 120  123  extern boolean_t txg_list_add_tail(txg_list_t *tl, void *p, uint64_t txg);
 121  124  extern void *txg_list_remove(txg_list_t *tl, uint64_t txg);
 122  125  extern void *txg_list_remove_this(txg_list_t *tl, void *p, uint64_t txg);
 123  126  extern boolean_t txg_list_member(txg_list_t *tl, void *p, uint64_t txg);
 124  127  extern void *txg_list_head(txg_list_t *tl, uint64_t txg);
 125  128  extern void *txg_list_next(txg_list_t *tl, void *p, uint64_t txg);
 126  129  
 127  130  #ifdef  __cplusplus
 128  131  }
 129  132  #endif
 130  133  
 131  134  #endif  /* _SYS_TXG_H */
  
    | 
      ↓ open down ↓ | 
    45 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX