Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/raid/md_ddf.c
Show First 20 Lines • Show All 583 Lines • ▼ Show 20 Lines | ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample) | ||||
pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; | pd = (struct g_raid_md_ddf_perdisk *)disk->d_md_data; | ||||
meta = &pd->pd_meta; | meta = &pd->pd_meta; | ||||
ss = disk->d_consumer->provider->sectorsize; | ss = disk->d_consumer->provider->sectorsize; | ||||
anchorlba = disk->d_consumer->provider->mediasize / ss - 1; | anchorlba = disk->d_consumer->provider->mediasize / ss - 1; | ||||
meta->sectorsize = ss; | meta->sectorsize = ss; | ||||
meta->bigendian = sample ? sample->bigendian : mdi->mdio_bigendian; | meta->bigendian = sample ? sample->bigendian : mdi->mdio_bigendian; | ||||
getnanotime(&ts); | getnanotime(&ts); | ||||
clock_ts_to_ct(&ts, &ct); | |||||
/* Header */ | /* Header */ | ||||
meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); | meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); | ||||
memset(meta->hdr, 0xff, ss); | memset(meta->hdr, 0xff, ss); | ||||
if (sample) { | if (sample) { | ||||
memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header)); | memcpy(meta->hdr, sample->hdr, sizeof(struct ddf_header)); | ||||
if (ss != sample->sectorsize) { | if (ss != sample->sectorsize) { | ||||
SET32(meta, hdr->WorkSpace_Length, | SET32(meta, hdr->WorkSpace_Length, | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | ddf_meta_create(struct g_raid_disk *disk, struct ddf_meta *sample) | ||||
SET16(meta, pdr->Max_PDE_Supported, | SET16(meta, pdr->Max_PDE_Supported, | ||||
GET16(meta, hdr->Max_PD_Entries)); | GET16(meta, hdr->Max_PD_Entries)); | ||||
pde = &meta->pdr->entry[0]; | pde = &meta->pdr->entry[0]; | ||||
len = sizeof(serial_buffer); | len = sizeof(serial_buffer); | ||||
error = g_io_getattr("GEOM::ident", disk->d_consumer, &len, serial_buffer); | error = g_io_getattr("GEOM::ident", disk->d_consumer, &len, serial_buffer); | ||||
if (error == 0 && (len = strlen (serial_buffer)) >= 6 && len <= 20) | if (error == 0 && (len = strlen (serial_buffer)) >= 6 && len <= 20) | ||||
snprintf(pde->PD_GUID, 25, "DISK%20s", serial_buffer); | snprintf(pde->PD_GUID, 25, "DISK%20s", serial_buffer); | ||||
else | else { | ||||
error = clock_ts_to_ct(&ts, &ct); | |||||
if (error) { | |||||
imp: Panic here means we can't boot. | |||||
Done Inline ActionsYeah, but it paniced before this change too, at least when INVARIANTS were on. It's easy enough to fix though, so I'll do it. asomers: Yeah, but it paniced before this change too, at least when INVARIANTS were on. It's easy… | |||||
snprintf(pde->PD_GUID, 25, "DISK%08x%04x", | |||||
arc4random(), arc4random() & 0xffff); | |||||
} else { | |||||
snprintf(pde->PD_GUID, 25, "DISK%04d%02d%02d%08x%04x", | snprintf(pde->PD_GUID, 25, "DISK%04d%02d%02d%08x%04x", | ||||
ct.year, ct.mon, ct.day, | ct.year, ct.mon, ct.day, | ||||
arc4random(), arc4random() & 0xffff); | arc4random(), arc4random() & 0xffff); | ||||
} | |||||
} | |||||
SET32D(meta, pde->PD_Reference, arc4random()); | SET32D(meta, pde->PD_Reference, arc4random()); | ||||
SET16D(meta, pde->PD_Type, DDF_PDE_GUID_FORCE); | SET16D(meta, pde->PD_Type, DDF_PDE_GUID_FORCE); | ||||
SET16D(meta, pde->PD_State, 0); | SET16D(meta, pde->PD_State, 0); | ||||
SET64D(meta, pde->Configured_Size, | SET64D(meta, pde->Configured_Size, | ||||
anchorlba + 1 - 32 * 1024 * 1024 / ss); | anchorlba + 1 - 32 * 1024 * 1024 / ss); | ||||
SET16D(meta, pde->Block_Size, ss); | SET16D(meta, pde->Block_Size, ss); | ||||
/* Virtual Drive Records. */ | /* Virtual Drive Records. */ | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
static void | static void | ||||
ddf_vol_meta_create(struct ddf_vol_meta *meta, struct ddf_meta *sample) | ddf_vol_meta_create(struct ddf_vol_meta *meta, struct ddf_meta *sample) | ||||
{ | { | ||||
struct timespec ts; | struct timespec ts; | ||||
struct clocktime ct; | struct clocktime ct; | ||||
u_int ss, size; | u_int ss, size; | ||||
int error; | |||||
meta->bigendian = sample->bigendian; | meta->bigendian = sample->bigendian; | ||||
ss = meta->sectorsize = sample->sectorsize; | ss = meta->sectorsize = sample->sectorsize; | ||||
meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); | meta->hdr = malloc(ss, M_MD_DDF, M_WAITOK); | ||||
memcpy(meta->hdr, sample->hdr, ss); | memcpy(meta->hdr, sample->hdr, ss); | ||||
meta->cdr = malloc(GET32(sample, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); | meta->cdr = malloc(GET32(sample, hdr->cd_length) * ss, M_MD_DDF, M_WAITOK); | ||||
memcpy(meta->cdr, sample->cdr, GET32(sample, hdr->cd_length) * ss); | memcpy(meta->cdr, sample->cdr, GET32(sample, hdr->cd_length) * ss); | ||||
meta->vde = malloc(sizeof(struct ddf_vd_entry), M_MD_DDF, M_WAITOK); | meta->vde = malloc(sizeof(struct ddf_vd_entry), M_MD_DDF, M_WAITOK); | ||||
memset(meta->vde, 0xff, sizeof(struct ddf_vd_entry)); | memset(meta->vde, 0xff, sizeof(struct ddf_vd_entry)); | ||||
getnanotime(&ts); | getnanotime(&ts); | ||||
clock_ts_to_ct(&ts, &ct); | error = clock_ts_to_ct(&ts, &ct); | ||||
Not Done Inline Actionspanic here means we can't boot. imp: panic here means we can't boot.
| |||||
Done Inline ActionsSame as above, this line paniced before too. And I'll fix it too. asomers: Same as above, this line paniced before too. And I'll fix it too. | |||||
if (error) { | |||||
snprintf(meta->vde->VD_GUID, 25, "FreeBSD%08x%01x", | |||||
arc4random(), arc4random() & 0xf); | |||||
} else { | |||||
snprintf(meta->vde->VD_GUID, 25, "FreeBSD%04d%02d%02d%08x%01x", | snprintf(meta->vde->VD_GUID, 25, "FreeBSD%04d%02d%02d%08x%01x", | ||||
ct.year, ct.mon, ct.day, | ct.year, ct.mon, ct.day, | ||||
arc4random(), arc4random() & 0xf); | arc4random(), arc4random() & 0xf); | ||||
} | |||||
size = GET16(sample, hdr->Configuration_Record_Length) * ss; | size = GET16(sample, hdr->Configuration_Record_Length) * ss; | ||||
meta->vdc = malloc(size, M_MD_DDF, M_WAITOK); | meta->vdc = malloc(size, M_MD_DDF, M_WAITOK); | ||||
memset(meta->vdc, 0xff, size); | memset(meta->vdc, 0xff, size); | ||||
SET32(meta, vdc->Signature, DDF_VDCR_SIGNATURE); | SET32(meta, vdc->Signature, DDF_VDCR_SIGNATURE); | ||||
memcpy(meta->vdc->VD_GUID, meta->vde->VD_GUID, 24); | memcpy(meta->vdc->VD_GUID, meta->vde->VD_GUID, 24); | ||||
SET32(meta, vdc->Sequence_Number, 0); | SET32(meta, vdc->Sequence_Number, 0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,219 Lines • Show Last 20 Lines |
Panic here means we can't boot.