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/arc.c
          +++ new/usr/src/uts/common/fs/zfs/arc.c
↓ open down ↓ 1002 lines elided ↑ open up ↑
1003 1003              (ab->b_state != arc_anon)) {
1004 1004                  uint64_t delta = ab->b_size * ab->b_datacnt;
1005 1005                  list_t *list = &ab->b_state->arcs_list[ab->b_type];
1006 1006                  uint64_t *size = &ab->b_state->arcs_lsize[ab->b_type];
1007 1007  
1008 1008                  ASSERT(!MUTEX_HELD(&ab->b_state->arcs_mtx));
1009 1009                  mutex_enter(&ab->b_state->arcs_mtx);
1010 1010                  ASSERT(list_link_active(&ab->b_arc_node));
1011 1011                  list_remove(list, ab);
1012 1012                  if (GHOST_STATE(ab->b_state)) {
1013      -                        ASSERT3U(ab->b_datacnt, ==, 0);
     1013 +                        ASSERT0(ab->b_datacnt);
1014 1014                          ASSERT3P(ab->b_buf, ==, NULL);
1015 1015                          delta = ab->b_size;
1016 1016                  }
1017 1017                  ASSERT(delta > 0);
1018 1018                  ASSERT3U(*size, >=, delta);
1019 1019                  atomic_add_64(size, -delta);
1020 1020                  mutex_exit(&ab->b_state->arcs_mtx);
1021 1021                  /* remove the prefetch flag if we get a reference */
1022 1022                  if (ab->b_flags & ARC_PREFETCH)
1023 1023                          ab->b_flags &= ~ARC_PREFETCH;
↓ open down ↓ 606 lines elided ↑ open up ↑
1630 1630                          skipped++;
1631 1631                          continue;
1632 1632                  }
1633 1633                  /* "lookahead" for better eviction candidate */
1634 1634                  if (recycle && ab->b_size != bytes &&
1635 1635                      ab_prev && ab_prev->b_size == bytes)
1636 1636                          continue;
1637 1637                  hash_lock = HDR_LOCK(ab);
1638 1638                  have_lock = MUTEX_HELD(hash_lock);
1639 1639                  if (have_lock || mutex_tryenter(hash_lock)) {
1640      -                        ASSERT3U(refcount_count(&ab->b_refcnt), ==, 0);
     1640 +                        ASSERT0(refcount_count(&ab->b_refcnt));
1641 1641                          ASSERT(ab->b_datacnt > 0);
1642 1642                          while (ab->b_buf) {
1643 1643                                  arc_buf_t *buf = ab->b_buf;
1644 1644                                  if (!mutex_tryenter(&buf->b_evict_lock)) {
1645 1645                                          missed += 1;
1646 1646                                          break;
1647 1647                                  }
1648 1648                                  if (buf->b_data) {
1649 1649                                          bytes_evicted += ab->b_size;
1650 1650                                          if (recycle && ab->b_type == type &&
↓ open down ↓ 807 lines elided ↑ open up ↑
2458 2458                   * This buffer has been accessed more than once but has
2459 2459                   * been evicted from the cache.  Move it back to the
2460 2460                   * MFU state.
2461 2461                   */
2462 2462  
2463 2463                  if (buf->b_flags & ARC_PREFETCH) {
2464 2464                          /*
2465 2465                           * This is a prefetch access...
2466 2466                           * move this block back to the MRU state.
2467 2467                           */
2468      -                        ASSERT3U(refcount_count(&buf->b_refcnt), ==, 0);
     2468 +                        ASSERT0(refcount_count(&buf->b_refcnt));
2469 2469                          new_state = arc_mru;
2470 2470                  }
2471 2471  
2472 2472                  buf->b_arc_access = ddi_get_lbolt();
2473 2473                  DTRACE_PROBE1(new_state__mfu, arc_buf_hdr_t *, buf);
2474 2474                  arc_change_state(new_state, buf, hash_lock);
2475 2475  
2476 2476                  ARCSTAT_BUMP(arcstat_mfu_ghost_hits);
2477 2477          } else if (buf->b_state == arc_l2c_only) {
2478 2478                  /*
↓ open down ↓ 320 lines elided ↑ open up ↑
2799 2799                                  hdr->b_flags |= ARC_PREFETCH;
2800 2800                          }
2801 2801                          if (*arc_flags & ARC_L2CACHE)
2802 2802                                  hdr->b_flags |= ARC_L2CACHE;
2803 2803                          if (BP_GET_LEVEL(bp) > 0)
2804 2804                                  hdr->b_flags |= ARC_INDIRECT;
2805 2805                  } else {
2806 2806                          /* this block is in the ghost cache */
2807 2807                          ASSERT(GHOST_STATE(hdr->b_state));
2808 2808                          ASSERT(!HDR_IO_IN_PROGRESS(hdr));
2809      -                        ASSERT3U(refcount_count(&hdr->b_refcnt), ==, 0);
     2809 +                        ASSERT0(refcount_count(&hdr->b_refcnt));
2810 2810                          ASSERT(hdr->b_buf == NULL);
2811 2811  
2812 2812                          /* if this is a prefetch, we don't have a reference */
2813 2813                          if (*arc_flags & ARC_PREFETCH)
2814 2814                                  hdr->b_flags |= ARC_PREFETCH;
2815 2815                          else
2816 2816                                  add_reference(hdr, hash_lock, private);
2817 2817                          if (*arc_flags & ARC_L2CACHE)
2818 2818                                  hdr->b_flags |= ARC_L2CACHE;
2819 2819                          buf = kmem_cache_alloc(buf_cache, KM_PUSHPAGE);
↓ open down ↓ 1553 lines elided ↑ open up ↑
4373 4373                  }
4374 4374  
4375 4375                  mutex_exit(list_lock);
4376 4376  
4377 4377                  if (full == B_TRUE)
4378 4378                          break;
4379 4379          }
4380 4380          mutex_exit(&l2arc_buflist_mtx);
4381 4381  
4382 4382          if (pio == NULL) {
4383      -                ASSERT3U(write_sz, ==, 0);
     4383 +                ASSERT0(write_sz);
4384 4384                  kmem_cache_free(hdr_cache, head);
4385 4385                  return (0);
4386 4386          }
4387 4387  
4388 4388          ASSERT3U(write_sz, <=, target_sz);
4389 4389          ARCSTAT_BUMP(arcstat_l2_writes_sent);
4390 4390          ARCSTAT_INCR(arcstat_l2_write_bytes, write_sz);
4391 4391          ARCSTAT_INCR(arcstat_l2_size, write_sz);
4392 4392          vdev_space_update(dev->l2ad_vdev, write_sz, 0, 0);
4393 4393  
↓ open down ↓ 282 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX