Lines Matching refs:bp
103 BUFHEAD *bp; in __get_buf() local
111 bp = prev_bp->ovfl; in __get_buf()
112 if (!bp || (bp->addr != addr)) in __get_buf()
113 bp = NULL; in __get_buf()
125 bp = PTROF(segp[segment_ndx]); in __get_buf()
130 if (!bp) { in __get_buf()
131 bp = newbuf(hashp, addr, prev_bp); in __get_buf()
132 if (!bp || in __get_buf()
133 __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) in __get_buf()
137 (BUFHEAD *)((intptr_t)bp | is_disk_mask); in __get_buf()
139 BUF_REMOVE(bp); in __get_buf()
140 MRU_INSERT(bp); in __get_buf()
142 return (bp); in __get_buf()
154 BUFHEAD *bp; /* The buffer we're going to use */ in newbuf() local
162 bp = LRU; in newbuf()
165 if (bp == hashp->cpage) { in newbuf()
166 BUF_REMOVE(bp); in newbuf()
167 MRU_INSERT(bp); in newbuf()
168 bp = LRU; in newbuf()
172 if (hashp->nbufs == 0 && prev_bp && bp->ovfl) { in newbuf()
175 for (ovfl = bp->ovfl; ovfl ; ovfl = ovfl->ovfl) { in newbuf()
187 if (hashp->nbufs || (bp->flags & BUF_PIN) || bp == hashp->cpage) { in newbuf()
189 if ((bp = (BUFHEAD *)calloc(1, sizeof(BUFHEAD))) == NULL) in newbuf()
191 if ((bp->page = (char *)calloc(1, hashp->BSIZE)) == NULL) { in newbuf()
192 free(bp); in newbuf()
199 BUF_REMOVE(bp); in newbuf()
204 if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { in newbuf()
209 shortp = (u_int16_t *)bp->page; in newbuf()
212 if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, in newbuf()
213 bp->addr, (int)IS_BUCKET(bp->flags), 0)) in newbuf()
223 if (IS_BUCKET(bp->flags)) { in newbuf()
224 segment_ndx = bp->addr & (hashp->SGSIZE - 1); in newbuf()
225 segp = hashp->dir[bp->addr >> hashp->SSHIFT]; in newbuf()
231 ((bp->flags & BUF_MOD) || in newbuf()
242 for (xbp = bp; xbp->ovfl;) { in newbuf()
268 bp->addr = addr; in newbuf()
271 bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); in newbuf()
273 bp->ovfl = NULL; in newbuf()
282 (bp ? bp->addr : 0)); in newbuf()
284 prev_bp->ovfl = bp; in newbuf()
285 bp->flags = 0; in newbuf()
287 bp->flags = BUF_BUCKET; in newbuf()
288 MRU_INSERT(bp); in newbuf()
289 return (bp); in newbuf()
318 BUFHEAD *bp; in __buf_free() local
323 for (bp = LRU; bp != &hashp->bufhead;) { in __buf_free()
325 if (bp->addr || IS_BUCKET(bp->flags)) { in __buf_free()
326 if (to_disk && (bp->flags & BUF_MOD) && in __buf_free()
327 __put_page(hashp, bp->page, in __buf_free()
328 bp->addr, IS_BUCKET(bp->flags), 0)) in __buf_free()
333 if (bp->page) { in __buf_free()
334 (void)memset(bp->page, 0, hashp->BSIZE); in __buf_free()
335 free(bp->page); in __buf_free()
337 BUF_REMOVE(bp); in __buf_free()
338 free(bp); in __buf_free()
339 bp = LRU; in __buf_free()
341 bp = bp->prev; in __buf_free()
347 __reclaim_buf(HTAB *hashp, BUFHEAD *bp) in __reclaim_buf() argument
349 bp->ovfl = NULL; in __reclaim_buf()
350 bp->addr = 0; in __reclaim_buf()
351 bp->flags = 0; in __reclaim_buf()
352 BUF_REMOVE(bp); in __reclaim_buf()
353 LRU_INSERT(bp); in __reclaim_buf()