From 55d6eb9fef37de85ba595146e4dda73d25fba9c5 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Sat, 31 Jul 2004 00:54:44 +0000 Subject: [PATCH] Add '-p' option for 'insert' command which allows to specify priority of the new component. Version number wasn't bumped (it should be), because I think there are no geom_mirror users yet. --- sbin/geom/class/mirror/geom_mirror.c | 4 +++- sys/geom/mirror/g_mirror_ctl.c | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sbin/geom/class/mirror/geom_mirror.c b/sbin/geom/class/mirror/geom_mirror.c index 66174b7c2cf6..04f035152a7b 100644 --- a/sbin/geom/class/mirror/geom_mirror.c +++ b/sbin/geom/class/mirror/geom_mirror.c @@ -46,6 +46,7 @@ uint32_t version = G_MIRROR_VERSION; static char label_balance[] = "split", configure_balance[] = "none"; static intmax_t label_slice = 4096, configure_slice = -1; +static intmax_t insert_priority = 0; static void mirror_main(struct gctl_req *req, unsigned f); static void mirror_activate(struct gctl_req *req); @@ -79,6 +80,7 @@ struct g_command class_commands[] = { { "insert", G_FLAG_VERBOSE, NULL, { { 'i', "inactive", NULL, G_TYPE_NONE }, + { 'p', "priority", &insert_priority, G_TYPE_NUMBER }, G_OPT_SENTINEL } }, @@ -105,7 +107,7 @@ usage(const char *comm) " %s dump dev1 [dev2 [...]]\n" " %s configure [-anv] [-b balance] [-s slice] name\n" " %s rebuild [-v] name dev1 [dev2 [...]]\n" - " %s insert [-iv] name dev1 [dev2 [...]]\n" + " %s insert [-iv] [-p priority] name dev1 [dev2 [...]]\n" " %s remove [-v] name dev1 [dev2 [...]]\n" " %s activate [-v] name dev1 [dev2 [...]]\n" " %s deactivate [-v] name dev1 [dev2 [...]]\n" diff --git a/sys/geom/mirror/g_mirror_ctl.c b/sys/geom/mirror/g_mirror_ctl.c index 36859010ffab..d69c44595ec8 100644 --- a/sys/geom/mirror/g_mirror_ctl.c +++ b/sys/geom/mirror/g_mirror_ctl.c @@ -252,6 +252,7 @@ g_mirror_ctl_insert(struct gctl_req *req, struct g_class *mp) struct g_mirror_metadata md; struct g_provider *pp; struct g_consumer *cp; + intmax_t *priority; const char *name; char param[16]; u_char *sector; @@ -272,6 +273,11 @@ g_mirror_ctl_insert(struct gctl_req *req, struct g_class *mp) gctl_error(req, "Too few arguments."); return; } + priority = gctl_get_paraml(req, "priority", sizeof(*priority)); + if (priority == NULL) { + gctl_error(req, "No '%s' argument.", "priority"); + return; + } inactive = gctl_get_paraml(req, "inactive", sizeof(*inactive)); if (inactive == NULL) { gctl_error(req, "No '%s' argument.", "inactive"); @@ -346,6 +352,7 @@ again: if (disks[i].consumer == NULL) continue; g_mirror_fill_metadata(sc, NULL, &md); + md.md_priority = *priority; if (*inactive) md.md_dflags |= G_MIRROR_DISK_FLAG_INACTIVE; pp = disks[i].provider;