Lines Matching defs:bmp

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