Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/vdev.c
          +++ new/usr/src/uts/common/fs/zfs/vdev.c
↓ open down ↓ 584 lines elided ↑ open up ↑
 585  585          ASSERT(vd->vdev_guid_sum == vd->vdev_guid);
 586  586  
 587  587          /*
 588  588           * Discard allocation state.
 589  589           */
 590  590          if (vd->vdev_mg != NULL) {
 591  591                  vdev_metaslab_fini(vd);
 592  592                  metaslab_group_destroy(vd->vdev_mg);
 593  593          }
 594  594  
 595      -        ASSERT3U(vd->vdev_stat.vs_space, ==, 0);
 596      -        ASSERT3U(vd->vdev_stat.vs_dspace, ==, 0);
 597      -        ASSERT3U(vd->vdev_stat.vs_alloc, ==, 0);
      595 +        ASSERT0(vd->vdev_stat.vs_space);
      596 +        ASSERT0(vd->vdev_stat.vs_dspace);
      597 +        ASSERT0(vd->vdev_stat.vs_alloc);
 598  598  
 599  599          /*
 600  600           * Remove this vdev from its parent's child list.
 601  601           */
 602  602          vdev_remove_child(vd->vdev_parent, vd);
 603  603  
 604  604          ASSERT(vd->vdev_parent == NULL);
 605  605  
 606  606          /*
 607  607           * Clean up vdev structure.
↓ open down ↓ 1190 lines elided ↑ open up ↑
1798 1798          dmu_buf_t *db;
1799 1799          dmu_tx_t *tx;
1800 1800  
1801 1801          ASSERT(!vd->vdev_ishole);
1802 1802  
1803 1803          tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
1804 1804  
1805 1805          if (vd->vdev_detached) {
1806 1806                  if (smo->smo_object != 0) {
1807 1807                          int err = dmu_object_free(mos, smo->smo_object, tx);
1808      -                        ASSERT3U(err, ==, 0);
     1808 +                        ASSERT0(err);
1809 1809                          smo->smo_object = 0;
1810 1810                  }
1811 1811                  dmu_tx_commit(tx);
1812 1812                  return;
1813 1813          }
1814 1814  
1815 1815          if (smo->smo_object == 0) {
1816 1816                  ASSERT(smo->smo_objsize == 0);
1817 1817                  ASSERT(smo->smo_alloc == 0);
1818 1818                  smo->smo_object = dmu_object_alloc(mos,
↓ open down ↓ 179 lines elided ↑ open up ↑
1998 1998  void
1999 1999  vdev_remove(vdev_t *vd, uint64_t txg)
2000 2000  {
2001 2001          spa_t *spa = vd->vdev_spa;
2002 2002          objset_t *mos = spa->spa_meta_objset;
2003 2003          dmu_tx_t *tx;
2004 2004  
2005 2005          tx = dmu_tx_create_assigned(spa_get_dsl(spa), txg);
2006 2006  
2007 2007          if (vd->vdev_dtl_smo.smo_object) {
2008      -                ASSERT3U(vd->vdev_dtl_smo.smo_alloc, ==, 0);
     2008 +                ASSERT0(vd->vdev_dtl_smo.smo_alloc);
2009 2009                  (void) dmu_object_free(mos, vd->vdev_dtl_smo.smo_object, tx);
2010 2010                  vd->vdev_dtl_smo.smo_object = 0;
2011 2011          }
2012 2012  
2013 2013          if (vd->vdev_ms != NULL) {
2014 2014                  for (int m = 0; m < vd->vdev_ms_count; m++) {
2015 2015                          metaslab_t *msp = vd->vdev_ms[m];
2016 2016  
2017 2017                          if (msp == NULL || msp->ms_smo.smo_object == 0)
2018 2018                                  continue;
2019 2019  
2020      -                        ASSERT3U(msp->ms_smo.smo_alloc, ==, 0);
     2020 +                        ASSERT0(msp->ms_smo.smo_alloc);
2021 2021                          (void) dmu_object_free(mos, msp->ms_smo.smo_object, tx);
2022 2022                          msp->ms_smo.smo_object = 0;
2023 2023                  }
2024 2024          }
2025 2025  
2026 2026          if (vd->vdev_ms_array) {
2027 2027                  (void) dmu_object_free(mos, vd->vdev_ms_array, tx);
2028 2028                  vd->vdev_ms_array = 0;
2029 2029                  vd->vdev_ms_shift = 0;
2030 2030          }
↓ open down ↓ 257 lines elided ↑ open up ↑
2288 2288                           * Check to see if the config has changed.
2289 2289                           */
2290 2290                          if (error || generation != spa->spa_config_generation) {
2291 2291                                  metaslab_group_activate(mg);
2292 2292                                  if (error)
2293 2293                                          return (spa_vdev_state_exit(spa,
2294 2294                                              vd, error));
2295 2295                                  (void) spa_vdev_state_exit(spa, vd, 0);
2296 2296                                  goto top;
2297 2297                          }
2298      -                        ASSERT3U(tvd->vdev_stat.vs_alloc, ==, 0);
     2298 +                        ASSERT0(tvd->vdev_stat.vs_alloc);
2299 2299                  }
2300 2300  
2301 2301                  /*
2302 2302                   * Offline this device and reopen its top-level vdev.
2303 2303                   * If the top-level vdev is a log device then just offline
2304 2304                   * it. Otherwise, if this action results in the top-level
2305 2305                   * vdev becoming unusable, undo it and fail the request.
2306 2306                   */
2307 2307                  vd->vdev_offline = B_TRUE;
2308 2308                  vdev_reopen(tvd);
↓ open down ↓ 847 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX