Print this page
5045 use atomic_{inc,dec}_* instead of atomic_add_*

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zio_inject.c
          +++ new/usr/src/uts/common/fs/zfs/zio_inject.c
↓ open down ↓ 418 lines elided ↑ open up ↑
 419  419                          return (SET_ERROR(ENOENT));
 420  420  
 421  421                  handler = kmem_alloc(sizeof (inject_handler_t), KM_SLEEP);
 422  422  
 423  423                  rw_enter(&inject_lock, RW_WRITER);
 424  424  
 425  425                  *id = handler->zi_id = inject_next_id++;
 426  426                  handler->zi_spa = spa;
 427  427                  handler->zi_record = *record;
 428  428                  list_insert_tail(&inject_handlers, handler);
 429      -                atomic_add_32(&zio_injection_enabled, 1);
      429 +                atomic_inc_32(&zio_injection_enabled);
 430  430  
 431  431                  rw_exit(&inject_lock);
 432  432          }
 433  433  
 434  434          /*
 435  435           * Flush the ARC, so that any attempts to read this data will end up
 436  436           * going to the ZIO layer.  Note that this is a little overkill, but
 437  437           * we don't have the necessary ARC interfaces to do anything else, and
 438  438           * fault injection isn't a performance critical path.
 439  439           */
↓ open down ↓ 56 lines elided ↑ open up ↑
 496  496          if (handler == NULL) {
 497  497                  rw_exit(&inject_lock);
 498  498                  return (SET_ERROR(ENOENT));
 499  499          }
 500  500  
 501  501          list_remove(&inject_handlers, handler);
 502  502          rw_exit(&inject_lock);
 503  503  
 504  504          spa_inject_delref(handler->zi_spa);
 505  505          kmem_free(handler, sizeof (inject_handler_t));
 506      -        atomic_add_32(&zio_injection_enabled, -1);
      506 +        atomic_dec_32(&zio_injection_enabled);
 507  507  
 508  508          return (0);
 509  509  }
 510  510  
 511  511  void
 512  512  zio_inject_init(void)
 513  513  {
 514  514          rw_init(&inject_lock, NULL, RW_DEFAULT, NULL);
 515  515          list_create(&inject_handlers, sizeof (inject_handler_t),
 516  516              offsetof(inject_handler_t, zi_link));
 517  517  }
 518  518  
 519  519  void
 520  520  zio_inject_fini(void)
 521  521  {
 522  522          list_destroy(&inject_handlers);
 523  523          rw_destroy(&inject_lock);
 524  524  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX