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/bptree.c
          +++ new/usr/src/uts/common/fs/zfs/bptree.c
↓ open down ↓ 64 lines elided ↑ open up ↑
  65   65          bptree_phys_t *bt;
  66   66  
  67   67          obj = dmu_object_alloc(os, DMU_OTN_UINT64_METADATA,
  68   68              SPA_MAXBLOCKSIZE, DMU_OTN_UINT64_METADATA,
  69   69              sizeof (bptree_phys_t), tx);
  70   70  
  71   71          /*
  72   72           * Bonus buffer contents are already initialized to 0, but for
  73   73           * readability we make it explicit.
  74   74           */
  75      -        VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
       75 +        VERIFY0(dmu_bonus_hold(os, obj, FTAG, &db));
  76   76          dmu_buf_will_dirty(db, tx);
  77   77          bt = db->db_data;
  78   78          bt->bt_begin = 0;
  79   79          bt->bt_end = 0;
  80   80          bt->bt_bytes = 0;
  81   81          bt->bt_comp = 0;
  82   82          bt->bt_uncomp = 0;
  83   83          dmu_buf_rele(db, FTAG);
  84   84  
  85   85          return (obj);
  86   86  }
  87   87  
  88   88  int
  89   89  bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx)
  90   90  {
  91   91          dmu_buf_t *db;
  92   92          bptree_phys_t *bt;
  93   93  
  94      -        VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
       94 +        VERIFY0(dmu_bonus_hold(os, obj, FTAG, &db));
  95   95          bt = db->db_data;
  96   96          ASSERT3U(bt->bt_begin, ==, bt->bt_end);
  97      -        ASSERT3U(bt->bt_bytes, ==, 0);
  98      -        ASSERT3U(bt->bt_comp, ==, 0);
  99      -        ASSERT3U(bt->bt_uncomp, ==, 0);
       97 +        ASSERT0(bt->bt_bytes);
       98 +        ASSERT0(bt->bt_comp);
       99 +        ASSERT0(bt->bt_uncomp);
 100  100          dmu_buf_rele(db, FTAG);
 101  101  
 102  102          return (dmu_object_free(os, obj, tx));
 103  103  }
 104  104  
 105  105  void
 106  106  bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
 107  107      uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx)
 108  108  {
 109  109          dmu_buf_t *db;
 110  110          bptree_phys_t *bt;
 111  111          bptree_entry_phys_t bte;
 112  112  
 113  113          /*
 114  114           * bptree objects are in the pool mos, therefore they can only be
 115  115           * modified in syncing context. Furthermore, this is only modified
 116  116           * by the sync thread, so no locking is necessary.
 117  117           */
 118  118          ASSERT(dmu_tx_is_syncing(tx));
 119  119  
 120      -        VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
      120 +        VERIFY0(dmu_bonus_hold(os, obj, FTAG, &db));
 121  121          bt = db->db_data;
 122  122  
 123  123          bte.be_birth_txg = birth_txg;
 124  124          bte.be_bp = *bp;
 125  125          bzero(&bte.be_zb, sizeof (bte.be_zb));
 126  126          dmu_write(os, obj, bt->bt_end * sizeof (bte), sizeof (bte), &bte, tx);
 127  127  
 128  128          dmu_buf_will_dirty(db, tx);
 129  129          bt->bt_end++;
 130  130          bt->bt_bytes += bytes;
↓ open down ↓ 59 lines elided ↑ open up ↑
 190  190  
 191  191                  err = traverse_dataset_destroyed(os->os_spa, &bte.be_bp,
 192  192                      bte.be_birth_txg, &bte.be_zb, TRAVERSE_POST,
 193  193                      bptree_visit_cb, &ba);
 194  194                  if (free) {
 195  195                          ASSERT(err == 0 || err == ERESTART);
 196  196                          if (err != 0) {
 197  197                                  /* save bookmark for future resume */
 198  198                                  ASSERT3U(bte.be_zb.zb_objset, ==,
 199  199                                      ZB_DESTROYED_OBJSET);
 200      -                                ASSERT3U(bte.be_zb.zb_level, ==, 0);
      200 +                                ASSERT0(bte.be_zb.zb_level);
 201  201                                  dmu_write(os, obj, i * sizeof (bte),
 202  202                                      sizeof (bte), &bte, tx);
 203  203                                  break;
 204  204                          } else {
 205  205                                  ba.ba_phys->bt_begin++;
 206  206                                  (void) dmu_free_range(os, obj,
 207  207                                      i * sizeof (bte), sizeof (bte), tx);
 208  208                          }
 209  209                  }
 210  210          }
 211  211  
 212  212          ASSERT(!free || err != 0 || ba.ba_phys->bt_begin == ba.ba_phys->bt_end);
 213  213  
 214  214          /* if all blocks are free there should be no used space */
 215  215          if (ba.ba_phys->bt_begin == ba.ba_phys->bt_end) {
 216      -                ASSERT3U(ba.ba_phys->bt_bytes, ==, 0);
 217      -                ASSERT3U(ba.ba_phys->bt_comp, ==, 0);
 218      -                ASSERT3U(ba.ba_phys->bt_uncomp, ==, 0);
      216 +                ASSERT0(ba.ba_phys->bt_bytes);
      217 +                ASSERT0(ba.ba_phys->bt_comp);
      218 +                ASSERT0(ba.ba_phys->bt_uncomp);
 219  219          }
 220  220  
 221  221          dmu_buf_rele(db, FTAG);
 222  222  
 223  223          return (err);
 224  224  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX