MCPcopy Create free account
hub / github.com/F-Stack/f-stack / add_reference

Function add_reference

freebsd/contrib/openzfs/module/zfs/arc.c:2312–2341  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

2310 * it is not evictable.
2311 */
2312static void
2313add_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

Callers 1

arc_buf_alloc_implFunction · 0.85

Calls 6

zfs_refcount_is_zeroFunction · 0.85
zfs_refcount_addFunction · 0.85
multilist_removeFunction · 0.85
arc_buf_typeFunction · 0.85
arc_hdr_clear_flagsFunction · 0.85

Tested by

no test coverage detected