Lines Matching refs:cp

123 #define	BMAP_CSET_DIRTY(cp)	(cp)->c_flags |= BMAP_CDIRTY
130 #define BMAP_CIS_DIRTY(cp) ((cp)->c_flags & BMAP_CDIRTY)
319 bmp_set(bmap_chunk_t *cp, u_quad_t bn, uint_t *vp)
326 bn -= cp->c_off;
327 if (bn < cp->c_clen) {
329 ip = &cp->c_bmp[bn >> BMAP_BPW_SHIFT];
346 bmp_get(bmap_chunk_t *cp, u_quad_t bn)
351 bn -= cp->c_off;
352 if (bn < cp->c_clen) {
354 rv = (cp->c_bmp[bn >> BMAP_BPW_SHIFT] & bit) != 0;
368 bm_chunk_setup(bitmap_t *bmp, bmap_chunk_t *cp, u_quad_t bn)
386 (void) memset(cp->c_bmp, 0xff, ml);
388 (void) memset(cp->c_bmp, 0x00, ml);
393 TAILQ_INSERT_HEAD(hp, cp, c_hash);
394 cp->c_off = off;
395 cp->c_clen = cl;
396 cp->c_mlen = ml;
397 return (cp);
409 bmap_chunk_t *cp;
413 cp = ndmp_malloc(sizeof (bmap_chunk_t));
414 if (cp) {
415 cp->c_bmp = ndmp_malloc(sizeof (uint_t) * BMAP_CHUNK_WORDS);
416 if (!cp->c_bmp) {
417 free(cp);
418 cp = NULL;
420 (void) bm_chunk_setup(bmp, cp, bn);
425 return (cp);
438 bmap_chunk_t *cp;
441 cp = bm_chunk_new(bmp, bn);
443 cp = NULL;
445 return (cp);
457 bmap_chunk_t *cp;
463 cp = TAILQ_FIRST(hp);
464 TAILQ_REMOVE(hp, cp, c_hash);
465 free(cp->c_bmp);
466 free(cp);
492 bm_chunk_reposition(bitmap_t *bmp, bmap_list_t *hp, bmap_chunk_t *cp)
494 if (!bmp || !hp || !cp)
497 if (TAILQ_FIRST(hp) != cp) {
498 TAILQ_REMOVE(hp, cp, c_hash);
499 TAILQ_INSERT_HEAD(hp, cp, c_hash);
514 bmap_chunk_t *cp;
522 TAILQ_FOREACH(cp, hp, c_hash) {
523 if (bn >= cp->c_off && bn < (cp->c_off + cp->c_clen)) {
526 bm_chunk_reposition(bmp, hp, cp);
527 return (cp);
549 bmap_chunk_t *cp;
565 cp = bm_chunk_find(bmp, bn);
566 if (!cp)
569 for (cl = cp->c_off + cp->c_clen; bn < cl && bn < max; bn++) {
570 rv = bmp_set(cp, bn, vp->bmv_val);
594 bmap_chunk_t *cp;
608 cp = bm_chunk_find(bmp, bn);
609 if (!cp)
612 for (cl = cp->c_off + cp->c_clen; bn < cl && bn < max; bn++) {
613 rv = bmp_get(cp, bn);
852 dbmp_set(dbmap_chunk_t *cp, u_quad_t bn, uint_t *vp)
859 bn -= cp->c_off;
860 if (bn < cp->c_clen) {
862 ip = &cp->c_bmp[bn >> BMAP_BPW_SHIFT];
865 BMAP_CSET_DIRTY(cp);
892 dbmp_get(dbmap_chunk_t *cp, u_quad_t bn)
897 bn -= cp->c_off;
898 if (bn < cp->c_clen) {
900 rv = (cp->c_bmp[bn >> BMAP_BPW_SHIFT] & bit) != 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)
986 (void) memset(cp->c_bmp, 0xff, ml);
988 (void) memset(cp->c_bmp, 0x00, ml);
991 cp = NULL;
992 else if (read(bmp->bm_fd, cp->c_bmp, ml) != ml)
993 cp = NULL;
996 if (cp) {
997 TAILQ_INSERT_TAIL(&bmp->bm_lru, cp, c_lru);
1000 TAILQ_INSERT_HEAD(hp, cp, c_hash);
1001 cp->c_flags = 0;
1002 cp->c_off = off;
1003 cp->c_clen = cl;
1004 cp->c_mlen = ml;
1007 return (cp);
1019 dbmap_chunk_t *cp;
1022 cp = ndmp_malloc(sizeof (dbmap_chunk_t));
1023 if (cp) {
1024 cp->c_bmp = ndmp_malloc(sizeof (uint_t) * BMAP_CHUNK_WORDS);
1025 if (!cp->c_bmp) {
1026 free(cp);
1027 cp = NULL;
1028 } else if (!dbm_chunk_load(bmp, cp, bn, BMAP_NEW_CHUNK)) {
1029 free(cp->c_bmp);
1030 free(cp);
1031 cp = NULL;
1036 return (cp);
1053 dbmap_chunk_t *cp;
1060 cp = TAILQ_FIRST(&bmp->bm_lru);
1061 if (BMAP_CIS_DIRTY(cp))
1062 (void) dbm_chunk_flush(bmp, cp);
1064 TAILQ_REMOVE(&bmp->bm_lru, cp, c_lru);
1065 h = HASH(cp->c_off);
1067 TAILQ_REMOVE(hp, cp, c_hash);
1068 return (dbm_chunk_load(bmp, cp, bn, BMAP_OLD_CHUNK));
1081 dbmap_chunk_t *cp;
1091 cp = TAILQ_FIRST(headp);
1092 TAILQ_REMOVE(headp, cp, c_lru);
1093 free(cp->c_bmp);
1094 free(cp);
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);
1110 if (TAILQ_FIRST(hp) != cp) {
1111 TAILQ_REMOVE(hp, cp, c_hash);
1112 TAILQ_INSERT_HEAD(hp, cp, c_hash);
1129 dbmap_chunk_t *cp;
1137 TAILQ_FOREACH(cp, hp, c_hash) {
1138 if (bn >= cp->c_off && bn < (cp->c_off + cp->c_clen)) {
1141 dbm_chunk_reposition(bmp, hp, cp);
1142 return (cp);
1165 dbmap_chunk_t *cp;
1181 cp = dbm_chunk_find(bmp, bn);
1182 if (!cp)
1185 for (cl = cp->c_off + cp->c_clen; bn < cl && bn < max; bn++) {
1186 rv = dbmp_set(cp, bn, vp->bmv_val);
1211 dbmap_chunk_t *cp;
1225 cp = dbm_chunk_find(bmp, bn);
1226 if (!cp)
1229 for (cl = cp->c_off + cp->c_clen; bn < cl && bn < max; bn++) {
1230 rv = dbmp_get(cp, bn);
1282 dbm_chunk_apply_ifset(dbitmap_t *bmp, dbmap_chunk_t *cp, int(*fp)(),
1291 bp = cp->c_bmp;
1292 q = cp->c_off;
1293 m = cp->c_mlen / BMAP_WSIZE;
1565 dbmap_chunk_t *cp;
1573 cp = dbm_chunk_find(bmp, q);
1574 if (!cp) {
1579 rv = dbm_chunk_apply_ifset(bmp, cp, fp, arg);