Print this page
3741 zfs needs better comments
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Alan Somers <alans@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>
Reviewed by:    Eric Schrock <eric.schrock@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/txg.c
          +++ new/usr/src/uts/common/fs/zfs/txg.c
↓ open down ↓ 329 lines elided ↑ open up ↑
 330  330  
 331  331          mutex_enter(&tc->tc_lock);
 332  332          ASSERT(tc->tc_count[g] != 0);
 333  333          if (--tc->tc_count[g] == 0)
 334  334                  cv_broadcast(&tc->tc_cv[g]);
 335  335          mutex_exit(&tc->tc_lock);
 336  336  
 337  337          th->th_cpu = NULL;      /* defensive */
 338  338  }
 339  339  
      340 +/*
      341 + * Blocks until all transactions in the group are committed.
      342 + *
      343 + * On return, the transaction group has reached a stable state in which it can
      344 + * then be passed off to the syncing context.
      345 + */
 340  346  static void
 341  347  txg_quiesce(dsl_pool_t *dp, uint64_t txg)
 342  348  {
 343  349          tx_state_t *tx = &dp->dp_tx;
 344  350          int g = txg & TXG_MASK;
 345  351          int c;
 346  352  
 347  353          /*
 348  354           * Grab all tx_cpu locks so nobody else can get into this txg.
 349  355           */
↓ open down ↓ 30 lines elided ↑ open up ↑
 380  386  {
 381  387          dmu_tx_do_callbacks(cb_list, 0);
 382  388  
 383  389          list_destroy(cb_list);
 384  390  
 385  391          kmem_free(cb_list, sizeof (list_t));
 386  392  }
 387  393  
 388  394  /*
 389  395   * Dispatch the commit callbacks registered on this txg to worker threads.
      396 + *
      397 + * If no callbacks are registered for a given TXG, nothing happens.
      398 + * This function creates a taskq for the associated pool, if needed.
 390  399   */
 391  400  static void
 392  401  txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg)
 393  402  {
 394  403          int c;
 395  404          tx_state_t *tx = &dp->dp_tx;
 396  405          list_t *cb_list;
 397  406  
 398  407          for (c = 0; c < max_ncpus; c++) {
 399  408                  tx_cpu_t *tc = &tx->tx_cpu[c];
 400      -                /* No need to lock tx_cpu_t at this point */
      409 +                /*
      410 +                 * No need to lock tx_cpu_t at this point, since this can
      411 +                 * only be called once a txg has been synced.
      412 +                 */
 401  413  
 402  414                  int g = txg & TXG_MASK;
 403  415  
 404  416                  if (list_is_empty(&tc->tc_callbacks[g]))
 405  417                          continue;
 406  418  
 407  419                  if (tx->tx_commit_cb_taskq == NULL) {
 408  420                          /*
 409  421                           * Commit callback taskq hasn't been created yet.
 410  422                           */
↓ open down ↓ 397 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX