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

Function arc_buf_remove

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

* Remove an arc_buf_t from the hdr's buf list and return the last * arc_buf_t on the list. If no buffers remain on the list then return * NULL. */

Source from the content-addressed store, hash-verified

3085 * NULL.
3086 */
3087static arc_buf_t *
3088arc_buf_remove(arc_buf_hdr_t *hdr, arc_buf_t *buf)
3089{
3090 ASSERT(HDR_HAS_L1HDR(hdr));
3091 ASSERT(HDR_EMPTY_OR_LOCKED(hdr));
3092
3093 arc_buf_t **bufp = &hdr->b_l1hdr.b_buf;
3094 arc_buf_t *lastbuf = NULL;
3095
3096 /*
3097 * Remove the buf from the hdr list and locate the last
3098 * remaining buffer on the list.
3099 */
3100 while (*bufp != NULL) {
3101 if (*bufp == buf)
3102 *bufp = buf->b_next;
3103
3104 /*
3105 * If we've removed a buffer in the middle of
3106 * the list then update the lastbuf and update
3107 * bufp.
3108 */
3109 if (*bufp != NULL) {
3110 lastbuf = *bufp;
3111 bufp = &(*bufp)->b_next;
3112 }
3113 }
3114 buf->b_next = NULL;
3115 ASSERT3P(lastbuf, !=, buf);
3116 IMPLY(hdr->b_l1hdr.b_bufcnt > 0, lastbuf != NULL);
3117 IMPLY(hdr->b_l1hdr.b_bufcnt > 0, hdr->b_l1hdr.b_buf != NULL);
3118 IMPLY(lastbuf != NULL, ARC_BUF_LAST(lastbuf));
3119
3120 return (lastbuf);
3121}
3122
3123/*
3124 * Free up buf->b_data and pull the arc_buf_t off of the arc_buf_hdr_t's

Callers 2

arc_buf_destroy_implFunction · 0.85
arc_releaseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected