Lines Matching refs:bmp
283 bitmap_t *bmp; in bmd_alloc() local
285 bmp = bitmap; in bmd_alloc()
286 for (i = 0; i < BMAP_MAX; bmp++, i++) in bmd_alloc()
287 if (!BMAP_IS_INUSE(bmp)) { in bmd_alloc()
288 BMAP_SET_FLAGS(bmp, BMAP_INUSE); in bmd_alloc()
304 bitmap_t *bmp; in bmd_free() local
306 bmp = bmd2bmp(bmd); in bmd_free()
307 if (bmp) in bmd_free()
308 BMAP_UNSET_FLAGS(bmp, BMAP_INUSE); in bmd_free()
368 bm_chunk_setup(bitmap_t *bmp, bmap_chunk_t *cp, u_quad_t bn) in bm_chunk_setup() argument
376 l = bmp->bm_len - off; in bm_chunk_setup()
385 if (BMAP_IS_INIT_ONES(bmp)) in bm_chunk_setup()
391 hp = &bmp->bm_hash[h]; in bm_chunk_setup()
407 bm_chunk_new(bitmap_t *bmp, u_quad_t bn) in bm_chunk_new() argument
420 (void) bm_chunk_setup(bmp, cp, bn); in bm_chunk_new()
421 bmp->bm_ccur++; in bm_chunk_new()
436 bm_chunk_alloc(bitmap_t *bmp, u_quad_t bn) in bm_chunk_alloc() argument
440 if (bmp->bm_ccur < bmp->bm_cmax) in bm_chunk_alloc()
441 cp = bm_chunk_new(bmp, bn); in bm_chunk_alloc()
492 bm_chunk_reposition(bitmap_t *bmp, bmap_list_t *hp, bmap_chunk_t *cp) in bm_chunk_reposition() argument
494 if (!bmp || !hp || !cp) in bm_chunk_reposition()
511 bm_chunk_find(bitmap_t *bmp, u_quad_t bn) in bm_chunk_find() argument
517 if (!bmp) in bm_chunk_find()
521 hp = &bmp->bm_hash[h]; in bm_chunk_find()
526 bm_chunk_reposition(bmp, hp, cp); in bm_chunk_find()
533 return (bm_chunk_alloc(bmp, bn)); in bm_chunk_find()
543 bmp_setval(bitmap_t *bmp, bm_iovec_t *vp) in bmp_setval() argument
553 if (bn >= bmp->bm_len || max > bmp->bm_len) in bmp_setval()
565 cp = bm_chunk_find(bmp, bn); in bmp_setval()
586 bmp_getval(bitmap_t *bmp, bm_iovec_t *vp) in bmp_getval() argument
598 if (bn >= bmp->bm_len || max > bmp->bm_len) in bmp_getval()
608 cp = bm_chunk_find(bmp, bn); in bmp_getval()
657 bitmap_t *bmp; in bm_alloc() local
666 bmp = bmd2bmp(bmd); in bm_alloc()
671 BMAP_SET_FLAGS(bmp, BMAP_BINIT_ONES); in bm_alloc()
673 BMAP_UNSET_FLAGS(bmp, BMAP_BINIT_ONES); in bm_alloc()
674 bmp->bm_len = len; in bm_alloc()
675 bmp->bm_ccur = 0; in bm_alloc()
676 bmp->bm_cmax = BMAP_CHUNK_MAX; in bm_alloc()
677 hash_init(bmp->bm_hash); in bm_alloc()
692 bitmap_t *bmp; in bm_free() local
694 bmp = bmd2bmp(bmd); in bm_free()
695 if (bmp && BMAP_IS_INUSE(bmp)) { in bm_free()
698 bm_chunks_free(bmp->bm_hash); in bm_free()
719 bitmap_t *bmp; in bm_getiov() local
723 else if (!(bmp = bmd2bmp(bmd))) in bm_getiov()
733 rv |= bmp_getval(bmp, vp); in bm_getiov()
752 bitmap_t *bmp; in bm_setiov() local
756 else if (!(bmp = bmd2bmp(bmd))) in bm_setiov()
766 rv |= bmp_setval(bmp, vp); in bm_setiov()
794 dbmp2bmd(dbitmap_t *bmp) in dbmp2bmd() argument
798 bmd = bmp - dbitmap; in dbmp2bmd()
815 dbitmap_t *bmp; in dbmd_alloc() local
817 bmp = dbitmap; in dbmd_alloc()
818 for (i = 0; i < BMAP_MAX; bmp++, i++) in dbmd_alloc()
819 if (!BMAP_IS_INUSE(bmp)) { in dbmd_alloc()
820 BMAP_SET_FLAGS(bmp, BMAP_INUSE); in dbmd_alloc()
837 dbitmap_t *bmp; in dbmd_free() local
839 bmp = bmd2dbmp(bmd); in dbmd_free()
840 if (bmp) in dbmd_free()
841 BMAP_UNSET_FLAGS(bmp, BMAP_INUSE); in dbmd_free()
880 dbmp_getlen(dbitmap_t *bmp) in dbmp_getlen() argument
882 return (bmp ? bmp->bm_len : 0LL); in dbmp_getlen()
914 dbm_chunk_seek(dbitmap_t *bmp, u_quad_t bn) in dbm_chunk_seek() argument
919 if (!bmp) in dbm_chunk_seek()
923 rv = (lseek(bmp->bm_fd, off, SEEK_SET) != off) ? -1 : 0; in dbm_chunk_seek()
936 dbm_chunk_flush(dbitmap_t *bmp, dbmap_chunk_t *cp) in dbm_chunk_flush() argument
941 if (!bmp || !cp) in dbm_chunk_flush()
943 else if (dbm_chunk_seek(bmp, cp->c_off) != 0) in dbm_chunk_flush()
945 else if (write(bmp->bm_fd, cp->c_bmp, cp->c_mlen) != cp->c_mlen) in dbm_chunk_flush()
967 dbm_chunk_load(dbitmap_t *bmp, dbmap_chunk_t *cp, u_quad_t bn, int new) in dbm_chunk_load() argument
975 l = bmp->bm_len - off; in dbm_chunk_load()
985 if (BMAP_IS_INIT_ONES(bmp)) in dbm_chunk_load()
990 if (dbm_chunk_seek(bmp, bn) != 0) in dbm_chunk_load()
992 else if (read(bmp->bm_fd, cp->c_bmp, ml) != ml) in dbm_chunk_load()
997 TAILQ_INSERT_TAIL(&bmp->bm_lru, cp, c_lru); in dbm_chunk_load()
999 hp = &bmp->bm_hash[h]; in dbm_chunk_load()
1017 dbm_chunk_new(dbitmap_t *bmp, u_quad_t bn) in dbm_chunk_new() argument
1028 } else if (!dbm_chunk_load(bmp, cp, bn, BMAP_NEW_CHUNK)) { in dbm_chunk_new()
1033 bmp->bm_ccur++; in dbm_chunk_new()
1049 dbm_chunk_alloc(dbitmap_t *bmp, u_quad_t bn) in dbm_chunk_alloc() argument
1055 if (bmp->bm_ccur < bmp->bm_cmax) in dbm_chunk_alloc()
1056 return (dbm_chunk_new(bmp, bn)); in dbm_chunk_alloc()
1060 cp = TAILQ_FIRST(&bmp->bm_lru); in dbm_chunk_alloc()
1062 (void) dbm_chunk_flush(bmp, cp); in dbm_chunk_alloc()
1064 TAILQ_REMOVE(&bmp->bm_lru, cp, c_lru); in dbm_chunk_alloc()
1066 hp = &bmp->bm_hash[h]; in dbm_chunk_alloc()
1068 return (dbm_chunk_load(bmp, cp, bn, BMAP_OLD_CHUNK)); in dbm_chunk_alloc()
1078 dbm_chunks_free(dbitmap_t *bmp) in dbm_chunks_free() argument
1083 if (!bmp) in dbm_chunks_free()
1086 headp = &bmp->bm_lru; in dbm_chunks_free()
1105 dbm_chunk_reposition(dbitmap_t *bmp, dbmap_list_t *hp, dbmap_chunk_t *cp) in dbm_chunk_reposition() argument
1107 if (bmp && hp && cp) { in dbm_chunk_reposition()
1108 TAILQ_REMOVE(&bmp->bm_lru, cp, c_lru); in dbm_chunk_reposition()
1109 TAILQ_INSERT_TAIL(&bmp->bm_lru, cp, c_lru); in dbm_chunk_reposition()
1126 dbm_chunk_find(dbitmap_t *bmp, u_quad_t bn) in dbm_chunk_find() argument
1132 if (!bmp) in dbm_chunk_find()
1136 hp = &bmp->bm_hash[h]; in dbm_chunk_find()
1141 dbm_chunk_reposition(bmp, hp, cp); in dbm_chunk_find()
1148 return (dbm_chunk_alloc(bmp, bn)); in dbm_chunk_find()
1159 dbmp_setval(dbitmap_t *bmp, bm_iovec_t *vp) in dbmp_setval() argument
1169 if (bn >= bmp->bm_len || max > bmp->bm_len) in dbmp_setval()
1181 cp = dbm_chunk_find(bmp, bn); in dbmp_setval()
1203 dbmp_getval(dbitmap_t *bmp, bm_iovec_t *vp) in dbmp_getval() argument
1215 if (bn >= bmp->bm_len || max > bmp->bm_len) in dbmp_getval()
1225 cp = dbm_chunk_find(bmp, bn); in dbmp_getval()
1252 dbyte_apply_ifset(dbitmap_t *bmp, u_quad_t off, uint_t b, int(*fp)(), in dbyte_apply_ifset() argument
1260 l = dbmp_getlen(bmp); in dbyte_apply_ifset()
1261 bmd = dbmp2bmd(bmp); in dbyte_apply_ifset()
1282 dbm_chunk_apply_ifset(dbitmap_t *bmp, dbmap_chunk_t *cp, int(*fp)(), in dbm_chunk_apply_ifset() argument
1296 rv = dbyte_apply_ifset(bmp, q, *bp, fp, arg); in dbm_chunk_apply_ifset()
1376 dbitmap_t *bmp; in dbm_alloc() local
1390 bmp = bmd2dbmp(bmd); in dbm_alloc()
1399 } else if (!(bmp->bm_fname = strdup(fname))) { in dbm_alloc()
1408 bmp->bm_fd = fd; in dbm_alloc()
1410 BMAP_SET_FLAGS(bmp, BMAP_BINIT_ONES); in dbm_alloc()
1412 BMAP_UNSET_FLAGS(bmp, BMAP_BINIT_ONES); in dbm_alloc()
1413 bmp->bm_len = len; in dbm_alloc()
1414 bmp->bm_ccur = 0; in dbm_alloc()
1415 bmp->bm_cmax = BMAP_CHUNK_MAX; in dbm_alloc()
1416 TAILQ_INIT(&bmp->bm_lru); in dbm_alloc()
1417 hash_init((bmap_list_t *)bmp->bm_hash); in dbm_alloc()
1433 dbitmap_t *bmp; in dbm_free() local
1435 bmp = bmd2dbmp(bmd); in dbm_free()
1436 if (bmp && BMAP_IS_INUSE(bmp)) { in dbm_free()
1439 dbm_chunks_free(bmp); in dbm_free()
1440 (void) close(bmp->bm_fd); in dbm_free()
1441 (void) unlink(bmp->bm_fname); in dbm_free()
1442 free(bmp->bm_fname); in dbm_free()
1460 dbitmap_t *bmp; in dbm_getlen() local
1462 bmp = bmd2dbmp(bmd); in dbm_getlen()
1463 return (dbmp_getlen(bmp)); in dbm_getlen()
1499 dbitmap_t *bmp; in dbm_getiov() local
1503 else if (!(bmp = bmd2dbmp(bmd))) in dbm_getiov()
1513 rv |= dbmp_getval(bmp, vp); in dbm_getiov()
1532 dbitmap_t *bmp; in dbm_setiov() local
1536 else if (!(bmp = bmd2dbmp(bmd))) in dbm_setiov()
1546 rv |= dbmp_setval(bmp, vp); in dbm_setiov()
1564 dbitmap_t *bmp; in dbm_apply_ifset() local
1567 bmp = bmd2dbmp(bmd); in dbm_apply_ifset()
1568 if (!bmp || !fp) in dbm_apply_ifset()
1572 for (q = 0; q < bmp->bm_len; q += BMAP_CHUNK_BITS) { in dbm_apply_ifset()
1573 cp = dbm_chunk_find(bmp, q); in dbm_apply_ifset()
1579 rv = dbm_chunk_apply_ifset(bmp, cp, fp, arg); in dbm_apply_ifset()