svn commit: r242649 - stable/9/sys/geom/raid
Alexander Motin
mav at FreeBSD.org
Tue Nov 6 01:53:25 UTC 2012
Author: mav
Date: Tue Nov 6 01:53:25 2012
New Revision: 242649
URL: http://svnweb.freebsd.org/changeset/base/242649
Log:
MFC r241329:
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.
Modified:
stable/9/sys/geom/raid/g_raid_ctl.c
stable/9/sys/geom/raid/md_ddf.c
stable/9/sys/geom/raid/md_intel.c
stable/9/sys/geom/raid/md_promise.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/geom/raid/g_raid_ctl.c
==============================================================================
--- stable/9/sys/geom/raid/g_raid_ctl.c Tue Nov 6 01:49:55 2012 (r242648)
+++ stable/9/sys/geom/raid/g_raid_ctl.c Tue Nov 6 01:53:25 2012 (r242649)
@@ -51,7 +51,10 @@ g_raid_find_node(struct g_class *mp, con
{
struct g_raid_softc *sc;
struct g_geom *gp;
+ struct g_provider *pp;
+ struct g_raid_volume *vol;
+ /* Look for geom with specified name. */
LIST_FOREACH(gp, &mp->geom, geom) {
sc = gp->softc;
if (sc == NULL)
@@ -61,6 +64,35 @@ g_raid_find_node(struct g_class *mp, con
if (strcasecmp(sc->sc_name, name) == 0)
return (sc);
}
+
+ /* Look for provider with specified name. */
+ LIST_FOREACH(gp, &mp->geom, geom) {
+ sc = gp->softc;
+ if (sc == NULL)
+ continue;
+ if (sc->sc_stopping != 0)
+ continue;
+ LIST_FOREACH(pp, &gp->provider, provider) {
+ if (strcmp(pp->name, name) == 0)
+ return (sc);
+ if (strncmp(pp->name, "raid/", 5) == 0 &&
+ strcmp(pp->name + 5, name) == 0)
+ return (sc);
+ }
+ }
+
+ /* Look for volume with specified name. */
+ LIST_FOREACH(gp, &mp->geom, geom) {
+ sc = gp->softc;
+ if (sc == NULL)
+ continue;
+ if (sc->sc_stopping != 0)
+ continue;
+ TAILQ_FOREACH(vol, &sc->sc_volumes, v_next) {
+ if (strcmp(vol->v_name, name) == 0)
+ return (sc);
+ }
+ }
return (NULL);
}
Modified: stable/9/sys/geom/raid/md_ddf.c
==============================================================================
--- stable/9/sys/geom/raid/md_ddf.c Tue Nov 6 01:49:55 2012 (r242648)
+++ stable/9/sys/geom/raid/md_ddf.c Tue Nov 6 01:53:25 2012 (r242649)
@@ -2231,7 +2231,7 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec
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, offs[DDF_MAX_DISKS_HARD], esize;
@@ -2502,8 +2502,12 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec
}
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 &&
@@ -2521,11 +2525,12 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec
}
/* 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);
@@ -2535,6 +2540,14 @@ g_raid_md_ctl_ddf(struct g_raid_md_objec
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);
Modified: stable/9/sys/geom/raid/md_intel.c
==============================================================================
--- stable/9/sys/geom/raid/md_intel.c Tue Nov 6 01:49:55 2012 (r242648)
+++ stable/9/sys/geom/raid/md_intel.c Tue Nov 6 01:53:25 2012 (r242649)
@@ -1461,7 +1461,7 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
struct g_consumer *cp;
struct g_provider *pp;
char arg[16], serial[INTEL_SERIAL_LEN];
- const char *verb, *volname, *levelname, *diskname;
+ const char *nodename, *verb, *volname, *levelname, *diskname;
char *tmp;
int *nargs, *force;
off_t off, size, sectorsize, strip, disk_sectors;
@@ -1876,8 +1876,12 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
}
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 &&
@@ -1895,11 +1899,12 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
}
/* 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);
@@ -1909,6 +1914,14 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
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);
Modified: stable/9/sys/geom/raid/md_promise.c
==============================================================================
--- stable/9/sys/geom/raid/md_promise.c Tue Nov 6 01:49:55 2012 (r242648)
+++ stable/9/sys/geom/raid/md_promise.c Tue Nov 6 01:53:25 2012 (r242649)
@@ -1217,7 +1217,7 @@ g_raid_md_ctl_promise(struct g_raid_md_o
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_o
}
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_o
}
/* 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_o
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);
More information about the svn-src-stable-9
mailing list