2 * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/kernel.h>
33 #include <sys/module.h>
35 #include <sys/mutex.h>
37 #include <sys/sysctl.h>
38 #include <sys/malloc.h>
39 #include <geom/geom.h>
40 #include <geom/concat/g_concat.h>
43 static MALLOC_DEFINE(M_CONCAT, "concat_data", "GEOM_CONCAT Data");
45 SYSCTL_DECL(_kern_geom);
46 SYSCTL_NODE(_kern_geom, OID_AUTO, concat, CTLFLAG_RW, 0, "GEOM_CONCAT stuff");
47 static u_int g_concat_debug = 0;
48 TUNABLE_INT("kern.geom.concat.debug", &g_concat_debug);
49 SYSCTL_UINT(_kern_geom_concat, OID_AUTO, debug, CTLFLAG_RW, &g_concat_debug, 0,
52 static int g_concat_destroy(struct g_concat_softc *sc, boolean_t force);
53 static int g_concat_destroy_geom(struct gctl_req *req, struct g_class *mp,
56 static g_taste_t g_concat_taste;
57 static g_ctl_req_t g_concat_config;
58 static g_dumpconf_t g_concat_dumpconf;
60 struct g_class g_concat_class = {
61 .name = G_CONCAT_CLASS_NAME,
63 .ctlreq = g_concat_config,
64 .taste = g_concat_taste,
65 .destroy_geom = g_concat_destroy_geom
70 * Greatest Common Divisor.
86 * Least Common Multiple.
92 return ((a * b) / gcd(a, b));
96 * Return the number of valid disks.
99 g_concat_nvalid(struct g_concat_softc *sc)
104 for (i = 0; i < sc->sc_ndisks; i++) {
105 if (sc->sc_disks[i].d_consumer != NULL)
113 g_concat_remove_disk(struct g_concat_disk *disk)
115 struct g_consumer *cp;
116 struct g_concat_softc *sc;
118 KASSERT(disk->d_consumer != NULL, ("Non-valid disk in %s.", __func__));
120 cp = disk->d_consumer;
122 G_CONCAT_DEBUG(0, "Disk %s removed from %s.", cp->provider->name,
125 disk->d_consumer = NULL;
126 if (sc->sc_provider != NULL) {
127 sc->sc_provider->flags |= G_PF_WITHER;
128 g_orphan_provider(sc->sc_provider, ENXIO);
129 sc->sc_provider = NULL;
130 G_CONCAT_DEBUG(0, "Device %s removed.", sc->sc_name);
133 if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0)
134 g_access(cp, -cp->acr, -cp->acw, -cp->ace);
136 g_destroy_consumer(cp);
140 g_concat_orphan(struct g_consumer *cp)
142 struct g_concat_softc *sc;
143 struct g_concat_disk *disk;
153 if (disk == NULL) /* Possible? */
155 g_concat_remove_disk(disk);
157 /* If there are no valid disks anymore, remove device. */
158 if (g_concat_nvalid(sc) == 0)
159 g_concat_destroy(sc, 1);
163 g_concat_access(struct g_provider *pp, int dr, int dw, int de)
165 struct g_consumer *cp1, *cp2;
166 struct g_concat_softc *sc;
175 * It looks like geom is being withered.
176 * In that case we allow only negative requests.
178 KASSERT(dr <= 0 && dw <= 0 && de <= 0,
179 ("Positive access request (device=%s).", pp->name));
180 if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 &&
181 (pp->ace + de) == 0) {
182 G_CONCAT_DEBUG(0, "Device %s definitely destroyed.",
188 /* On first open, grab an extra "exclusive" bit */
189 if (pp->acr == 0 && pp->acw == 0 && pp->ace == 0)
191 /* ... and let go of it on last close */
192 if ((pp->acr + dr) == 0 && (pp->acw + dw) == 0 && (pp->ace + de) == 0)
196 LIST_FOREACH(cp1, &gp->consumer, consumer) {
197 error = g_access(cp1, dr, dw, de);
201 * If we fail here, backout all previous changes.
203 LIST_FOREACH(cp2, &gp->consumer, consumer) {
206 g_access(cp2, -dr, -dw, -de);
215 g_concat_kernel_dump(struct bio *bp)
217 struct g_concat_softc *sc;
218 struct g_concat_disk *disk;
220 struct g_kerneldump *gkd;
223 sc = bp->bio_to->geom->softc;
224 gkd = (struct g_kerneldump *)bp->bio_data;
225 for (i = 0; i < sc->sc_ndisks; i++) {
226 if (sc->sc_disks[i].d_start <= gkd->offset &&
227 sc->sc_disks[i].d_end > gkd->offset)
230 if (i == sc->sc_ndisks)
231 g_io_deliver(bp, EOPNOTSUPP);
232 disk = &sc->sc_disks[i];
233 gkd->offset -= disk->d_start;
234 if (gkd->length > disk->d_end - disk->d_start - gkd->offset)
235 gkd->length = disk->d_end - disk->d_start - gkd->offset;
236 cbp = g_clone_bio(bp);
238 g_io_deliver(bp, ENOMEM);
241 cbp->bio_done = g_std_done;
242 g_io_request(cbp, disk->d_consumer);
243 G_CONCAT_DEBUG(1, "Kernel dump will go to %s.",
244 disk->d_consumer->provider->name);
248 g_concat_flush(struct g_concat_softc *sc, struct bio *bp)
250 struct bio_queue_head queue;
251 struct g_consumer *cp;
256 for (no = 0; no < sc->sc_ndisks; no++) {
257 cbp = g_clone_bio(bp);
259 for (cbp = bioq_first(&queue); cbp != NULL;
260 cbp = bioq_first(&queue)) {
261 bioq_remove(&queue, cbp);
264 if (bp->bio_error == 0)
265 bp->bio_error = ENOMEM;
266 g_io_deliver(bp, bp->bio_error);
269 bioq_insert_tail(&queue, cbp);
270 cbp->bio_done = g_std_done;
271 cbp->bio_caller1 = sc->sc_disks[no].d_consumer;
272 cbp->bio_to = sc->sc_disks[no].d_consumer->provider;
274 for (cbp = bioq_first(&queue); cbp != NULL; cbp = bioq_first(&queue)) {
275 bioq_remove(&queue, cbp);
276 G_CONCAT_LOGREQ(cbp, "Sending request.");
277 cp = cbp->bio_caller1;
278 cbp->bio_caller1 = NULL;
279 g_io_request(cbp, cp);
284 g_concat_start(struct bio *bp)
286 struct bio_queue_head queue;
287 struct g_concat_softc *sc;
288 struct g_concat_disk *disk;
289 struct g_provider *pp;
290 off_t offset, end, length, off, len;
296 sc = pp->geom->softc;
298 * If sc == NULL, provider's error should be set and g_concat_start()
299 * should not be called at all.
302 ("Provider's error should be set (error=%d)(device=%s).",
303 bp->bio_to->error, bp->bio_to->name));
305 G_CONCAT_LOGREQ(bp, "Request received.");
307 switch (bp->bio_cmd) {
313 g_concat_flush(sc, bp);
316 if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) {
317 g_concat_kernel_dump(bp);
320 /* To which provider it should be delivered? */
323 g_io_deliver(bp, EOPNOTSUPP);
327 offset = bp->bio_offset;
328 length = bp->bio_length;
330 end = offset + length;
333 for (no = 0; no < sc->sc_ndisks; no++) {
334 disk = &sc->sc_disks[no];
335 if (disk->d_end <= offset)
337 if (disk->d_start >= end)
340 off = offset - disk->d_start;
341 len = MIN(length, disk->d_end - offset);
345 cbp = g_clone_bio(bp);
347 for (cbp = bioq_first(&queue); cbp != NULL;
348 cbp = bioq_first(&queue)) {
349 bioq_remove(&queue, cbp);
352 if (bp->bio_error == 0)
353 bp->bio_error = ENOMEM;
354 g_io_deliver(bp, bp->bio_error);
357 bioq_insert_tail(&queue, cbp);
359 * Fill in the component buf structure.
361 cbp->bio_done = g_std_done;
362 cbp->bio_offset = off;
363 cbp->bio_data = addr;
365 cbp->bio_length = len;
366 cbp->bio_to = disk->d_consumer->provider;
367 cbp->bio_caller1 = disk;
373 ("Length is still greater than 0 (class=%s, name=%s).",
374 bp->bio_to->geom->class->name, bp->bio_to->geom->name));
375 for (cbp = bioq_first(&queue); cbp != NULL; cbp = bioq_first(&queue)) {
376 bioq_remove(&queue, cbp);
377 G_CONCAT_LOGREQ(cbp, "Sending request.");
378 disk = cbp->bio_caller1;
379 cbp->bio_caller1 = NULL;
380 g_io_request(cbp, disk->d_consumer);
385 g_concat_check_and_run(struct g_concat_softc *sc)
387 struct g_concat_disk *disk;
388 struct g_provider *pp;
389 u_int no, sectorsize = 0;
392 if (g_concat_nvalid(sc) != sc->sc_ndisks)
395 pp = g_new_providerf(sc->sc_geom, "concat/%s", sc->sc_name);
397 for (no = 0; no < sc->sc_ndisks; no++) {
398 disk = &sc->sc_disks[no];
399 disk->d_start = start;
400 disk->d_end = disk->d_start +
401 disk->d_consumer->provider->mediasize;
402 if (sc->sc_type == G_CONCAT_TYPE_AUTOMATIC)
403 disk->d_end -= disk->d_consumer->provider->sectorsize;
406 sectorsize = disk->d_consumer->provider->sectorsize;
408 sectorsize = lcm(sectorsize,
409 disk->d_consumer->provider->sectorsize);
412 pp->sectorsize = sectorsize;
413 /* We have sc->sc_disks[sc->sc_ndisks - 1].d_end in 'start'. */
414 pp->mediasize = start;
415 pp->stripesize = sc->sc_disks[0].d_consumer->provider->stripesize;
416 pp->stripeoffset = sc->sc_disks[0].d_consumer->provider->stripeoffset;
417 sc->sc_provider = pp;
418 g_error_provider(pp, 0);
420 G_CONCAT_DEBUG(0, "Device %s activated.", sc->sc_name);
424 g_concat_read_metadata(struct g_consumer *cp, struct g_concat_metadata *md)
426 struct g_provider *pp;
432 error = g_access(cp, 1, 0, 0);
437 buf = g_read_data(cp, pp->mediasize - pp->sectorsize, pp->sectorsize,
440 g_access(cp, -1, 0, 0);
444 /* Decode metadata. */
445 concat_metadata_decode(buf, md);
452 * Add disk to given device.
455 g_concat_add_disk(struct g_concat_softc *sc, struct g_provider *pp, u_int no)
457 struct g_concat_disk *disk;
458 struct g_consumer *cp, *fcp;
462 /* Metadata corrupted? */
463 if (no >= sc->sc_ndisks)
466 disk = &sc->sc_disks[no];
467 /* Check if disk is not already attached. */
468 if (disk->d_consumer != NULL)
472 fcp = LIST_FIRST(&gp->consumer);
474 cp = g_new_consumer(gp);
475 error = g_attach(cp, pp);
477 g_destroy_consumer(cp);
481 if (fcp != NULL && (fcp->acr > 0 || fcp->acw > 0 || fcp->ace > 0)) {
482 error = g_access(cp, fcp->acr, fcp->acw, fcp->ace);
485 g_destroy_consumer(cp);
489 if (sc->sc_type == G_CONCAT_TYPE_AUTOMATIC) {
490 struct g_concat_metadata md;
492 /* Re-read metadata. */
493 error = g_concat_read_metadata(cp, &md);
497 if (strcmp(md.md_magic, G_CONCAT_MAGIC) != 0 ||
498 strcmp(md.md_name, sc->sc_name) != 0 ||
499 md.md_id != sc->sc_id) {
500 G_CONCAT_DEBUG(0, "Metadata on %s changed.", pp->name);
506 disk->d_consumer = cp;
508 disk->d_start = 0; /* not yet */
509 disk->d_end = 0; /* not yet */
511 G_CONCAT_DEBUG(0, "Disk %s attached to %s.", pp->name, sc->sc_name);
513 g_concat_check_and_run(sc);
517 if (fcp != NULL && (fcp->acr > 0 || fcp->acw > 0 || fcp->ace > 0))
518 g_access(cp, -fcp->acr, -fcp->acw, -fcp->ace);
520 g_destroy_consumer(cp);
524 static struct g_geom *
525 g_concat_create(struct g_class *mp, const struct g_concat_metadata *md,
528 struct g_concat_softc *sc;
532 G_CONCAT_DEBUG(1, "Creating device %s (id=%u).", md->md_name,
535 /* One disks is minimum. */
539 /* Check for duplicate unit */
540 LIST_FOREACH(gp, &mp->geom, geom) {
542 if (sc != NULL && strcmp(sc->sc_name, md->md_name) == 0) {
543 G_CONCAT_DEBUG(0, "Device %s already configured.",
548 gp = g_new_geomf(mp, "%s", md->md_name);
549 gp->softc = NULL; /* for a moment */
551 sc = malloc(sizeof(*sc), M_CONCAT, M_WAITOK | M_ZERO);
552 gp->start = g_concat_start;
553 gp->spoiled = g_concat_orphan;
554 gp->orphan = g_concat_orphan;
555 gp->access = g_concat_access;
556 gp->dumpconf = g_concat_dumpconf;
558 sc->sc_id = md->md_id;
559 sc->sc_ndisks = md->md_all;
560 sc->sc_disks = malloc(sizeof(struct g_concat_disk) * sc->sc_ndisks,
561 M_CONCAT, M_WAITOK | M_ZERO);
562 for (no = 0; no < sc->sc_ndisks; no++)
563 sc->sc_disks[no].d_consumer = NULL;
568 sc->sc_provider = NULL;
570 G_CONCAT_DEBUG(0, "Device %s created (id=%u).", sc->sc_name, sc->sc_id);
576 g_concat_destroy(struct g_concat_softc *sc, boolean_t force)
578 struct g_provider *pp;
587 pp = sc->sc_provider;
588 if (pp != NULL && (pp->acr != 0 || pp->acw != 0 || pp->ace != 0)) {
590 G_CONCAT_DEBUG(0, "Device %s is still open, so it "
591 "can't be definitely removed.", pp->name);
594 "Device %s is still open (r%dw%de%d).", pp->name,
595 pp->acr, pp->acw, pp->ace);
600 for (no = 0; no < sc->sc_ndisks; no++) {
601 if (sc->sc_disks[no].d_consumer != NULL)
602 g_concat_remove_disk(&sc->sc_disks[no]);
607 KASSERT(sc->sc_provider == NULL, ("Provider still exists? (device=%s)",
609 free(sc->sc_disks, M_CONCAT);
612 pp = LIST_FIRST(&gp->provider);
613 if (pp == NULL || (pp->acr == 0 && pp->acw == 0 && pp->ace == 0))
614 G_CONCAT_DEBUG(0, "Device %s destroyed.", gp->name);
616 g_wither_geom(gp, ENXIO);
622 g_concat_destroy_geom(struct gctl_req *req __unused,
623 struct g_class *mp __unused, struct g_geom *gp)
625 struct g_concat_softc *sc;
628 return (g_concat_destroy(sc, 0));
631 static struct g_geom *
632 g_concat_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
634 struct g_concat_metadata md;
635 struct g_concat_softc *sc;
636 struct g_consumer *cp;
640 g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, pp->name);
643 /* Skip providers that are already open for writing. */
647 G_CONCAT_DEBUG(3, "Tasting %s.", pp->name);
649 gp = g_new_geomf(mp, "concat:taste");
650 gp->start = g_concat_start;
651 gp->access = g_concat_access;
652 gp->orphan = g_concat_orphan;
653 cp = g_new_consumer(gp);
655 error = g_concat_read_metadata(cp, &md);
657 g_destroy_consumer(cp);
663 if (strcmp(md.md_magic, G_CONCAT_MAGIC) != 0)
665 if (md.md_version > G_CONCAT_VERSION) {
666 printf("geom_concat.ko module is too old to handle %s.\n",
671 * Backward compatibility:
673 /* There was no md_provider field in earlier versions of metadata. */
674 if (md.md_version < 3)
675 bzero(md.md_provider, sizeof(md.md_provider));
676 /* There was no md_provsize field in earlier versions of metadata. */
677 if (md.md_version < 4)
678 md.md_provsize = pp->mediasize;
680 if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0)
682 if (md.md_provsize != pp->mediasize)
686 * Let's check if device already exists.
689 LIST_FOREACH(gp, &mp->geom, geom) {
693 if (sc->sc_type != G_CONCAT_TYPE_AUTOMATIC)
695 if (strcmp(md.md_name, sc->sc_name) != 0)
697 if (md.md_id != sc->sc_id)
702 G_CONCAT_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
703 error = g_concat_add_disk(sc, pp, md.md_no);
706 "Cannot add disk %s to %s (error=%d).", pp->name,
711 gp = g_concat_create(mp, &md, G_CONCAT_TYPE_AUTOMATIC);
713 G_CONCAT_DEBUG(0, "Cannot create device %s.",
718 G_CONCAT_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name);
719 error = g_concat_add_disk(sc, pp, md.md_no);
722 "Cannot add disk %s to %s (error=%d).", pp->name,
724 g_concat_destroy(sc, 1);
733 g_concat_ctl_create(struct gctl_req *req, struct g_class *mp)
736 struct g_concat_metadata md;
737 struct g_provider *pp;
738 struct g_concat_softc *sc;
746 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
748 gctl_error(req, "No '%s' argument.", "nargs");
752 gctl_error(req, "Too few arguments.");
756 strlcpy(md.md_magic, G_CONCAT_MAGIC, sizeof(md.md_magic));
757 md.md_version = G_CONCAT_VERSION;
758 name = gctl_get_asciiparam(req, "arg0");
760 gctl_error(req, "No 'arg%u' argument.", 0);
763 strlcpy(md.md_name, name, sizeof(md.md_name));
764 md.md_id = arc4random();
766 md.md_all = *nargs - 1;
767 bzero(md.md_provider, sizeof(md.md_provider));
768 /* This field is not important here. */
771 /* Check all providers are valid */
772 for (no = 1; no < *nargs; no++) {
773 snprintf(param, sizeof(param), "arg%u", no);
774 name = gctl_get_asciiparam(req, param);
776 gctl_error(req, "No 'arg%u' argument.", no);
779 if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
780 name += strlen("/dev/");
781 pp = g_provider_by_name(name);
783 G_CONCAT_DEBUG(1, "Disk %s is invalid.", name);
784 gctl_error(req, "Disk %s is invalid.", name);
789 gp = g_concat_create(mp, &md, G_CONCAT_TYPE_MANUAL);
791 gctl_error(req, "Can't configure %s.", md.md_name);
796 sb = sbuf_new_auto();
797 sbuf_printf(sb, "Can't attach disk(s) to %s:", gp->name);
798 for (attached = 0, no = 1; no < *nargs; no++) {
799 snprintf(param, sizeof(param), "arg%u", no);
800 name = gctl_get_asciiparam(req, param);
802 gctl_error(req, "No 'arg%d' argument.", no);
805 if (strncmp(name, "/dev/", strlen("/dev/")) == 0)
806 name += strlen("/dev/");
807 pp = g_provider_by_name(name);
808 KASSERT(pp != NULL, ("Provider %s disappear?!", name));
809 if (g_concat_add_disk(sc, pp, no - 1) != 0) {
810 G_CONCAT_DEBUG(1, "Disk %u (%s) not attached to %s.",
811 no, pp->name, gp->name);
812 sbuf_printf(sb, " %s", pp->name);
818 if (md.md_all != attached) {
819 g_concat_destroy(gp->softc, 1);
820 gctl_error(req, "%s", sbuf_data(sb));
825 static struct g_concat_softc *
826 g_concat_find_device(struct g_class *mp, const char *name)
828 struct g_concat_softc *sc;
831 LIST_FOREACH(gp, &mp->geom, geom) {
835 if (strcmp(sc->sc_name, name) == 0)
842 g_concat_ctl_destroy(struct gctl_req *req, struct g_class *mp)
844 struct g_concat_softc *sc;
845 int *force, *nargs, error;
852 nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
854 gctl_error(req, "No '%s' argument.", "nargs");
858 gctl_error(req, "Missing device(s).");
861 force = gctl_get_paraml(req, "force", sizeof(*force));
863 gctl_error(req, "No '%s' argument.", "force");
867 for (i = 0; i < (u_int)*nargs; i++) {
868 snprintf(param, sizeof(param), "arg%u", i);
869 name = gctl_get_asciiparam(req, param);
871 gctl_error(req, "No 'arg%u' argument.", i);
874 sc = g_concat_find_device(mp, name);
876 gctl_error(req, "No such device: %s.", name);
879 error = g_concat_destroy(sc, *force);
881 gctl_error(req, "Cannot destroy device %s (error=%d).",
889 g_concat_config(struct gctl_req *req, struct g_class *mp, const char *verb)
895 version = gctl_get_paraml(req, "version", sizeof(*version));
896 if (version == NULL) {
897 gctl_error(req, "No '%s' argument.", "version");
900 if (*version != G_CONCAT_VERSION) {
901 gctl_error(req, "Userland and kernel parts are out of sync.");
905 if (strcmp(verb, "create") == 0) {
906 g_concat_ctl_create(req, mp);
908 } else if (strcmp(verb, "destroy") == 0 ||
909 strcmp(verb, "stop") == 0) {
910 g_concat_ctl_destroy(req, mp);
913 gctl_error(req, "Unknown verb.");
917 g_concat_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
918 struct g_consumer *cp, struct g_provider *pp)
920 struct g_concat_softc *sc;
928 } else if (cp != NULL) {
929 struct g_concat_disk *disk;
934 sbuf_printf(sb, "%s<End>%jd</End>\n", indent,
935 (intmax_t)disk->d_end);
936 sbuf_printf(sb, "%s<Start>%jd</Start>\n", indent,
937 (intmax_t)disk->d_start);
939 sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id);
940 sbuf_printf(sb, "%s<Type>", indent);
941 switch (sc->sc_type) {
942 case G_CONCAT_TYPE_AUTOMATIC:
943 sbuf_printf(sb, "AUTOMATIC");
945 case G_CONCAT_TYPE_MANUAL:
946 sbuf_printf(sb, "MANUAL");
949 sbuf_printf(sb, "UNKNOWN");
952 sbuf_printf(sb, "</Type>\n");
953 sbuf_printf(sb, "%s<Status>Total=%u, Online=%u</Status>\n",
954 indent, sc->sc_ndisks, g_concat_nvalid(sc));
955 sbuf_printf(sb, "%s<State>", indent);
956 if (sc->sc_provider != NULL && sc->sc_provider->error == 0)
957 sbuf_printf(sb, "UP");
959 sbuf_printf(sb, "DOWN");
960 sbuf_printf(sb, "</State>\n");
964 DECLARE_GEOM_CLASS(g_concat_class, g_concat);