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

Function arc_buf_destroy_impl

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

* Free up buf->b_data and pull the arc_buf_t off of the arc_buf_hdr_t's * list and free it. */

Source from the content-addressed store, hash-verified

3125 * list and free it.
3126 */
3127static void
3128arc_buf_destroy_impl(arc_buf_t *buf)
3129{
3130 arc_buf_hdr_t *hdr = buf->b_hdr;
3131
3132 /*
3133 * Free up the data associated with the buf but only if we're not
3134 * sharing this with the hdr. If we are sharing it with the hdr, the
3135 * hdr is responsible for doing the free.
3136 */
3137 if (buf->b_data != NULL) {
3138 /*
3139 * We're about to change the hdr's b_flags. We must either
3140 * hold the hash_lock or be undiscoverable.
3141 */
3142 ASSERT(HDR_EMPTY_OR_LOCKED(hdr));
3143
3144 arc_cksum_verify(buf);
3145 arc_buf_unwatch(buf);
3146
3147 if (arc_buf_is_shared(buf)) {
3148 arc_hdr_clear_flags(hdr, ARC_FLAG_SHARED_DATA);
3149 } else {
3150 uint64_t size = arc_buf_size(buf);
3151 arc_free_data_buf(hdr, buf->b_data, size, buf);
3152 ARCSTAT_INCR(arcstat_overhead_size, -size);
3153 }
3154 buf->b_data = NULL;
3155
3156 ASSERT(hdr->b_l1hdr.b_bufcnt > 0);
3157 hdr->b_l1hdr.b_bufcnt -= 1;
3158
3159 if (ARC_BUF_ENCRYPTED(buf)) {
3160 hdr->b_crypt_hdr.b_ebufcnt -= 1;
3161
3162 /*
3163 * If we have no more encrypted buffers and we've
3164 * already gotten a copy of the decrypted data we can
3165 * free b_rabd to save some space.
3166 */
3167 if (hdr->b_crypt_hdr.b_ebufcnt == 0 &&
3168 HDR_HAS_RABD(hdr) && hdr->b_l1hdr.b_pabd != NULL &&
3169 !HDR_IO_IN_PROGRESS(hdr)) {
3170 arc_hdr_free_abd(hdr, B_TRUE);
3171 }
3172 }
3173 }
3174
3175 arc_buf_t *lastbuf = arc_buf_remove(hdr, buf);
3176
3177 if (ARC_BUF_SHARED(buf) && !ARC_BUF_COMPRESSED(buf)) {
3178 /*
3179 * If the current arc_buf_t is sharing its data buffer with the
3180 * hdr, then reassign the hdr's b_pabd to share it with the new
3181 * buffer at the end of the list. The shared buffer is always
3182 * the last one on the hdr's buffer list.
3183 *
3184 * There is an equivalent case for compressed bufs, but since

Callers 4

arc_hdr_destroyFunction · 0.85
arc_buf_destroyFunction · 0.85
arc_evict_hdrFunction · 0.85
arc_readFunction · 0.85

Calls 13

arc_cksum_verifyFunction · 0.85
arc_buf_unwatchFunction · 0.85
arc_buf_is_sharedFunction · 0.85
arc_hdr_clear_flagsFunction · 0.85
arc_buf_sizeFunction · 0.85
arc_free_data_bufFunction · 0.85
arc_hdr_free_abdFunction · 0.85
arc_buf_removeFunction · 0.85
arc_share_bufFunction · 0.85
arc_hdr_get_compressFunction · 0.85
arc_cksum_freeFunction · 0.85

Tested by

no test coverage detected