Lines Matching refs:bcp

173 	bcache_t *bcp = cdrarg;  in bcache_dblk_constructor()  local
178 dbp->db_base = kmem_cache_alloc(bcp->buffer_cache, kmflags); in bcache_dblk_constructor()
185 dbp->db_cache = (void *)bcp; in bcache_dblk_constructor()
186 dbp->db_lim = dbp->db_base + bcp->size; in bcache_dblk_constructor()
220 bcache_t *bcp = cdrarg; in bcache_dblk_destructor() local
222 kmem_cache_free(bcp->buffer_cache, dbp->db_base); in bcache_dblk_destructor()
667 bcache_t *bcp = dbp->db_cache; in bcache_dblk_lastfree() local
682 mutex_enter(&bcp->mutex); in bcache_dblk_lastfree()
683 kmem_cache_free(bcp->dblk_cache, dbp); in bcache_dblk_lastfree()
684 bcp->alloc--; in bcache_dblk_lastfree()
686 if (bcp->alloc == 0 && bcp->destroy != 0) { in bcache_dblk_lastfree()
687 kmem_cache_destroy(bcp->dblk_cache); in bcache_dblk_lastfree()
688 kmem_cache_destroy(bcp->buffer_cache); in bcache_dblk_lastfree()
689 mutex_exit(&bcp->mutex); in bcache_dblk_lastfree()
690 mutex_destroy(&bcp->mutex); in bcache_dblk_lastfree()
691 kmem_free(bcp, sizeof (bcache_t)); in bcache_dblk_lastfree()
693 mutex_exit(&bcp->mutex); in bcache_dblk_lastfree()
700 bcache_t *bcp; in bcache_create() local
705 if ((bcp = kmem_alloc(sizeof (bcache_t), KM_NOSLEEP)) == NULL) in bcache_create()
708 bcp->size = size; in bcache_create()
709 bcp->align = align; in bcache_create()
710 bcp->alloc = 0; in bcache_create()
711 bcp->destroy = 0; in bcache_create()
713 mutex_init(&bcp->mutex, NULL, MUTEX_DRIVER, NULL); in bcache_create()
716 bcp->buffer_cache = kmem_cache_create(buffer, size, align, NULL, NULL, in bcache_create()
719 bcp->dblk_cache = kmem_cache_create(buffer, sizeof (dblk_t), in bcache_create()
721 NULL, (void *)bcp, NULL, 0); in bcache_create()
723 return (bcp); in bcache_create()
727 bcache_destroy(bcache_t *bcp) in bcache_destroy() argument
729 ASSERT(bcp != NULL); in bcache_destroy()
731 mutex_enter(&bcp->mutex); in bcache_destroy()
732 if (bcp->alloc == 0) { in bcache_destroy()
733 kmem_cache_destroy(bcp->dblk_cache); in bcache_destroy()
734 kmem_cache_destroy(bcp->buffer_cache); in bcache_destroy()
735 mutex_exit(&bcp->mutex); in bcache_destroy()
736 mutex_destroy(&bcp->mutex); in bcache_destroy()
737 kmem_free(bcp, sizeof (bcache_t)); in bcache_destroy()
739 bcp->destroy++; in bcache_destroy()
740 mutex_exit(&bcp->mutex); in bcache_destroy()
746 bcache_allocb(bcache_t *bcp, uint_t pri) in bcache_allocb() argument
751 ASSERT(bcp != NULL); in bcache_allocb()
753 mutex_enter(&bcp->mutex); in bcache_allocb()
754 if (bcp->destroy != 0) { in bcache_allocb()
755 mutex_exit(&bcp->mutex); in bcache_allocb()
759 if ((dbp = kmem_cache_alloc(bcp->dblk_cache, KM_NOSLEEP)) == NULL) { in bcache_allocb()
760 mutex_exit(&bcp->mutex); in bcache_allocb()
763 bcp->alloc++; in bcache_allocb()
764 mutex_exit(&bcp->mutex); in bcache_allocb()
766 ASSERT(((uintptr_t)(dbp->db_base) & (bcp->align - 1)) == 0); in bcache_allocb()
774 STR_FTALLOC(&dbp->db_fthdr, FTEV_BCALLOCB, bcp->size); in bcache_allocb()