Print this page
3741 zfs needs better comments
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Alan Somers <alans@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>

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 ↓ 246 lines elided ↑ open up ↑
 247  247          kstat_named_t arcstat_prefetch_data_hits;
 248  248          kstat_named_t arcstat_prefetch_data_misses;
 249  249          kstat_named_t arcstat_prefetch_metadata_hits;
 250  250          kstat_named_t arcstat_prefetch_metadata_misses;
 251  251          kstat_named_t arcstat_mru_hits;
 252  252          kstat_named_t arcstat_mru_ghost_hits;
 253  253          kstat_named_t arcstat_mfu_hits;
 254  254          kstat_named_t arcstat_mfu_ghost_hits;
 255  255          kstat_named_t arcstat_deleted;
 256  256          kstat_named_t arcstat_recycle_miss;
      257 +        /*
      258 +         * Number of buffers that could not be evicted because the hash lock
      259 +         * was held by another thread.  The lock may not necessarily be held
      260 +         * by something using the same buffer, since hash locks are shared
      261 +         * by multiple buffers.
      262 +         */
 257  263          kstat_named_t arcstat_mutex_miss;
      264 +        /*
      265 +         * Number of buffers skipped because they have I/O in progress, are
      266 +         * indrect prefetch buffers that have not lived long enough, or are
      267 +         * not from the spa we're trying to evict from.
      268 +         */
 258  269          kstat_named_t arcstat_evict_skip;
 259  270          kstat_named_t arcstat_evict_l2_cached;
 260  271          kstat_named_t arcstat_evict_l2_eligible;
 261  272          kstat_named_t arcstat_evict_l2_ineligible;
 262  273          kstat_named_t arcstat_hash_elements;
 263  274          kstat_named_t arcstat_hash_elements_max;
 264  275          kstat_named_t arcstat_hash_collisions;
 265  276          kstat_named_t arcstat_hash_chains;
 266  277          kstat_named_t arcstat_hash_chain_max;
 267  278          kstat_named_t arcstat_p;
↓ open down ↓ 2678 lines elided ↑ open up ↑
2946 2957                          /*
2947 2958                           * Lock out device removal.
2948 2959                           */
2949 2960                          if (vdev_is_dead(vd) ||
2950 2961                              !spa_config_tryenter(spa, SCL_L2ARC, vd, RW_READER))
2951 2962                                  vd = NULL;
2952 2963                  }
2953 2964  
2954 2965                  mutex_exit(hash_lock);
2955 2966  
     2967 +                /*
     2968 +                 * At this point, we have a level 1 cache miss.  Try again in
     2969 +                 * L2ARC if possible.
     2970 +                 */
2956 2971                  ASSERT3U(hdr->b_size, ==, size);
2957 2972                  DTRACE_PROBE4(arc__miss, arc_buf_hdr_t *, hdr, blkptr_t *, bp,
2958 2973                      uint64_t, size, zbookmark_t *, zb);
2959 2974                  ARCSTAT_BUMP(arcstat_misses);
2960 2975                  ARCSTAT_CONDSTAT(!(hdr->b_flags & ARC_PREFETCH),
2961 2976                      demand, prefetch, hdr->b_type != ARC_BUFC_METADATA,
2962 2977                      data, metadata, misses);
2963 2978  
2964 2979                  if (vd != NULL && l2arc_ndev != 0 && !(l2arc_norw && devw)) {
2965 2980                          /*
↓ open down ↓ 170 lines elided ↑ open up ↑
3136 3151          VERIFY(buf->b_efunc(buf) == 0);
3137 3152          buf->b_efunc = NULL;
3138 3153          buf->b_private = NULL;
3139 3154          buf->b_hdr = NULL;
3140 3155          buf->b_next = NULL;
3141 3156          kmem_cache_free(buf_cache, buf);
3142 3157          return (1);
3143 3158  }
3144 3159  
3145 3160  /*
3146      - * Release this buffer from the cache.  This must be done
3147      - * after a read and prior to modifying the buffer contents.
     3161 + * Release this buffer from the cache, making it an anonymous buffer.  This
     3162 + * must be done after a read and prior to modifying the buffer contents.
3148 3163   * If the buffer has more than one reference, we must make
3149 3164   * a new hdr for the buffer.
3150 3165   */
3151 3166  void
3152 3167  arc_release(arc_buf_t *buf, void *tag)
3153 3168  {
3154 3169          arc_buf_hdr_t *hdr;
3155 3170          kmutex_t *hash_lock = NULL;
3156 3171          l2arc_buf_hdr_t *l2hdr;
3157 3172          uint64_t buf_size;
↓ open down ↓ 1626 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX