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/space_map.c
          +++ new/usr/src/uts/common/fs/zfs/space_map.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  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 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
       24 + *
  24   25   */
  25   26  
       27 +/*
       28 + * Copyright (c) 2012 by Delphix. All rights reserved.
       29 + */
       30 +
  26   31  #include <sys/zfs_context.h>
  27   32  #include <sys/spa.h>
  28   33  #include <sys/dmu.h>
  29   34  #include <sys/zio.h>
  30   35  #include <sys/space_map.h>
  31   36  
  32   37  /*
  33   38   * Space map routines.
  34   39   * NOTE: caller is responsible for all locking.
  35   40   */
↓ open down ↓ 30 lines elided ↑ open up ↑
  66   71          sm->sm_start = start;
  67   72          sm->sm_size = size;
  68   73          sm->sm_shift = shift;
  69   74          sm->sm_lock = lp;
  70   75  }
  71   76  
  72   77  void
  73   78  space_map_destroy(space_map_t *sm)
  74   79  {
  75   80          ASSERT(!sm->sm_loaded && !sm->sm_loading);
  76      -        VERIFY3U(sm->sm_space, ==, 0);
       81 +        VERIFY0(sm->sm_space);
  77   82          avl_destroy(&sm->sm_root);
  78   83          cv_destroy(&sm->sm_load_cv);
  79   84  }
  80   85  
  81   86  void
  82   87  space_map_add(space_map_t *sm, uint64_t start, uint64_t size)
  83   88  {
  84   89          avl_index_t where;
  85   90          space_seg_t ssearch, *ss_before, *ss_after, *ss;
  86   91          uint64_t end = start + size;
↓ open down ↓ 192 lines elided ↑ open up ↑
 279  284  
 280  285          ASSERT(MUTEX_HELD(sm->sm_lock));
 281  286          ASSERT(!sm->sm_loaded);
 282  287          ASSERT(!sm->sm_loading);
 283  288  
 284  289          sm->sm_loading = B_TRUE;
 285  290          end = smo->smo_objsize;
 286  291          space = smo->smo_alloc;
 287  292  
 288  293          ASSERT(sm->sm_ops == NULL);
 289      -        VERIFY3U(sm->sm_space, ==, 0);
      294 +        VERIFY0(sm->sm_space);
 290  295  
 291  296          if (maptype == SM_FREE) {
 292  297                  space_map_add(sm, sm->sm_start, sm->sm_size);
 293  298                  space = sm->sm_size - space;
 294  299          }
 295  300  
 296  301          bufsize = 1ULL << SPACE_MAP_BLOCKSHIFT;
 297  302          entry_map = zio_buf_alloc(bufsize);
 298  303  
 299  304          mutex_exit(sm->sm_lock);
↓ open down ↓ 168 lines elided ↑ open up ↑
 468  473                  size = (entry - entry_map) * sizeof (uint64_t);
 469  474                  mutex_exit(sm->sm_lock);
 470  475                  dmu_write(os, smo->smo_object, smo->smo_objsize,
 471  476                      size, entry_map, tx);
 472  477                  mutex_enter(sm->sm_lock);
 473  478                  smo->smo_objsize += size;
 474  479          }
 475  480  
 476  481          zio_buf_free(entry_map, bufsize);
 477  482  
 478      -        VERIFY3U(sm->sm_space, ==, 0);
      483 +        VERIFY0(sm->sm_space);
 479  484  }
 480  485  
 481  486  void
 482  487  space_map_truncate(space_map_obj_t *smo, objset_t *os, dmu_tx_t *tx)
 483  488  {
 484  489          VERIFY(dmu_free_range(os, smo->smo_object, 0, -1ULL, tx) == 0);
 485  490  
 486  491          smo->smo_objsize = 0;
 487  492          smo->smo_alloc = 0;
 488  493  }
↓ open down ↓ 128 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX