Lines Matching refs:bp
105 struct ubuf *bp, *nbp;
125 bp = LIST_FIRST(&bufhash[i]);
126 while(bp) {
127 nbp = LIST_NEXT(bp, b_hash);
128 LIST_REMOVE(bp, b_hash);
129 bp->b_hashval = vl_hash(bp->b_vp, bp->b_lblkno);
130 LIST_INSERT_HEAD(&np[bp->b_hashval], bp, b_hash);
131 bp = nbp;
156 buf_destroy(struct ubuf * bp)
158 LIST_REMOVE(bp, b_vnbufs);
159 LIST_REMOVE(bp, b_hash);
160 if (!(bp->b_flags & B_DONTFREE))
161 free(bp->b_data);
162 free(bp);
168 bremfree(struct ubuf * bp)
177 if (bp->b_flags & B_LOCKED) {
178 locked_queue_bytes -= bp->b_bcount;
181 if (TAILQ_NEXT(bp, b_freelist) == NULL) {
183 if (TAILQ_LAST(dp, bqueues) == bp)
188 ++bp->b_vp->v_usecount;
189 TAILQ_REMOVE(dp, bp, b_freelist);
196 struct ubuf *bp;
202 LIST_FOREACH(bp, &bufhash[hash], b_hash) {
206 if (bp->b_vp == vp && bp->b_lblkno == lbn) {
207 return bp;
220 struct ubuf *bp;
230 if ((bp = incore(vp, lbn)) != NULL) {
231 assert(!(bp->b_flags & B_BUSY));
232 bp->b_flags |= B_BUSY;
233 bremfree(bp);
234 if (bp->b_bcount == size)
235 return bp;
236 else if (bp->b_bcount > size) {
237 assert(!(bp->b_flags & B_DELWRI));
238 bp->b_bcount = size;
239 bp->b_data = erealloc(bp->b_data, size);
240 return bp;
243 buf_destroy(bp);
244 bp = NULL;
254 bp = TAILQ_FIRST(&bufqueues[BQ_AGE]);
255 if (bp)
256 TAILQ_REMOVE(&bufqueues[BQ_AGE], bp, b_freelist);
257 if (bp == NULL) {
258 bp = TAILQ_FIRST(&bufqueues[BQ_LRU]);
259 if (bp)
260 TAILQ_REMOVE(&bufqueues[BQ_LRU], bp,
263 if (bp) {
264 if (bp->b_flags & B_DELWRI)
265 VOP_STRATEGY(bp);
266 buf_destroy(bp);
278 bp = ecalloc(1, sizeof(*bp));
279 bp->b_data = ecalloc(1, size);
280 bp->b_vp = vp;
281 bp->b_blkno = bp->b_lblkno = lbn;
282 bp->b_bcount = size;
283 bp->b_hashval = vl_hash(vp, lbn);
284 LIST_INSERT_HEAD(&bufhash[bp->b_hashval], bp, b_hash);
285 LIST_INSERT_HEAD(&vp->v_cleanblkhd, bp, b_vnbufs);
286 bp->b_flags = B_BUSY;
288 return bp;
293 bwrite(struct ubuf * bp)
295 bp->b_flags &= ~(B_READ | B_DONE | B_DELWRI | B_LOCKED);
296 VOP_STRATEGY(bp);
297 bp->b_flags |= B_DONE;
298 reassignbuf(bp, bp->b_vp);
299 brelse(bp, 0);
304 brelse(struct ubuf * bp, int set)
308 assert(bp->b_flags & B_BUSY);
310 bp->b_flags |= set;
312 age = bp->b_flags & B_AGE;
313 bp->b_flags &= ~(B_BUSY | B_AGE);
314 if (bp->b_flags & B_INVAL) {
315 buf_destroy(bp);
318 if (bp->b_flags & B_LOCKED) {
319 locked_queue_bytes += bp->b_bcount;
321 TAILQ_INSERT_TAIL(&bufqueues[BQ_LOCKED], bp, b_freelist);
323 TAILQ_INSERT_TAIL(&bufqueues[BQ_AGE], bp, b_freelist);
325 TAILQ_INSERT_TAIL(&bufqueues[BQ_LRU], bp, b_freelist);
327 --bp->b_vp->v_usecount;
330 if (LIST_FIRST(&bufhash[bp->b_hashval]) != bp) {
331 LIST_REMOVE(bp, b_hash);
332 LIST_INSERT_HEAD(&bufhash[bp->b_hashval], bp, b_hash);
340 struct ubuf *bp;
343 bp = getblk(vp, lbn, size);
344 *bpp = bp;
345 if (bp->b_flags & (B_DELWRI | B_DONE)) {
357 bp->b_blkno = daddr;
359 bp->b_flags |= B_READ;
360 return VOP_STRATEGY(bp);
362 memset(bp->b_data, 0, bp->b_bcount);
368 reassignbuf(struct ubuf * bp, struct uvnode * vp)
370 LIST_REMOVE(bp, b_vnbufs);
371 if (bp->b_flags & B_DELWRI) {
372 LIST_INSERT_HEAD(&vp->v_dirtyblkhd, bp, b_vnbufs);
374 LIST_INSERT_HEAD(&vp->v_cleanblkhd, bp, b_vnbufs);
382 struct ubuf *bp;
387 TAILQ_FOREACH(bp, &bufqueues[i], b_freelist) {
389 bp->b_vp, bp->b_lblkno, bp->b_flags);