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

Function arc_share_buf

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

* Share the arc_buf_t's data with the hdr. Whenever we are sharing the * data buffer, we transfer the refcount ownership to the hdr and update * the appropriate kstats. */

Source from the content-addressed store, hash-verified

3021 * the appropriate kstats.
3022 */
3023static void
3024arc_share_buf(arc_buf_hdr_t *hdr, arc_buf_t *buf)
3025{
3026 ASSERT(arc_can_share(hdr, buf));
3027 ASSERT3P(hdr->b_l1hdr.b_pabd, ==, NULL);
3028 ASSERT(!ARC_BUF_ENCRYPTED(buf));
3029 ASSERT(HDR_EMPTY_OR_LOCKED(hdr));
3030
3031 /*
3032 * Start sharing the data buffer. We transfer the
3033 * refcount ownership to the hdr since it always owns
3034 * the refcount whenever an arc_buf_t is shared.
3035 */
3036 zfs_refcount_transfer_ownership_many(&hdr->b_l1hdr.b_state->arcs_size,
3037 arc_hdr_size(hdr), buf, hdr);
3038 hdr->b_l1hdr.b_pabd = abd_get_from_buf(buf->b_data, arc_buf_size(buf));
3039 abd_take_ownership_of_buf(hdr->b_l1hdr.b_pabd,
3040 HDR_ISTYPE_METADATA(hdr));
3041 arc_hdr_set_flags(hdr, ARC_FLAG_SHARED_DATA);
3042 buf->b_flags |= ARC_BUF_FLAG_SHARED;
3043
3044 /*
3045 * Since we've transferred ownership to the hdr we need
3046 * to increment its compressed and uncompressed kstats and
3047 * decrement the overhead size.
3048 */
3049 ARCSTAT_INCR(arcstat_compressed_size, arc_hdr_size(hdr));
3050 ARCSTAT_INCR(arcstat_uncompressed_size, HDR_GET_LSIZE(hdr));
3051 ARCSTAT_INCR(arcstat_overhead_size, -arc_buf_size(buf));
3052}
3053
3054static void
3055arc_unshare_buf(arc_buf_hdr_t *hdr, arc_buf_t *buf)

Callers 4

arc_buf_destroy_implFunction · 0.85
arc_alloc_compressed_bufFunction · 0.85
arc_releaseFunction · 0.85
arc_write_readyFunction · 0.85

Calls 7

arc_can_shareFunction · 0.85
arc_hdr_sizeFunction · 0.85
abd_get_from_bufFunction · 0.85
arc_buf_sizeFunction · 0.85
arc_hdr_set_flagsFunction · 0.85

Tested by

no test coverage detected