* Add a reference to this hdr indicating that someone is actively * referencing that memory. When the refcount transitions from 0 to 1, * we remove it from the respective arc_state_t list to indicate that * it is not evictable. */
| 2310 | * it is not evictable. |
| 2311 | */ |
| 2312 | static void |
| 2313 | add_reference(arc_buf_hdr_t *hdr, void *tag) |
| 2314 | { |
| 2315 | arc_state_t *state; |
| 2316 | |
| 2317 | ASSERT(HDR_HAS_L1HDR(hdr)); |
| 2318 | if (!HDR_EMPTY(hdr) && !MUTEX_HELD(HDR_LOCK(hdr))) { |
| 2319 | ASSERT(hdr->b_l1hdr.b_state == arc_anon); |
| 2320 | ASSERT(zfs_refcount_is_zero(&hdr->b_l1hdr.b_refcnt)); |
| 2321 | ASSERT3P(hdr->b_l1hdr.b_buf, ==, NULL); |
| 2322 | } |
| 2323 | |
| 2324 | state = hdr->b_l1hdr.b_state; |
| 2325 | |
| 2326 | if ((zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, tag) == 1) && |
| 2327 | (state != arc_anon)) { |
| 2328 | /* We don't use the L2-only state list. */ |
| 2329 | if (state != arc_l2c_only) { |
| 2330 | multilist_remove(state->arcs_list[arc_buf_type(hdr)], |
| 2331 | hdr); |
| 2332 | arc_evictable_space_decrement(hdr, state); |
| 2333 | } |
| 2334 | /* remove the prefetch flag if we get a reference */ |
| 2335 | if (HDR_HAS_L2HDR(hdr)) |
| 2336 | l2arc_hdr_arcstats_decrement_state(hdr); |
| 2337 | arc_hdr_clear_flags(hdr, ARC_FLAG_PREFETCH); |
| 2338 | if (HDR_HAS_L2HDR(hdr)) |
| 2339 | l2arc_hdr_arcstats_increment_state(hdr); |
| 2340 | } |
| 2341 | } |
| 2342 | |
| 2343 | /* |
| 2344 | * Remove a reference from this hdr. When the reference transitions from |
no test coverage detected