Print this page
5047 don't use atomic_*_nv if you discard the return value

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dbuf.c
          +++ new/usr/src/uts/common/fs/zfs/dbuf.c
↓ open down ↓ 1577 lines elided ↑ open up ↑
1578 1578          ASSERT(db->db_data_pending == NULL);
1579 1579  
1580 1580          db->db_state = DB_EVICTING;
1581 1581          db->db_blkptr = NULL;
1582 1582  
1583 1583          DB_DNODE_ENTER(db);
1584 1584          dn = DB_DNODE(db);
1585 1585          dndb = dn->dn_dbuf;
1586 1586          if (db->db_blkid != DMU_BONUS_BLKID && MUTEX_HELD(&dn->dn_dbufs_mtx)) {
1587 1587                  list_remove(&dn->dn_dbufs, db);
1588      -                (void) atomic_dec_32_nv(&dn->dn_dbufs_count);
     1588 +                atomic_dec_32(&dn->dn_dbufs_count);
1589 1589                  membar_producer();
1590 1590                  DB_DNODE_EXIT(db);
1591 1591                  /*
1592 1592                   * Decrementing the dbuf count means that the hold corresponding
1593 1593                   * to the removed dbuf is no longer discounted in dnode_move(),
1594 1594                   * so the dnode cannot be moved until after we release the hold.
1595 1595                   * The membar_producer() ensures visibility of the decremented
1596 1596                   * value in dnode_move(), since DB_DNODE_EXIT doesn't actually
1597 1597                   * release any lock.
1598 1598                   */
↓ open down ↓ 202 lines elided ↑ open up ↑
1801 1801                   * If this dbuf is still on the dn_dbufs list,
1802 1802                   * remove it from that list.
1803 1803                   */
1804 1804                  if (db->db_dnode_handle != NULL) {
1805 1805                          dnode_t *dn;
1806 1806  
1807 1807                          DB_DNODE_ENTER(db);
1808 1808                          dn = DB_DNODE(db);
1809 1809                          mutex_enter(&dn->dn_dbufs_mtx);
1810 1810                          list_remove(&dn->dn_dbufs, db);
1811      -                        (void) atomic_dec_32_nv(&dn->dn_dbufs_count);
     1811 +                        atomic_dec_32(&dn->dn_dbufs_count);
1812 1812                          mutex_exit(&dn->dn_dbufs_mtx);
1813 1813                          DB_DNODE_EXIT(db);
1814 1814                          /*
1815 1815                           * Decrementing the dbuf count means that the hold
1816 1816                           * corresponding to the removed dbuf is no longer
1817 1817                           * discounted in dnode_move(), so the dnode cannot be
1818 1818                           * moved until after we release the hold.
1819 1819                           */
1820 1820                          dnode_rele(dn, db);
1821 1821                          db->db_dnode_handle = NULL;
↓ open down ↓ 264 lines elided ↑ open up ↑
2086 2086  
2087 2087          if (holds == 0) {
2088 2088                  if (db->db_blkid == DMU_BONUS_BLKID) {
2089 2089                          mutex_exit(&db->db_mtx);
2090 2090  
2091 2091                          /*
2092 2092                           * If the dnode moves here, we cannot cross this barrier
2093 2093                           * until the move completes.
2094 2094                           */
2095 2095                          DB_DNODE_ENTER(db);
2096      -                        (void) atomic_dec_32_nv(&DB_DNODE(db)->dn_dbufs_count);
     2096 +                        atomic_dec_32(&DB_DNODE(db)->dn_dbufs_count);
2097 2097                          DB_DNODE_EXIT(db);
2098 2098                          /*
2099 2099                           * The bonus buffer's dnode hold is no longer discounted
2100 2100                           * in dnode_move(). The dnode cannot move until after
2101 2101                           * the dnode_rele().
2102 2102                           */
2103 2103                          dnode_rele(DB_DNODE(db), db);
2104 2104                  } else if (db->db_buf == NULL) {
2105 2105                          /*
2106 2106                           * This is a special case: we never associated this
↓ open down ↓ 720 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX