Changeset View
Changeset View
Standalone View
Standalone View
head/sys/geom/virstor/g_virstor.c
Show First 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Initialise GEOM class (per-class callback) | * Initialise GEOM class (per-class callback) | ||||
*/ | */ | ||||
static void | static void | ||||
g_virstor_init(struct g_class *mp __unused) | g_virstor_init(struct g_class *mp __unused) | ||||
{ | { | ||||
/* Catch map struct size mismatch at compile time; Map entries must | /* Catch map struct size mismatch at compile time; Map entries must | ||||
* fit into MAXPHYS exactly, with no wasted space. */ | * fit into maxphys exactly, with no wasted space. */ | ||||
CTASSERT(VIRSTOR_MAP_BLOCK_ENTRIES*VIRSTOR_MAP_ENTRY_SIZE == MAXPHYS); | MPASS(VIRSTOR_MAP_BLOCK_ENTRIES * VIRSTOR_MAP_ENTRY_SIZE == maxphys); | ||||
/* Init UMA zones, TAILQ's, other global vars */ | /* Init UMA zones, TAILQ's, other global vars */ | ||||
} | } | ||||
/* | /* | ||||
* Finalise GEOM class (per-class callback) | * Finalise GEOM class (per-class callback) | ||||
*/ | */ | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 1,079 Lines • ▼ Show 20 Lines | virstor_check_and_run(struct g_virstor_softc *sc) | ||||
/* Read in the allocation map */ | /* Read in the allocation map */ | ||||
LOG_MSG(LVL_DEBUG, "Reading map for %s from %s", sc->geom->name, | LOG_MSG(LVL_DEBUG, "Reading map for %s from %s", sc->geom->name, | ||||
sc->components[0].gcons->provider->name); | sc->components[0].gcons->provider->name); | ||||
off = count = n = 0; | off = count = n = 0; | ||||
while (count < sc->map_size) { | while (count < sc->map_size) { | ||||
struct g_virstor_map_entry *mapbuf; | struct g_virstor_map_entry *mapbuf; | ||||
size_t bs; | size_t bs; | ||||
bs = MIN(MAXPHYS, sc->map_size - count); | bs = MIN(maxphys, sc->map_size - count); | ||||
if (bs % sc->sectorsize != 0) { | if (bs % sc->sectorsize != 0) { | ||||
/* Check for alignment errors */ | /* Check for alignment errors */ | ||||
bs = rounddown(bs, sc->sectorsize); | bs = rounddown(bs, sc->sectorsize); | ||||
if (bs == 0) | if (bs == 0) | ||||
break; | break; | ||||
LOG_MSG(LVL_ERROR, "Trouble: map is not sector-aligned " | LOG_MSG(LVL_ERROR, "Trouble: map is not sector-aligned " | ||||
"for %s on %s", sc->geom->name, | "for %s on %s", sc->geom->name, | ||||
sc->components[0].gcons->provider->name); | sc->components[0].gcons->provider->name); | ||||
▲ Show 20 Lines • Show All 622 Lines • Show Last 20 Lines |