Lines Matching refs:bp

50 makebusy(ml_unit_t *ul, buf_t *bp)  in makebusy()  argument
52 sema_p(&bp->b_sem); in makebusy()
53 if ((bp->b_flags & B_ERROR) == 0) in makebusy()
55 if (bp->b_flags & B_READ) in makebusy()
62 logdone(buf_t *bp) in logdone() argument
64 bp->b_flags |= B_DONE; in logdone()
66 if (bp->b_flags & B_WRITE) in logdone()
67 sema_v(&bp->b_sem); in logdone()
70 sema_v(&bp->b_io); in logdone()
79 buf_t *bp; in ldl_strategy_done() local
102 bp = sv->sv_bp; in ldl_strategy_done()
104 bp->b_flags |= B_ERROR; in ldl_strategy_done()
108 biodone(bp); in ldl_strategy_done()
239 writelog(ml_unit_t *ul, buf_t *bp) in writelog() argument
241 ASSERT(SEMA_HELD(&bp->b_sem)); in writelog()
248 bp->b_flags = B_WRITE; in writelog()
249 bp->b_edev = ul->un_dev; in writelog()
250 bp->b_iodone = logdone; in writelog()
256 bp->b_flags |= B_ERROR; in writelog()
257 bp->b_error = EIO; in writelog()
258 biodone(bp); in writelog()
262 ldl_strategy(ul, bp); in writelog()
266 readlog(ml_unit_t *ul, buf_t *bp) in readlog() argument
268 ASSERT(SEMA_HELD(&bp->b_sem)); in readlog()
269 ASSERT(bp->b_bcount); in readlog()
271 bp->b_flags = B_READ; in readlog()
272 bp->b_edev = ul->un_dev; in readlog()
273 bp->b_iodone = logdone; in readlog()
277 bp->b_flags |= B_ERROR; in readlog()
278 bp->b_error = EIO; in readlog()
279 biodone(bp); in readlog()
280 (void) trans_wait(bp); in readlog()
284 ldl_strategy(ul, bp); in readlog()
286 if (trans_wait(bp)) in readlog()
297 push_dirty_bp(ml_unit_t *ul, buf_t *bp) in push_dirty_bp() argument
302 ASSERT(bp == cb->cb_bp && bp == cb->cb_dirty); in push_dirty_bp()
303 ASSERT((bp->b_bcount & (DEV_BSIZE-1)) == 0); in push_dirty_bp()
308 writelog(ul, bp); in push_dirty_bp()
318 if (bp->b_bcount == bp->b_bufsize) in push_dirty_bp()
336 newbp->b_bufsize = bp->b_bufsize - bp->b_bcount; in push_dirty_bp()
337 newbp->b_un.b_addr = bp->b_un.b_addr + bp->b_bcount; in push_dirty_bp()
338 bp->b_bufsize = bp->b_bcount; in push_dirty_bp()
344 newbp->b_forw = bp->b_forw; in push_dirty_bp()
345 newbp->b_back = bp; in push_dirty_bp()
346 bp->b_forw->b_back = newbp; in push_dirty_bp()
347 bp->b_forw = newbp; in push_dirty_bp()
354 buf_t *bp; in inval_range() local
363 bp = cb->cb_bp; in inval_range()
365 if (bp == cb->cb_dirty || bp->b_bcount == 0) { in inval_range()
366 bp = bp->b_forw; in inval_range()
369 buflof = dbtob(bp->b_blkno); in inval_range()
370 bufelof = buflof + bp->b_bcount; in inval_range()
373 bp = bp->b_forw; in inval_range()
376 makebusy(ul, bp); in inval_range()
377 bp->b_flags = 0; in inval_range()
378 bp->b_bcount = 0; in inval_range()
379 sema_v(&bp->b_sem); in inval_range()
380 bp = bp->b_forw; in inval_range()
381 } while (bp != cb->cb_bp); in inval_range()
395 buf_t *bp; in get_write_bp() local
400 if ((bp = cb->cb_dirty) != NULL) { in get_write_bp()
401 makebusy(ul, bp); in get_write_bp()
402 return (bp); in get_write_bp()
414 bp = cb->cb_bp->b_forw; in get_write_bp()
415 makebusy(ul, bp); in get_write_bp()
417 cb->cb_dirty = bp; in get_write_bp()
418 cb->cb_bp = bp; in get_write_bp()
420 bp->b_flags = 0; in get_write_bp()
421 bp->b_bcount = 0; in get_write_bp()
422 bp->b_blkno = btodb(ul->un_tail_lof); in get_write_bp()
423 ASSERT(dbtob(bp->b_blkno) == ul->un_tail_lof); in get_write_bp()
432 return (bp); in get_write_bp()
439 buf_t *bp; in alloc_wrbuf() local
456 bp = kmem_zalloc(sizeof (buf_t), KM_SLEEP); in alloc_wrbuf()
457 sema_init(&bp->b_sem, 1, NULL, SEMA_DEFAULT, NULL); in alloc_wrbuf()
458 sema_init(&bp->b_io, 0, NULL, SEMA_DEFAULT, NULL); in alloc_wrbuf()
459 bp->b_offset = -1; in alloc_wrbuf()
460 bp->b_forw = cb->cb_free; in alloc_wrbuf()
461 cb->cb_free = bp; in alloc_wrbuf()
470 bp = cb->cb_free; in alloc_wrbuf()
471 cb->cb_free = bp->b_forw; in alloc_wrbuf()
473 bp->b_forw = bp; in alloc_wrbuf()
474 bp->b_back = bp; in alloc_wrbuf()
475 cb->cb_bp = bp; in alloc_wrbuf()
476 bp->b_un.b_addr = cb->cb_va; in alloc_wrbuf()
477 bp->b_bufsize = cb->cb_nb; in alloc_wrbuf()
487 buf_t *bp; in alloc_rdbuf() local
512 bp = kmem_alloc(sizeof (buf_t), KM_SLEEP); in alloc_rdbuf()
513 bzero(bp, sizeof (buf_t)); in alloc_rdbuf()
514 sema_init(&bp->b_sem, 1, NULL, SEMA_DEFAULT, NULL); in alloc_rdbuf()
515 sema_init(&bp->b_io, 0, NULL, SEMA_DEFAULT, NULL); in alloc_rdbuf()
516 bp->b_un.b_addr = va; in alloc_rdbuf()
517 bp->b_bufsize = nb; in alloc_rdbuf()
519 bp->b_forw = cb->cb_bp->b_forw; in alloc_rdbuf()
520 bp->b_back = cb->cb_bp; in alloc_rdbuf()
521 cb->cb_bp->b_forw->b_back = bp; in alloc_rdbuf()
522 cb->cb_bp->b_forw = bp; in alloc_rdbuf()
524 bp->b_forw = bp->b_back = bp; in alloc_rdbuf()
525 cb->cb_bp = bp; in alloc_rdbuf()
536 buf_t *bp; in free_cirbuf() local
547 while ((bp = cb->cb_bp) != NULL) { in free_cirbuf()
548 if (bp == bp->b_forw) in free_cirbuf()
551 cb->cb_bp = bp->b_forw; in free_cirbuf()
552 bp->b_back->b_forw = bp->b_forw; in free_cirbuf()
553 bp->b_forw->b_back = bp->b_back; in free_cirbuf()
554 sema_destroy(&bp->b_sem); in free_cirbuf()
555 sema_destroy(&bp->b_io); in free_cirbuf()
556 kmem_free(bp, sizeof (buf_t)); in free_cirbuf()
562 while ((bp = cb->cb_free) != NULL) { in free_cirbuf()
563 cb->cb_free = bp->b_forw; in free_cirbuf()
564 sema_destroy(&bp->b_sem); in free_cirbuf()
565 sema_destroy(&bp->b_io); in free_cirbuf()
566 kmem_free(bp, sizeof (buf_t)); in free_cirbuf()
586 buf_t *bp; in find_bp() local
592 bp = cb->cb_bp; in find_bp()
594 if (bp->b_bcount && in find_bp()
595 within_range(lof, bp->b_blkno, bp->b_bcount)) { in find_bp()
596 makebusy(ul, bp); in find_bp()
598 return (bp); in find_bp()
600 bp = bp->b_forw; in find_bp()
601 } while (bp != cb->cb_bp); in find_bp()
610 buf_t *bp, *bpend; in find_read_lof() local
620 bpend = bp = cb->cb_bp->b_forw; in find_read_lof()
623 if (bp->b_bcount) { in find_read_lof()
624 rlof = dbtob(bp->b_blkno); in find_read_lof()
627 bp = bp->b_forw; in find_read_lof()
628 } while (bp != bpend); in find_read_lof()
643 buf_t *bp; in get_read_bp() local
649 if ((bp = find_bp(ul, &ul->un_wrbuf, lof)) != NULL) { in get_read_bp()
651 return (bp); in get_read_bp()
653 if ((bp = find_bp(ul, &ul->un_rdbuf, lof)) != NULL) { in get_read_bp()
655 return (bp); in get_read_bp()
663 bp = cb->cb_bp->b_forw; in get_read_bp()
664 makebusy(ul, bp); in get_read_bp()
665 bp->b_flags = 0; in get_read_bp()
666 bp->b_bcount = 0; in get_read_bp()
667 cb->cb_bp = bp; in get_read_bp()
673 bp->b_blkno = btodb(lof); in get_read_bp()
674 lof = dbtob(bp->b_blkno); in get_read_bp()
676 bp->b_bcount = MIN(bp->b_bufsize, rlof - lof); in get_read_bp()
677 readlog(ul, bp); in get_read_bp()
678 return (bp); in get_read_bp()
688 extend_write_bp(ml_unit_t *ul, cirbuf_t *cb, buf_t *bp) in extend_write_bp() argument
690 buf_t *bpforw = bp->b_forw; in extend_write_bp()
692 ASSERT(bp == cb->cb_bp && bp == cb->cb_dirty); in extend_write_bp()
697 if (bpforw == bp) in extend_write_bp()
703 if ((bp->b_un.b_addr + bp->b_bufsize) != bpforw->b_un.b_addr) in extend_write_bp()
711 sema_v(&bp->b_sem); in extend_write_bp()
726 bp->b_forw = bpforw->b_forw; in extend_write_bp()
727 bpforw->b_forw->b_back = bp; in extend_write_bp()
728 bp->b_bufsize += bpforw->b_bufsize; in extend_write_bp()
732 makebusy(ul, bp); in extend_write_bp()
739 storebuf(ml_unit_t *ul, buf_t *bp, caddr_t va, size_t nb) in storebuf() argument
748 nb_in_sec = NB_LEFT_IN_SECTOR(bp->b_bcount); in storebuf()
753 bcopy(va, bp->b_un.b_addr + bp->b_bcount, copy_nb); in storebuf()
754 bp->b_bcount += copy_nb; in storebuf()
760 st = (sect_trailer_t *)(bp->b_un.b_addr + bp->b_bcount); in storebuf()
764 bp->b_bcount += sizeof (sect_trailer_t); in storebuf()
771 push_dirty_bp(ul, bp); in storebuf()
777 if (bp->b_bcount == bp->b_bufsize) { in storebuf()
778 if (!extend_write_bp(ul, cb, bp)) { in storebuf()
779 push_dirty_bp(ul, bp); in storebuf()
787 sema_v(&bp->b_sem); in storebuf()
817 buf_t *bp, in fetchbuf() argument
827 ulong_t src_nb = bp->b_bcount; in fetchbuf()
828 off_t src_lof = dbtob(bp->b_blkno); in fetchbuf()
830 caddr_t src_va = bp->b_un.b_addr; in fetchbuf()
874 sema_v(&bp->b_sem); in fetchbuf()
885 sema_v(&bp->b_sem); in fetchbuf()
894 buf_t *bp; in ldl_round_commit() local
902 if ((bp = cb->cb_dirty) == NULL) in ldl_round_commit()
904 makebusy(ul, bp); in ldl_round_commit()
910 bcount = P2ROUNDUP(bp->b_bcount, DEV_BSIZE); in ldl_round_commit()
911 if (bcount == bp->b_bcount) { in ldl_round_commit()
912 sema_v(&bp->b_sem); in ldl_round_commit()
915 bp->b_bcount = bcount; in ldl_round_commit()
916 ul->un_tail_lof = dbtob(bp->b_blkno) + bcount; in ldl_round_commit()
929 ((bp->b_un.b_addr + bcount) - sizeof (*st)); in ldl_round_commit()
937 if (wrapped || bcount == bp->b_bufsize) in ldl_round_commit()
938 push_dirty_bp(ul, bp); in ldl_round_commit()
940 sema_v(&bp->b_sem); in ldl_round_commit()
946 buf_t *bp; in ldl_push_commit() local
952 if ((bp = cb->cb_dirty) == NULL) in ldl_push_commit()
954 makebusy(ul, bp); in ldl_push_commit()
955 push_dirty_bp(ul, bp); in ldl_push_commit()
997 buf_t *bp; in ldl_write() local
1008 bp = get_write_bp(ul); in ldl_write()
1012 sema_v(&bp->b_sem); in ldl_write()
1015 actual = storebuf(ul, bp, va, nb); in ldl_write()
1020 bp = get_write_bp(ul); in ldl_write()
1041 bp = get_write_bp(ul); in ldl_write()
1048 sema_v(&bp->b_sem); in ldl_write()
1051 actual = storebuf(ul, bp, va, nb); in ldl_write()
1056 bp = get_write_bp(ul); in ldl_write()
1063 buf_t *bp; in ldl_waito() local
1070 bp = cb->cb_bp; in ldl_waito()
1072 if ((bp->b_flags & B_DONE) == 0) { in ldl_waito()
1073 makebusy(ul, bp); in ldl_waito()
1074 sema_v(&bp->b_sem); in ldl_waito()
1076 bp = bp->b_forw; in ldl_waito()
1077 } while (bp != cb->cb_bp); in ldl_waito()
1087 buf_t *bp; in logseek() local
1091 bp = get_read_bp(ul, lof); in logseek()
1092 if (bp->b_flags & B_ERROR) { in logseek()
1093 sema_v(&bp->b_sem); in logseek()
1096 actual = fetchbuf(ul, bp, NULL, nb, &lof); in logseek()
1113 buf_t *bp; in ldl_read() local
1175 bp = get_read_bp(ul, lof); in ldl_read()
1176 if (bp->b_flags & B_ERROR) { in ldl_read()
1177 sema_v(&bp->b_sem); in ldl_read()
1181 (bp != ul->un_wrbuf.cb_dirty)); in ldl_read()
1182 actual = fetchbuf(ul, bp, rva, rnb, &lof); in ldl_read()
1195 buf_t *bp = ul->un_bp; in ldl_savestate() local
1196 ml_odunit_t *ud = (void *)bp->b_un.b_addr; in ldl_savestate()
1197 ml_odunit_t *ud2 = (void *)(bp->b_un.b_addr + DEV_BSIZE); in ldl_savestate()
1214 UFS_BWRITE2(ul->un_ufsvfs, bp); in ldl_savestate()
1216 BWRITE2(bp); in ldl_savestate()
1218 error = bp->b_flags & B_ERROR; in ldl_savestate()
1381 ldl_logscan_ident(ml_unit_t *ul, buf_t *bp, off_t lof) in ldl_logscan_ident() argument
1391 if (bp->b_blkno >= btodb(ul->un_head_lof)) { in ldl_logscan_ident()
1392 ident += (bp->b_blkno - btodb(ul->un_head_lof)); in ldl_logscan_ident()
1395 ident += (bp->b_blkno - btodb(ul->un_bol_lof)); in ldl_logscan_ident()
1400 nblk = btodb(bp->b_bcount); in ldl_logscan_ident()
1401 bp->b_bcount = 0; in ldl_logscan_ident()
1403 st = (sect_trailer_t *)(bp->b_un.b_addr + LDL_USABLE_BSIZE); in ldl_logscan_ident()
1414 bp->b_bcount += DEV_BSIZE; in ldl_logscan_ident()
1419 return (within_range(lof, bp->b_blkno, bp->b_bcount)); in ldl_logscan_ident()
1440 buf_t *bp; in ldl_logscan_read() local
1461 bp = get_read_bp(ul, *lofp); in ldl_logscan_read()
1462 if (bp->b_flags & B_ERROR) { in ldl_logscan_read()
1463 sema_v(&bp->b_sem); in ldl_logscan_read()
1470 if (!ldl_logscan_ident(ul, bp, *lofp)) { in ldl_logscan_read()
1471 sema_v(&bp->b_sem); in ldl_logscan_read()
1477 actual = fetchbuf(ul, bp, va, nb, lofp); in ldl_logscan_read()