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>

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 + * Quiesce, v.: to render temporarily inactive or disabled
      342 + *
      343 + * Blocks until all transactions in the group are committed.
      344 + *
      345 + * On return, the transaction group has reached a stable state in which it can
      346 + * then be passed off to the syncing context.
      347 + */
 340  348  static void
 341  349  txg_quiesce(dsl_pool_t *dp, uint64_t txg)
 342  350  {
 343  351          tx_state_t *tx = &dp->dp_tx;
 344  352          int g = txg & TXG_MASK;
 345  353          int c;
 346  354  
 347  355          /*
 348  356           * Grab all tx_cpu locks so nobody else can get into this txg.
 349  357           */
↓ open down ↓ 30 lines elided ↑ open up ↑
 380  388  {
 381  389          dmu_tx_do_callbacks(cb_list, 0);
 382  390  
 383  391          list_destroy(cb_list);
 384  392  
 385  393          kmem_free(cb_list, sizeof (list_t));
 386  394  }
 387  395  
 388  396  /*
 389  397   * Dispatch the commit callbacks registered on this txg to worker threads.
      398 + *
      399 + * If no callbacks are registered for a given TXG, nothing happens.
      400 + * This function creates a taskq for the associated pool, if needed.
 390  401   */
 391  402  static void
 392  403  txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg)
 393  404  {
 394  405          int c;
 395  406          tx_state_t *tx = &dp->dp_tx;
 396  407          list_t *cb_list;
 397  408  
 398  409          for (c = 0; c < max_ncpus; c++) {
 399  410                  tx_cpu_t *tc = &tx->tx_cpu[c];
 400      -                /* No need to lock tx_cpu_t at this point */
      411 +                /*
      412 +                 * No need to lock tx_cpu_t at this point, since this can
      413 +                 * only be called once a txg has been synced.
      414 +                 */
 401  415  
 402  416                  int g = txg & TXG_MASK;
 403  417  
 404  418                  if (list_is_empty(&tc->tc_callbacks[g]))
 405  419                          continue;
 406  420  
 407  421                  if (tx->tx_commit_cb_taskq == NULL) {
 408  422                          /*
 409  423                           * Commit callback taskq hasn't been created yet.
 410  424                           */
↓ open down ↓ 397 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX