Changeset View
Changeset View
Standalone View
Standalone View
sys/geom/raid3/g_raid3_ctl.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
static struct g_raid3_disk * | static struct g_raid3_disk * | ||||
g_raid3_find_disk(struct g_raid3_softc *sc, const char *name) | g_raid3_find_disk(struct g_raid3_softc *sc, const char *name) | ||||
{ | { | ||||
struct g_raid3_disk *disk; | struct g_raid3_disk *disk; | ||||
u_int n; | u_int n; | ||||
sx_assert(&sc->sc_lock, SX_XLOCKED); | sx_assert(&sc->sc_lock, SX_XLOCKED); | ||||
if (strncmp(name, _PATH_DEV, 5) == 0) | |||||
name += 5; | |||||
for (n = 0; n < sc->sc_ndisks; n++) { | for (n = 0; n < sc->sc_ndisks; n++) { | ||||
disk = &sc->sc_disks[n]; | disk = &sc->sc_disks[n]; | ||||
if (disk->d_state == G_RAID3_DISK_STATE_NODISK) | if (disk->d_state == G_RAID3_DISK_STATE_NODISK) | ||||
continue; | continue; | ||||
if (disk->d_consumer == NULL) | if (disk->d_consumer == NULL) | ||||
continue; | continue; | ||||
if (disk->d_consumer->provider == NULL) | if (disk->d_consumer->provider == NULL) | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | gctl_error(req, "'%s' and '%s' specified.", "verify", | ||||
"noverify"); | "noverify"); | ||||
return; | return; | ||||
} | } | ||||
if (!*autosync && !*noautosync && !*failsync && !*nofailsync && | if (!*autosync && !*noautosync && !*failsync && !*nofailsync && | ||||
!*round_robin && !*noround_robin && !*verify && !*noverify) { | !*round_robin && !*noround_robin && !*verify && !*noverify) { | ||||
gctl_error(req, "Nothing has changed."); | gctl_error(req, "Nothing has changed."); | ||||
return; | return; | ||||
} | } | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_providername(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
return; | return; | ||||
} | |||||
sc = g_raid3_find_device(mp, name); | sc = g_raid3_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", name); | gctl_error(req, "No such device: %s.", name); | ||||
return; | return; | ||||
} | } | ||||
if (g_raid3_ndisks(sc, -1) < sc->sc_ndisks) { | if (g_raid3_ndisks(sc, -1) < sc->sc_ndisks) { | ||||
gctl_error(req, "Not all disks connected."); | gctl_error(req, "Not all disks connected."); | ||||
sx_xunlock(&sc->sc_lock); | sx_xunlock(&sc->sc_lock); | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | g_raid3_ctl_rebuild(struct gctl_req *req, struct g_class *mp) | ||||
if (nargs == NULL) { | if (nargs == NULL) { | ||||
gctl_error(req, "No '%s' argument.", "nargs"); | gctl_error(req, "No '%s' argument.", "nargs"); | ||||
return; | return; | ||||
} | } | ||||
if (*nargs != 2) { | if (*nargs != 2) { | ||||
gctl_error(req, "Invalid number of arguments."); | gctl_error(req, "Invalid number of arguments."); | ||||
return; | return; | ||||
} | } | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_providername(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
return; | return; | ||||
} | |||||
sc = g_raid3_find_device(mp, name); | sc = g_raid3_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", name); | gctl_error(req, "No such device: %s.", name); | ||||
return; | return; | ||||
} | } | ||||
name = gctl_get_asciiparam(req, "arg1"); | name = gctl_get_providername(req, "arg1"); | ||||
if (name == NULL) { | if (name == NULL) { | ||||
gctl_error(req, "No 'arg%u' argument.", 1); | |||||
sx_xunlock(&sc->sc_lock); | sx_xunlock(&sc->sc_lock); | ||||
return; | return; | ||||
} | } | ||||
disk = g_raid3_find_disk(sc, name); | disk = g_raid3_find_disk(sc, name); | ||||
if (disk == NULL) { | if (disk == NULL) { | ||||
gctl_error(req, "No such provider: %s.", name); | gctl_error(req, "No such provider: %s.", name); | ||||
sx_xunlock(&sc->sc_lock); | sx_xunlock(&sc->sc_lock); | ||||
return; | return; | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | g_raid3_ctl_stop(struct gctl_req *req, struct g_class *mp) | ||||
} | } | ||||
if (*force) | if (*force) | ||||
how = G_RAID3_DESTROY_HARD; | how = G_RAID3_DESTROY_HARD; | ||||
else | else | ||||
how = G_RAID3_DESTROY_SOFT; | how = G_RAID3_DESTROY_SOFT; | ||||
for (i = 0; i < (u_int)*nargs; i++) { | for (i = 0; i < (u_int)*nargs; i++) { | ||||
snprintf(param, sizeof(param), "arg%u", i); | snprintf(param, sizeof(param), "arg%u", i); | ||||
name = gctl_get_asciiparam(req, param); | name = gctl_get_providername(req, param); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", i); | |||||
return; | return; | ||||
} | |||||
sc = g_raid3_find_device(mp, name); | sc = g_raid3_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", name); | gctl_error(req, "No such device: %s.", name); | ||||
return; | return; | ||||
} | } | ||||
g_cancel_event(sc); | g_cancel_event(sc); | ||||
error = g_raid3_destroy(sc, how); | error = g_raid3_destroy(sc, how); | ||||
if (error != 0) { | if (error != 0) { | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | g_raid3_ctl_insert(struct gctl_req *req, struct g_class *mp) | ||||
} | } | ||||
error = g_access(cp, 0, 1, 1); | error = g_access(cp, 0, 1, 1); | ||||
if (error != 0) { | if (error != 0) { | ||||
g_topology_unlock(); | g_topology_unlock(); | ||||
gctl_error(req, "Cannot access %s.", pp->name); | gctl_error(req, "Cannot access %s.", pp->name); | ||||
goto end; | goto end; | ||||
} | } | ||||
g_topology_unlock(); | g_topology_unlock(); | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_providername(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
goto end; | goto end; | ||||
} | |||||
sc = g_raid3_find_device(mp, name); | sc = g_raid3_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", name); | gctl_error(req, "No such device: %s.", name); | ||||
goto end; | goto end; | ||||
} | } | ||||
if (no != NULL) { | if (no != NULL) { | ||||
if (*no < 0 || *no >= sc->sc_ndisks) { | if (*no < 0 || *no >= sc->sc_ndisks) { | ||||
sx_xunlock(&sc->sc_lock); | sx_xunlock(&sc->sc_lock); | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | if (*nargs != 1) { | ||||
gctl_error(req, "Invalid number of arguments."); | gctl_error(req, "Invalid number of arguments."); | ||||
return; | return; | ||||
} | } | ||||
no = gctl_get_paraml(req, "number", sizeof(*no)); | no = gctl_get_paraml(req, "number", sizeof(*no)); | ||||
if (no == NULL) { | if (no == NULL) { | ||||
gctl_error(req, "No '%s' argument.", "no"); | gctl_error(req, "No '%s' argument.", "no"); | ||||
return; | return; | ||||
} | } | ||||
name = gctl_get_asciiparam(req, "arg0"); | name = gctl_get_providername(req, "arg0"); | ||||
if (name == NULL) { | if (name == NULL) | ||||
gctl_error(req, "No 'arg%u' argument.", 0); | |||||
return; | return; | ||||
} | |||||
sc = g_raid3_find_device(mp, name); | sc = g_raid3_find_device(mp, name); | ||||
if (sc == NULL) { | if (sc == NULL) { | ||||
gctl_error(req, "No such device: %s.", name); | gctl_error(req, "No such device: %s.", name); | ||||
return; | return; | ||||
} | } | ||||
if (*no >= sc->sc_ndisks) { | if (*no >= sc->sc_ndisks) { | ||||
sx_xunlock(&sc->sc_lock); | sx_xunlock(&sc->sc_lock); | ||||
gctl_error(req, "Invalid component number."); | gctl_error(req, "Invalid component number."); | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |