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/dsl_deadlist.c
          +++ new/usr/src/uts/common/fs/zfs/dsl_deadlist.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright (c) 2011 by Delphix. All rights reserved.
       23 + * Copyright (c) 2012 by Delphix. All rights reserved.
  24   24   */
  25   25  
  26   26  #include <sys/dsl_dataset.h>
  27   27  #include <sys/dmu.h>
  28   28  #include <sys/refcount.h>
  29   29  #include <sys/zap.h>
  30   30  #include <sys/zfs_context.h>
  31   31  #include <sys/dsl_pool.h>
  32   32  
  33   33  /*
↓ open down ↓ 41 lines elided ↑ open up ↑
  75   75                  return;
  76   76  
  77   77          avl_create(&dl->dl_tree, dsl_deadlist_compare,
  78   78              sizeof (dsl_deadlist_entry_t),
  79   79              offsetof(dsl_deadlist_entry_t, dle_node));
  80   80          for (zap_cursor_init(&zc, dl->dl_os, dl->dl_object);
  81   81              zap_cursor_retrieve(&zc, &za) == 0;
  82   82              zap_cursor_advance(&zc)) {
  83   83                  dsl_deadlist_entry_t *dle = kmem_alloc(sizeof (*dle), KM_SLEEP);
  84   84                  dle->dle_mintxg = strtonum(za.za_name, NULL);
  85      -                VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os,
       85 +                VERIFY0(bpobj_open(&dle->dle_bpobj, dl->dl_os,
  86   86                      za.za_first_integer));
  87   87                  avl_add(&dl->dl_tree, dle);
  88   88          }
  89   89          zap_cursor_fini(&zc);
  90   90          dl->dl_havetree = B_TRUE;
  91   91  }
  92   92  
  93   93  void
  94   94  dsl_deadlist_open(dsl_deadlist_t *dl, objset_t *os, uint64_t object)
  95   95  {
  96   96          dmu_object_info_t doi;
  97   97  
  98   98          mutex_init(&dl->dl_lock, NULL, MUTEX_DEFAULT, NULL);
  99   99          dl->dl_os = os;
 100  100          dl->dl_object = object;
 101      -        VERIFY3U(0, ==, dmu_bonus_hold(os, object, dl, &dl->dl_dbuf));
      101 +        VERIFY0(dmu_bonus_hold(os, object, dl, &dl->dl_dbuf));
 102  102          dmu_object_info_from_db(dl->dl_dbuf, &doi);
 103  103          if (doi.doi_type == DMU_OT_BPOBJ) {
 104  104                  dmu_buf_rele(dl->dl_dbuf, dl);
 105  105                  dl->dl_dbuf = NULL;
 106  106                  dl->dl_oldfmt = B_TRUE;
 107      -                VERIFY3U(0, ==, bpobj_open(&dl->dl_bpobj, os, object));
      107 +                VERIFY0(bpobj_open(&dl->dl_bpobj, os, object));
 108  108                  return;
 109  109          }
 110  110  
 111  111          dl->dl_oldfmt = B_FALSE;
 112  112          dl->dl_phys = dl->dl_dbuf->db_data;
 113  113          dl->dl_havetree = B_FALSE;
 114  114  }
 115  115  
 116  116  void
 117  117  dsl_deadlist_close(dsl_deadlist_t *dl)
↓ open down ↓ 30 lines elided ↑ open up ↑
 148  148              sizeof (dsl_deadlist_phys_t), tx));
 149  149  }
 150  150  
 151  151  void
 152  152  dsl_deadlist_free(objset_t *os, uint64_t dlobj, dmu_tx_t *tx)
 153  153  {
 154  154          dmu_object_info_t doi;
 155  155          zap_cursor_t zc;
 156  156          zap_attribute_t za;
 157  157  
 158      -        VERIFY3U(0, ==, dmu_object_info(os, dlobj, &doi));
      158 +        VERIFY0(dmu_object_info(os, dlobj, &doi));
 159  159          if (doi.doi_type == DMU_OT_BPOBJ) {
 160  160                  bpobj_free(os, dlobj, tx);
 161  161                  return;
 162  162          }
 163  163  
 164  164          for (zap_cursor_init(&zc, os, dlobj);
 165  165              zap_cursor_retrieve(&zc, &za) == 0;
 166  166              zap_cursor_advance(&zc))
 167  167                  bpobj_free(os, za.za_first_integer, tx);
 168  168          zap_cursor_fini(&zc);
 169      -        VERIFY3U(0, ==, dmu_object_free(os, dlobj, tx));
      169 +        VERIFY0(dmu_object_free(os, dlobj, tx));
 170  170  }
 171  171  
 172  172  void
 173  173  dsl_deadlist_insert(dsl_deadlist_t *dl, const blkptr_t *bp, dmu_tx_t *tx)
 174  174  {
 175  175          dsl_deadlist_entry_t dle_tofind;
 176  176          dsl_deadlist_entry_t *dle;
 177  177          avl_index_t where;
 178  178  
 179  179          if (dl->dl_oldfmt) {
↓ open down ↓ 31 lines elided ↑ open up ↑
 211  211          dsl_deadlist_entry_t *dle;
 212  212  
 213  213          if (dl->dl_oldfmt)
 214  214                  return;
 215  215  
 216  216          dsl_deadlist_load_tree(dl);
 217  217  
 218  218          dle = kmem_alloc(sizeof (*dle), KM_SLEEP);
 219  219          dle->dle_mintxg = mintxg;
 220  220          obj = bpobj_alloc(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
 221      -        VERIFY3U(0, ==, bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
      221 +        VERIFY0(bpobj_open(&dle->dle_bpobj, dl->dl_os, obj));
 222  222          avl_add(&dl->dl_tree, dle);
 223  223  
 224      -        VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, dl->dl_object,
      224 +        VERIFY0(zap_add_int_key(dl->dl_os, dl->dl_object,
 225  225              mintxg, obj, tx));
 226  226  }
 227  227  
 228  228  /*
 229  229   * Remove this key, merging its entries into the previous key.
 230  230   */
 231  231  void
 232  232  dsl_deadlist_remove_key(dsl_deadlist_t *dl, uint64_t mintxg, dmu_tx_t *tx)
 233  233  {
 234  234          dsl_deadlist_entry_t dle_tofind;
↓ open down ↓ 8 lines elided ↑ open up ↑
 243  243          dle = avl_find(&dl->dl_tree, &dle_tofind, NULL);
 244  244          dle_prev = AVL_PREV(&dl->dl_tree, dle);
 245  245  
 246  246          bpobj_enqueue_subobj(&dle_prev->dle_bpobj,
 247  247              dle->dle_bpobj.bpo_object, tx);
 248  248  
 249  249          avl_remove(&dl->dl_tree, dle);
 250  250          bpobj_close(&dle->dle_bpobj);
 251  251          kmem_free(dle, sizeof (*dle));
 252  252  
 253      -        VERIFY3U(0, ==, zap_remove_int(dl->dl_os, dl->dl_object, mintxg, tx));
      253 +        VERIFY0(zap_remove_int(dl->dl_os, dl->dl_object, mintxg, tx));
 254  254  }
 255  255  
 256  256  /*
 257  257   * Walk ds's snapshots to regenerate generate ZAP & AVL.
 258  258   */
 259  259  static void
 260  260  dsl_deadlist_regenerate(objset_t *os, uint64_t dlobj,
 261  261      uint64_t mrs_obj, dmu_tx_t *tx)
 262  262  {
 263  263          dsl_deadlist_t dl;
 264  264          dsl_pool_t *dp = dmu_objset_pool(os);
 265  265  
 266  266          dsl_deadlist_open(&dl, os, dlobj);
 267  267          if (dl.dl_oldfmt) {
 268  268                  dsl_deadlist_close(&dl);
 269  269                  return;
 270  270          }
 271  271  
 272  272          while (mrs_obj != 0) {
 273  273                  dsl_dataset_t *ds;
 274      -                VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, mrs_obj, FTAG, &ds));
      274 +                VERIFY0(dsl_dataset_hold_obj(dp, mrs_obj, FTAG, &ds));
 275  275                  dsl_deadlist_add_key(&dl, ds->ds_phys->ds_prev_snap_txg, tx);
 276  276                  mrs_obj = ds->ds_phys->ds_prev_snap_obj;
 277  277                  dsl_dataset_rele(ds, FTAG);
 278  278          }
 279  279          dsl_deadlist_close(&dl);
 280  280  }
 281  281  
 282  282  uint64_t
 283  283  dsl_deadlist_clone(dsl_deadlist_t *dl, uint64_t maxtxg,
 284  284      uint64_t mrs_obj, dmu_tx_t *tx)
↓ open down ↓ 11 lines elided ↑ open up ↑
 296  296          dsl_deadlist_load_tree(dl);
 297  297  
 298  298          for (dle = avl_first(&dl->dl_tree); dle;
 299  299              dle = AVL_NEXT(&dl->dl_tree, dle)) {
 300  300                  uint64_t obj;
 301  301  
 302  302                  if (dle->dle_mintxg >= maxtxg)
 303  303                          break;
 304  304  
 305  305                  obj = bpobj_alloc(dl->dl_os, SPA_MAXBLOCKSIZE, tx);
 306      -                VERIFY3U(0, ==, zap_add_int_key(dl->dl_os, newobj,
      306 +                VERIFY0(zap_add_int_key(dl->dl_os, newobj,
 307  307                      dle->dle_mintxg, obj, tx));
 308  308          }
 309  309          return (newobj);
 310  310  }
 311  311  
 312  312  void
 313  313  dsl_deadlist_space(dsl_deadlist_t *dl,
 314  314      uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
 315  315  {
 316  316          if (dl->dl_oldfmt) {
 317      -                VERIFY3U(0, ==, bpobj_space(&dl->dl_bpobj,
      317 +                VERIFY0(bpobj_space(&dl->dl_bpobj,
 318  318                      usedp, compp, uncompp));
 319  319                  return;
 320  320          }
 321  321  
 322  322          mutex_enter(&dl->dl_lock);
 323  323          *usedp = dl->dl_phys->dl_used;
 324  324          *compp = dl->dl_phys->dl_comp;
 325  325          *uncompp = dl->dl_phys->dl_uncomp;
 326  326          mutex_exit(&dl->dl_lock);
 327  327  }
↓ open down ↓ 6 lines elided ↑ open up ↑
 334  334   */
 335  335  void
 336  336  dsl_deadlist_space_range(dsl_deadlist_t *dl, uint64_t mintxg, uint64_t maxtxg,
 337  337      uint64_t *usedp, uint64_t *compp, uint64_t *uncompp)
 338  338  {
 339  339          dsl_deadlist_entry_t *dle;
 340  340          dsl_deadlist_entry_t dle_tofind;
 341  341          avl_index_t where;
 342  342  
 343  343          if (dl->dl_oldfmt) {
 344      -                VERIFY3U(0, ==, bpobj_space_range(&dl->dl_bpobj,
      344 +                VERIFY0(bpobj_space_range(&dl->dl_bpobj,
 345  345                      mintxg, maxtxg, usedp, compp, uncompp));
 346  346                  return;
 347  347          }
 348  348  
 349  349          *usedp = *compp = *uncompp = 0;
 350  350  
 351  351          mutex_enter(&dl->dl_lock);
 352  352          dsl_deadlist_load_tree(dl);
 353  353          dle_tofind.dle_mintxg = mintxg;
 354  354          dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
↓ open down ↓ 1 lines elided ↑ open up ↑
 356  356           * If we don't find this mintxg, there shouldn't be anything
 357  357           * after it either.
 358  358           */
 359  359          ASSERT(dle != NULL ||
 360  360              avl_nearest(&dl->dl_tree, where, AVL_AFTER) == NULL);
 361  361  
 362  362          for (; dle && dle->dle_mintxg < maxtxg;
 363  363              dle = AVL_NEXT(&dl->dl_tree, dle)) {
 364  364                  uint64_t used, comp, uncomp;
 365  365  
 366      -                VERIFY3U(0, ==, bpobj_space(&dle->dle_bpobj,
      366 +                VERIFY0(bpobj_space(&dle->dle_bpobj,
 367  367                      &used, &comp, &uncomp));
 368  368  
 369  369                  *usedp += used;
 370  370                  *compp += comp;
 371  371                  *uncompp += uncomp;
 372  372          }
 373  373          mutex_exit(&dl->dl_lock);
 374  374  }
 375  375  
 376  376  static void
 377  377  dsl_deadlist_insert_bpobj(dsl_deadlist_t *dl, uint64_t obj, uint64_t birth,
 378  378      dmu_tx_t *tx)
 379  379  {
 380  380          dsl_deadlist_entry_t dle_tofind;
 381  381          dsl_deadlist_entry_t *dle;
 382  382          avl_index_t where;
 383  383          uint64_t used, comp, uncomp;
 384  384          bpobj_t bpo;
 385  385  
 386      -        VERIFY3U(0, ==, bpobj_open(&bpo, dl->dl_os, obj));
 387      -        VERIFY3U(0, ==, bpobj_space(&bpo, &used, &comp, &uncomp));
      386 +        VERIFY0(bpobj_open(&bpo, dl->dl_os, obj));
      387 +        VERIFY0(bpobj_space(&bpo, &used, &comp, &uncomp));
 388  388          bpobj_close(&bpo);
 389  389  
 390  390          dsl_deadlist_load_tree(dl);
 391  391  
 392  392          dmu_buf_will_dirty(dl->dl_dbuf, tx);
 393  393          mutex_enter(&dl->dl_lock);
 394  394          dl->dl_phys->dl_used += used;
 395  395          dl->dl_phys->dl_comp += comp;
 396  396          dl->dl_phys->dl_uncomp += uncomp;
 397  397          mutex_exit(&dl->dl_lock);
↓ open down ↓ 19 lines elided ↑ open up ↑
 417  417   */
 418  418  void
 419  419  dsl_deadlist_merge(dsl_deadlist_t *dl, uint64_t obj, dmu_tx_t *tx)
 420  420  {
 421  421          zap_cursor_t zc;
 422  422          zap_attribute_t za;
 423  423          dmu_buf_t *bonus;
 424  424          dsl_deadlist_phys_t *dlp;
 425  425          dmu_object_info_t doi;
 426  426  
 427      -        VERIFY3U(0, ==, dmu_object_info(dl->dl_os, obj, &doi));
      427 +        VERIFY0(dmu_object_info(dl->dl_os, obj, &doi));
 428  428          if (doi.doi_type == DMU_OT_BPOBJ) {
 429  429                  bpobj_t bpo;
 430      -                VERIFY3U(0, ==, bpobj_open(&bpo, dl->dl_os, obj));
 431      -                VERIFY3U(0, ==, bpobj_iterate(&bpo,
      430 +                VERIFY0(bpobj_open(&bpo, dl->dl_os, obj));
      431 +                VERIFY0(bpobj_iterate(&bpo,
 432  432                      dsl_deadlist_insert_cb, dl, tx));
 433  433                  bpobj_close(&bpo);
 434  434                  return;
 435  435          }
 436  436  
 437  437          for (zap_cursor_init(&zc, dl->dl_os, obj);
 438  438              zap_cursor_retrieve(&zc, &za) == 0;
 439  439              zap_cursor_advance(&zc)) {
 440  440                  uint64_t mintxg = strtonum(za.za_name, NULL);
 441  441                  dsl_deadlist_insert_bpobj(dl, za.za_first_integer, mintxg, tx);
 442      -                VERIFY3U(0, ==, zap_remove_int(dl->dl_os, obj, mintxg, tx));
      442 +                VERIFY0(zap_remove_int(dl->dl_os, obj, mintxg, tx));
 443  443          }
 444  444          zap_cursor_fini(&zc);
 445  445  
 446      -        VERIFY3U(0, ==, dmu_bonus_hold(dl->dl_os, obj, FTAG, &bonus));
      446 +        VERIFY0(dmu_bonus_hold(dl->dl_os, obj, FTAG, &bonus));
 447  447          dlp = bonus->db_data;
 448  448          dmu_buf_will_dirty(bonus, tx);
 449  449          bzero(dlp, sizeof (*dlp));
 450  450          dmu_buf_rele(bonus, FTAG);
 451  451  }
 452  452  
 453  453  /*
 454  454   * Remove entries on dl that are >= mintxg, and put them on the bpobj.
 455  455   */
 456  456  void
↓ open down ↓ 11 lines elided ↑ open up ↑
 468  468          dle_tofind.dle_mintxg = mintxg;
 469  469          dle = avl_find(&dl->dl_tree, &dle_tofind, &where);
 470  470          if (dle == NULL)
 471  471                  dle = avl_nearest(&dl->dl_tree, where, AVL_AFTER);
 472  472          while (dle) {
 473  473                  uint64_t used, comp, uncomp;
 474  474                  dsl_deadlist_entry_t *dle_next;
 475  475  
 476  476                  bpobj_enqueue_subobj(bpo, dle->dle_bpobj.bpo_object, tx);
 477  477  
 478      -                VERIFY3U(0, ==, bpobj_space(&dle->dle_bpobj,
      478 +                VERIFY0(bpobj_space(&dle->dle_bpobj,
 479  479                      &used, &comp, &uncomp));
 480  480                  mutex_enter(&dl->dl_lock);
 481  481                  ASSERT3U(dl->dl_phys->dl_used, >=, used);
 482  482                  ASSERT3U(dl->dl_phys->dl_comp, >=, comp);
 483  483                  ASSERT3U(dl->dl_phys->dl_uncomp, >=, uncomp);
 484  484                  dl->dl_phys->dl_used -= used;
 485  485                  dl->dl_phys->dl_comp -= comp;
 486  486                  dl->dl_phys->dl_uncomp -= uncomp;
 487  487                  mutex_exit(&dl->dl_lock);
 488  488  
 489      -                VERIFY3U(0, ==, zap_remove_int(dl->dl_os, dl->dl_object,
      489 +                VERIFY0(zap_remove_int(dl->dl_os, dl->dl_object,
 490  490                      dle->dle_mintxg, tx));
 491  491  
 492  492                  dle_next = AVL_NEXT(&dl->dl_tree, dle);
 493  493                  avl_remove(&dl->dl_tree, dle);
 494  494                  bpobj_close(&dle->dle_bpobj);
 495  495                  kmem_free(dle, sizeof (*dle));
 496  496                  dle = dle_next;
 497  497          }
 498  498  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX