|
Lines 464-470
g_uncompress_taste(struct g_class *mp, struct g_pr
Link Here
|
| 464 |
struct g_provider *pp2; |
464 |
struct g_provider *pp2; |
| 465 |
struct g_consumer *cp; |
465 |
struct g_consumer *cp; |
| 466 |
struct g_geom *gp; |
466 |
struct g_geom *gp; |
| 467 |
uint32_t i, total_offsets, type; |
467 |
uint64_t *offsets; |
|
|
468 |
uint32_t i, r, total, total_offsets, type; |
| 468 |
uint8_t *buf; |
469 |
uint8_t *buf; |
| 469 |
int error; |
470 |
int error; |
| 470 |
|
471 |
|
|
Lines 499-506
g_uncompress_taste(struct g_class *mp, struct g_pr
Link Here
|
| 499 |
*/ |
500 |
*/ |
| 500 |
DPRINTF(("%s: media sectorsize %u, mediasize %jd\n", |
501 |
DPRINTF(("%s: media sectorsize %u, mediasize %jd\n", |
| 501 |
gp->name, pp->sectorsize, (intmax_t)pp->mediasize)); |
502 |
gp->name, pp->sectorsize, (intmax_t)pp->mediasize)); |
| 502 |
i = roundup(sizeof(struct cloop_header), pp->sectorsize); |
503 |
total = roundup(sizeof(struct cloop_header), pp->sectorsize); |
| 503 |
buf = g_read_data(cp, 0, i, NULL); |
504 |
buf = g_read_data(cp, 0, total, NULL); |
| 504 |
if (buf == NULL) |
505 |
if (buf == NULL) |
| 505 |
goto err; |
506 |
goto err; |
| 506 |
header = (struct cloop_header *) buf; |
507 |
header = (struct cloop_header *) buf; |
|
Lines 557-576
g_uncompress_taste(struct g_class *mp, struct g_pr
Link Here
|
| 557 |
gp->name, sc->nblocks); |
558 |
gp->name, sc->nblocks); |
| 558 |
goto err; |
559 |
goto err; |
| 559 |
} |
560 |
} |
| 560 |
free(buf, M_GEOM); |
561 |
g_free(buf); |
| 561 |
|
562 |
|
| 562 |
i = roundup((sizeof(struct cloop_header) + |
563 |
sc->offsets = malloc(total_offsets * sizeof(uint64_t), |
|
|
564 |
M_GEOM_UNCOMPRESS, M_WAITOK | M_ZERO); |
| 565 |
total = roundup((sizeof(struct cloop_header) + |
| 563 |
total_offsets * sizeof(uint64_t)), pp->sectorsize); |
566 |
total_offsets * sizeof(uint64_t)), pp->sectorsize); |
| 564 |
buf = g_read_data(cp, 0, i, NULL); |
567 |
#define RSZ ((total - r) > MAXPHYS ? MAXPHYS: (total - r)) |
| 565 |
if (buf == NULL) |
568 |
for (r = 0, i = 0; r < total; r += MAXPHYS) { |
| 566 |
goto err; |
569 |
buf = g_read_data(cp, r, RSZ, &error); |
| 567 |
sc->offsets = malloc(total_offsets * sizeof(uint64_t), |
570 |
if (buf == NULL) { |
| 568 |
M_GEOM_UNCOMPRESS, M_WAITOK); |
571 |
free(sc->offsets, M_GEOM_UNCOMPRESS); |
| 569 |
for (i = 0; i <= total_offsets; i++) { |
572 |
goto err; |
| 570 |
sc->offsets[i] = be64toh(((uint64_t *) |
573 |
} |
| 571 |
(buf+sizeof(struct cloop_header)))[i]); |
574 |
offsets = (uint64_t *)buf; |
|
|
575 |
if (r == 0) |
| 576 |
offsets += |
| 577 |
sizeof(struct cloop_header) / sizeof(uint64_t); |
| 578 |
for (; i < total_offsets && offsets < (uint64_t *)(buf + RSZ); |
| 579 |
i++, offsets++) |
| 580 |
sc->offsets[i] = be64toh(*offsets); |
| 581 |
g_free(buf); |
| 572 |
} |
582 |
} |
| 573 |
free(buf, M_GEOM); |
583 |
#undef RSZ |
| 574 |
buf = NULL; |
584 |
buf = NULL; |
| 575 |
DPRINTF(("%s: done reading offsets\n", gp->name)); |
585 |
DPRINTF(("%s: done reading offsets\n", gp->name)); |
| 576 |
mtx_init(&sc->last_mtx, "geom_uncompress cache", NULL, MTX_DEF); |
586 |
mtx_init(&sc->last_mtx, "geom_uncompress cache", NULL, MTX_DEF); |
|
Lines 619-625
err:
Link Here
|
| 619 |
g_topology_lock(); |
629 |
g_topology_lock(); |
| 620 |
g_access(cp, -1, 0, 0); |
630 |
g_access(cp, -1, 0, 0); |
| 621 |
if (buf != NULL) |
631 |
if (buf != NULL) |
| 622 |
free(buf, M_GEOM); |
632 |
g_free(buf); |
| 623 |
if (gp->softc != NULL) { |
633 |
if (gp->softc != NULL) { |
| 624 |
g_uncompress_softc_free(gp->softc, NULL); |
634 |
g_uncompress_softc_free(gp->softc, NULL); |
| 625 |
gp->softc = NULL; |
635 |
gp->softc = NULL; |