Lines Matching refs:bp
106 BUFHEAD *bp; in __get_buf() local
114 bp = prev_bp->ovfl; in __get_buf()
115 if (!bp || (bp->addr != addr)) in __get_buf()
116 bp = NULL; in __get_buf()
128 bp = PTROF(segp[segment_ndx]); in __get_buf()
133 if (!bp) { in __get_buf()
134 bp = newbuf(hashp, addr, prev_bp); in __get_buf()
135 if (!bp || in __get_buf()
136 __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) in __get_buf()
140 (BUFHEAD *)((intptr_t)bp | is_disk_mask); in __get_buf()
142 BUF_REMOVE(bp); in __get_buf()
143 MRU_INSERT(bp); in __get_buf()
145 return (bp); in __get_buf()
157 BUFHEAD *bp; /* The buffer we're going to use */ in newbuf() local
165 bp = LRU; in newbuf()
168 if (bp == hashp->cpage) { in newbuf()
169 BUF_REMOVE(bp); in newbuf()
170 MRU_INSERT(bp); in newbuf()
171 bp = LRU; in newbuf()
175 if (hashp->nbufs == 0 && prev_bp && bp->ovfl) { in newbuf()
178 for (ovfl = bp->ovfl; ovfl ; ovfl = ovfl->ovfl) { in newbuf()
190 if (hashp->nbufs || (bp->flags & BUF_PIN) || bp == hashp->cpage) { in newbuf()
192 if ((bp = (BUFHEAD *)calloc(1, sizeof(BUFHEAD))) == NULL) in newbuf()
194 if ((bp->page = (char *)calloc(1, hashp->BSIZE)) == NULL) { in newbuf()
195 free(bp); in newbuf()
202 BUF_REMOVE(bp); in newbuf()
207 if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { in newbuf()
212 shortp = (u_int16_t *)bp->page; in newbuf()
215 if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, in newbuf()
216 bp->addr, (int)IS_BUCKET(bp->flags), 0)) in newbuf()
226 if (IS_BUCKET(bp->flags)) { in newbuf()
227 segment_ndx = bp->addr & (hashp->SGSIZE - 1); in newbuf()
228 segp = hashp->dir[bp->addr >> hashp->SSHIFT]; in newbuf()
234 ((bp->flags & BUF_MOD) || in newbuf()
245 for (xbp = bp; xbp->ovfl;) { in newbuf()
271 bp->addr = addr; in newbuf()
274 bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); in newbuf()
276 bp->ovfl = NULL; in newbuf()
285 (bp ? bp->addr : 0)); in newbuf()
287 prev_bp->ovfl = bp; in newbuf()
288 bp->flags = 0; in newbuf()
290 bp->flags = BUF_BUCKET; in newbuf()
291 MRU_INSERT(bp); in newbuf()
292 return (bp); in newbuf()
321 BUFHEAD *bp; in __buf_free() local
326 for (bp = LRU; bp != &hashp->bufhead;) { in __buf_free()
328 if (bp->addr || IS_BUCKET(bp->flags)) { in __buf_free()
329 if (to_disk && (bp->flags & BUF_MOD) && in __buf_free()
330 __put_page(hashp, bp->page, in __buf_free()
331 bp->addr, IS_BUCKET(bp->flags), 0)) in __buf_free()
336 if (bp->page) { in __buf_free()
337 (void)memset(bp->page, 0, hashp->BSIZE); in __buf_free()
338 free(bp->page); in __buf_free()
340 BUF_REMOVE(bp); in __buf_free()
341 free(bp); in __buf_free()
342 bp = LRU; in __buf_free()
344 bp = bp->prev; in __buf_free()
350 __reclaim_buf(HTAB *hashp, BUFHEAD *bp) in __reclaim_buf() argument
352 bp->ovfl = NULL; in __reclaim_buf()
353 bp->addr = 0; in __reclaim_buf()
354 bp->flags = 0; in __reclaim_buf()
355 BUF_REMOVE(bp); in __reclaim_buf()
356 LRU_INSERT(bp); in __reclaim_buf()