Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/stripe/g_stripe.c
Show First 20 Lines • Show All 1,085 Lines • ▼ Show 20 Lines | g_stripe_ctl_create(struct gctl_req *req, struct g_class *mp) | ||||
md.md_stripesize = (uint32_t)*stripesize; | md.md_stripesize = (uint32_t)*stripesize; | ||||
bzero(md.md_provider, sizeof(md.md_provider)); | bzero(md.md_provider, sizeof(md.md_provider)); | ||||
/* This field is not important here. */ | /* This field is not important here. */ | ||||
md.md_provsize = 0; | md.md_provsize = 0; | ||||
/* Check all providers are valid */ | /* Check all providers are valid */ | ||||
for (no = 1; no < *nargs; no++) { | for (no = 1; no < *nargs; no++) { | ||||
snprintf(param, sizeof(param), "arg%u", no); | snprintf(param, sizeof(param), "arg%u", no); | ||||
name = gctl_get_asciiparam(req, param); | pp = gctl_get_provider(req, param); | ||||
if (name == NULL) { | if (pp == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", no); | |||||
return; | return; | ||||
} | } | ||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) | |||||
name += strlen(_PATH_DEV); | |||||
pp = g_provider_by_name(name); | |||||
if (pp == NULL) { | |||||
G_STRIPE_DEBUG(1, "Disk %s is invalid.", name); | |||||
gctl_error(req, "Disk %s is invalid.", name); | |||||
return; | |||||
} | |||||
} | |||||
gp = g_stripe_create(mp, &md, G_STRIPE_TYPE_MANUAL); | gp = g_stripe_create(mp, &md, G_STRIPE_TYPE_MANUAL); | ||||
if (gp == NULL) { | if (gp == NULL) { | ||||
gctl_error(req, "Can't configure %s.", md.md_name); | gctl_error(req, "Can't configure %s.", md.md_name); | ||||
return; | return; | ||||
} | } | ||||
sc = gp->softc; | sc = gp->softc; | ||||
sb = sbuf_new_auto(); | sb = sbuf_new_auto(); | ||||
sbuf_printf(sb, "Can't attach disk(s) to %s:", gp->name); | sbuf_printf(sb, "Can't attach disk(s) to %s:", gp->name); | ||||
for (attached = 0, no = 1; no < *nargs; no++) { | for (attached = 0, no = 1; no < *nargs; no++) { | ||||
snprintf(param, sizeof(param), "arg%u", no); | snprintf(param, sizeof(param), "arg%u", no); | ||||
pp = gctl_get_provider(req, param); | |||||
if (pp == NULL) { | |||||
name = gctl_get_asciiparam(req, param); | name = gctl_get_asciiparam(req, param); | ||||
if (name == NULL) { | MPASS(name != NULL); | ||||
gctl_error(req, "No 'arg%u' argument.", no); | sbuf_printf(sb, " %s", name); | ||||
continue; | continue; | ||||
} | } | ||||
if (strncmp(name, _PATH_DEV, strlen(_PATH_DEV)) == 0) | |||||
name += strlen(_PATH_DEV); | |||||
pp = g_provider_by_name(name); | |||||
KASSERT(pp != NULL, ("Provider %s disappear?!", name)); | |||||
if (g_stripe_add_disk(sc, pp, no - 1) != 0) { | if (g_stripe_add_disk(sc, pp, no - 1) != 0) { | ||||
G_STRIPE_DEBUG(1, "Disk %u (%s) not attached to %s.", | G_STRIPE_DEBUG(1, "Disk %u (%s) not attached to %s.", | ||||
no, pp->name, gp->name); | no, pp->name, gp->name); | ||||
sbuf_printf(sb, " %s", pp->name); | sbuf_printf(sb, " %s", pp->name); | ||||
continue; | continue; | ||||
} | } | ||||
attached++; | attached++; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |