* 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. */
| 3021 | * the appropriate kstats. |
| 3022 | */ |
| 3023 | static void |
| 3024 | arc_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 | |
| 3054 | static void |
| 3055 | arc_unshare_buf(arc_buf_hdr_t *hdr, arc_buf_t *buf) |
no test coverage detected