diff options
author | pjd <pjd@FreeBSD.org> | 2004-08-10 19:52:12 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2004-08-10 19:52:12 +0000 |
commit | f0d4b9a881adfc55bb8d152364a63b1c53595903 (patch) | |
tree | de2984db3dff4377ed9381b7aaf14bf93154c7d6 /sys/geom/mirror/g_mirror_ctl.c | |
parent | 0b97f253fb0427b5c3cd051685aa44c2b3e527bf (diff) | |
download | FreeBSD-src-f0d4b9a881adfc55bb8d152364a63b1c53595903.zip FreeBSD-src-f0d4b9a881adfc55bb8d152364a63b1c53595903.tar.gz |
Forgot to commit those: introduce hardcoded provider functionality,
which allow to store provider's name in the metadata and avoid
problems when few providers share the same last sector.
Diffstat (limited to 'sys/geom/mirror/g_mirror_ctl.c')
-rw-r--r-- | sys/geom/mirror/g_mirror_ctl.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/sys/geom/mirror/g_mirror_ctl.c b/sys/geom/mirror/g_mirror_ctl.c index d69c445..0ec5401 100644 --- a/sys/geom/mirror/g_mirror_ctl.c +++ b/sys/geom/mirror/g_mirror_ctl.c @@ -92,7 +92,7 @@ g_mirror_ctl_configure(struct gctl_req *req, struct g_class *mp) intmax_t *slicep; uint32_t slice; uint8_t balance; - int *nargs, *autosync, *noautosync, do_sync = 0; + int *nargs, *autosync, *noautosync, *hardcode, *dynamic, do_sync = 0; g_topology_assert(); nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); @@ -139,8 +139,18 @@ g_mirror_ctl_configure(struct gctl_req *req, struct g_class *mp) gctl_error(req, "No '%s' argument.", "noautosync"); return; } + hardcode = gctl_get_paraml(req, "hardcode", sizeof(*hardcode)); + if (hardcode == NULL) { + gctl_error(req, "No '%s' argument.", "hardcode"); + return; + } + dynamic = gctl_get_paraml(req, "dynamic", sizeof(*dynamic)); + if (dynamic == NULL) { + gctl_error(req, "No '%s' argument.", "dynamic"); + return; + } if (sc->sc_balance == balance && sc->sc_slice == slice && !*autosync && - !*noautosync) { + !*noautosync && !*hardcode && !*dynamic) { gctl_error(req, "Nothing has changed."); return; } @@ -149,6 +159,11 @@ g_mirror_ctl_configure(struct gctl_req *req, struct g_class *mp) "noautosync"); return; } + if (*hardcode && *dynamic) { + gctl_error(req, "'%s' and '%s' specified.", "hardcode", + "dynamic"); + return; + } sc->sc_balance = balance; sc->sc_slice = slice; if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_NOAUTOSYNC) != 0) { @@ -165,6 +180,10 @@ g_mirror_ctl_configure(struct gctl_req *req, struct g_class *mp) if (disk->d_state == G_MIRROR_DISK_STATE_SYNCHRONIZING) disk->d_flags &= ~G_MIRROR_DISK_FLAG_FORCE_SYNC; } + if (*hardcode) + disk->d_flags |= G_MIRROR_DISK_FLAG_HARDCODED; + else if (*dynamic) + disk->d_flags &= ~G_MIRROR_DISK_FLAG_HARDCODED; g_mirror_update_metadata(disk); if (do_sync) { if (disk->d_state == G_MIRROR_DISK_STATE_STALE) { @@ -257,7 +276,7 @@ g_mirror_ctl_insert(struct gctl_req *req, struct g_class *mp) char param[16]; u_char *sector; u_int i, n; - int error, *nargs, *inactive; + int error, *nargs, *hardcode, *inactive; struct { struct g_provider *provider; struct g_consumer *consumer; @@ -283,6 +302,11 @@ g_mirror_ctl_insert(struct gctl_req *req, struct g_class *mp) gctl_error(req, "No '%s' argument.", "inactive"); return; } + hardcode = gctl_get_paraml(req, "hardcode", sizeof(*hardcode)); + if (hardcode == NULL) { + gctl_error(req, "No '%s' argument.", "hardcode"); + return; + } name = gctl_get_asciiparam(req, "arg0"); if (name == NULL) { gctl_error(req, "No 'arg%u' argument.", 0); @@ -356,6 +380,12 @@ again: if (*inactive) md.md_dflags |= G_MIRROR_DISK_FLAG_INACTIVE; pp = disks[i].provider; + if (*hardcode) { + strlcpy(md.md_provider, pp->name, + sizeof(md.md_provider)); + } else { + bzero(md.md_provider, sizeof(md.md_provider)); + } sector = g_malloc(pp->sectorsize, M_WAITOK); mirror_metadata_encode(&md, sector); error = g_write_data(disks[i].consumer, |