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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/fssnap.c
          +++ new/usr/src/uts/common/io/fssnap.c
↓ open down ↓ 1536 lines elided ↑ open up ↑
1537 1537                   * chunks in memory.  The semaphore is sema_v'd by the taskq.
1538 1538                   *
1539 1539                   * You can't keep the sid_rwlock if you would go to sleep.
1540 1540                   * This will result in deadlock when someone tries to delete
1541 1541                   * the snapshot (wants the sid_rwlock as a writer, but can't
1542 1542                   * get it).
1543 1543                   */
1544 1544                  if (throttle_write) {
1545 1545                          if (sema_tryp(&cmap->cmap_throttle_sem) == 0) {
1546 1546                                  rw_exit(&sidp->sid_rwlock);
1547      -                                atomic_add_32(&cmap->cmap_waiters, 1);
     1547 +                                atomic_inc_32(&cmap->cmap_waiters);
1548 1548                                  sema_p(&cmap->cmap_throttle_sem);
1549      -                                atomic_add_32(&cmap->cmap_waiters, -1);
     1549 +                                atomic_dec_32(&cmap->cmap_waiters);
1550 1550                                  rw_enter(&sidp->sid_rwlock, RW_READER);
1551 1551  
1552 1552                          /*
1553 1553                           * Now since we released the sid_rwlock the state may
1554 1554                           * have transitioned underneath us. so check that again.
1555 1555                           */
1556 1556                                  if (sidp != *sidpp || SID_INACTIVE(sidp)) {
1557 1557                                          sema_v(&cmap->cmap_throttle_sem);
1558 1558                                          return (ENXIO);
1559 1559                                  }
↓ open down ↓ 113 lines elided ↑ open up ↑
1673 1673          /* if the snapshot was disabled from under us, drop the request. */
1674 1674          rw_enter(&sidp->sid_rwlock, RW_READER);
1675 1675          if (SID_INACTIVE(sidp)) {
1676 1676                  rw_exit(&sidp->sid_rwlock);
1677 1677                  if (release_sem)
1678 1678                          sema_v(&cmap->cmap_throttle_sem);
1679 1679                  return;
1680 1680          }
1681 1681          rw_exit(&sidp->sid_rwlock);
1682 1682  
1683      -        atomic_add_64((uint64_t *)&cmap->cmap_nchunks, 1);
     1683 +        atomic_inc_64((uint64_t *)&cmap->cmap_nchunks);
1684 1684  
1685 1685          if ((cmap->cmap_maxsize != 0) &&
1686 1686              ((cmap->cmap_nchunks * cmap->cmap_chunksz) > cmap->cmap_maxsize)) {
1687 1687                  cmn_err(CE_WARN, "fssnap_write_taskq: snapshot %d (%s) has "
1688 1688                      "reached the maximum backing file size specified (%llu "
1689 1689                      "bytes) and will be deleted.", sidp->sid_snapnumber,
1690 1690                      (char *)cowp->cow_kstat_mntpt->ks_data,
1691 1691                      cmap->cmap_maxsize);
1692 1692                  if (release_sem)
1693 1693                          sema_v(&cmap->cmap_throttle_sem);
↓ open down ↓ 632 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX