summaryrefslogtreecommitdiffstats
path: root/sys/geom/raid/md_promise.c
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2012-10-07 19:30:16 +0000
committermav <mav@FreeBSD.org>2012-10-07 19:30:16 +0000
commitbfb53c205cc5070309c8d61379cb48a0522ecade (patch)
treec617d1bde383726701bd7c5f4fcb51dddb0cebfc /sys/geom/raid/md_promise.c
parent65071837b032899bb739b4637721104cd3a7d80a (diff)
downloadFreeBSD-src-bfb53c205cc5070309c8d61379cb48a0522ecade.zip
FreeBSD-src-bfb53c205cc5070309c8d61379cb48a0522ecade.tar.gz
Make graid command line a bit more friendly by allowing volume name or
provider name to be specified instead of geom name (first argument in all subcommands except label). In most cases there is only one array used any way, so it is not really useful to make user type ugly geom names like Intel-f0bdf223 or SiI-732c2b9448cf. Though they can be used in some cases. Sponsored by: iXsystems, Inc. MFC after: 1 month
Diffstat (limited to 'sys/geom/raid/md_promise.c')
-rw-r--r--sys/geom/raid/md_promise.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sys/geom/raid/md_promise.c b/sys/geom/raid/md_promise.c
index 6dc0916..b9d667a 100644
--- a/sys/geom/raid/md_promise.c
+++ b/sys/geom/raid/md_promise.c
@@ -1217,7 +1217,7 @@ g_raid_md_ctl_promise(struct g_raid_md_object *md,
struct g_consumer *cp;
struct g_provider *pp;
char arg[16];
- const char *verb, *volname, *levelname, *diskname;
+ const char *nodename, *verb, *volname, *levelname, *diskname;
char *tmp;
int *nargs, *force;
off_t size, sectorsize, strip;
@@ -1478,8 +1478,12 @@ g_raid_md_ctl_promise(struct g_raid_md_object *md,
}
if (strcmp(verb, "delete") == 0) {
+ nodename = gctl_get_asciiparam(req, "arg0");
+ if (nodename != NULL && strcasecmp(sc->sc_name, nodename) != 0)
+ nodename = NULL;
+
/* Full node destruction. */
- if (*nargs == 1) {
+ if (*nargs == 1 && nodename != NULL) {
/* Check if some volume is still open. */
force = gctl_get_paraml(req, "force", sizeof(*force));
if (force != NULL && *force == 0 &&
@@ -1497,11 +1501,12 @@ g_raid_md_ctl_promise(struct g_raid_md_object *md,
}
/* Destroy specified volume. If it was last - all node. */
- if (*nargs != 2) {
+ if (*nargs > 2) {
gctl_error(req, "Invalid number of arguments.");
return (-1);
}
- volname = gctl_get_asciiparam(req, "arg1");
+ volname = gctl_get_asciiparam(req,
+ nodename != NULL ? "arg1" : "arg0");
if (volname == NULL) {
gctl_error(req, "No volume name.");
return (-2);
@@ -1511,6 +1516,14 @@ g_raid_md_ctl_promise(struct g_raid_md_object *md,
TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) {
if (strcmp(vol->v_name, volname) == 0)
break;
+ pp = vol->v_provider;
+ if (pp == NULL)
+ continue;
+ if (strcmp(pp->name, volname) == 0)
+ break;
+ if (strncmp(pp->name, "raid/", 5) == 0 &&
+ strcmp(pp->name + 5, volname) == 0)
+ break;
}
if (vol == NULL) {
i = strtol(volname, &tmp, 10);
OpenPOWER on IntegriCloud