diff --git a/sbin/geom/class/stripe/gstripe.8 b/sbin/geom/class/stripe/gstripe.8 index 59b0709afbf..9f3a2ba2adf 100644 --- a/sbin/geom/class/stripe/gstripe.8 +++ b/sbin/geom/class/stripe/gstripe.8 @@ -189,8 +189,8 @@ The following example shows how to set up striped device from four disks for automatic configuration, create a file system on it, and mount it: .Bd -literal -offset indent gstripe label -v -s 4096 data /dev/da0 /dev/da1 /dev/da2 /dev/da3 -newfs /dev/data.stripe -mount /dev/data.stripe /mnt +newfs /dev/stripe/data +mount /dev/stripe/data /mnt [...] umount /mnt gstripe stop data diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c index 68ace390250..9e642c0054e 100644 --- a/sys/geom/stripe/g_stripe.c +++ b/sys/geom/stripe/g_stripe.c @@ -162,13 +162,13 @@ g_stripe_remove_disk(struct g_consumer *cp) no = cp->index; G_STRIPE_DEBUG(0, "Disk %s removed from %s.", cp->provider->name, - sc->sc_geom->name); + sc->sc_name); sc->sc_disks[no] = NULL; if (sc->sc_provider != NULL) { g_orphan_provider(sc->sc_provider, ENXIO); sc->sc_provider = NULL; - G_STRIPE_DEBUG(0, "Device %s removed.", sc->sc_geom->name); + G_STRIPE_DEBUG(0, "Device %s removed.", sc->sc_name); } if (cp->acr > 0 || cp->acw > 0 || cp->ace > 0) @@ -607,7 +607,8 @@ g_stripe_check_and_run(struct g_stripe_softc *sc) if (g_stripe_nvalid(sc) != sc->sc_ndisks) return; - sc->sc_provider = g_new_providerf(sc->sc_geom, "%s", sc->sc_geom->name); + sc->sc_provider = g_new_providerf(sc->sc_geom, "stripe/%s", + sc->sc_name); /* * Find the smallest disk. */ @@ -630,7 +631,7 @@ g_stripe_check_and_run(struct g_stripe_softc *sc) sc->sc_provider->mediasize = mediasize * sc->sc_ndisks; g_error_provider(sc->sc_provider, 0); - G_STRIPE_DEBUG(0, "Device %s activated.", sc->sc_geom->name); + G_STRIPE_DEBUG(0, "Device %s activated.", sc->sc_name); } static int @@ -717,7 +718,7 @@ g_stripe_add_disk(struct g_stripe_softc *sc, struct g_provider *pp, u_int no) cp->index = no; sc->sc_disks[no] = cp; - G_STRIPE_DEBUG(0, "Disk %s attached to %s.", pp->name, gp->name); + G_STRIPE_DEBUG(0, "Disk %s attached to %s.", pp->name, sc->sc_name); g_stripe_check_and_run(sc); @@ -738,27 +739,24 @@ g_stripe_create(struct g_class *mp, const struct g_stripe_metadata *md, struct g_geom *gp; u_int no; - G_STRIPE_DEBUG(1, "Creating device %s.stripe (id=%u).", md->md_name, + G_STRIPE_DEBUG(1, "Creating device %s (id=%u).", md->md_name, md->md_id); /* Two disks is minimum. */ - if (md->md_all <= 1) { - G_STRIPE_DEBUG(0, "Too few disks defined for %s.stripe.", - md->md_name); + if (md->md_all < 2) { + G_STRIPE_DEBUG(0, "Too few disks defined for %s.", md->md_name); return (NULL); } #if 0 /* Stripe size have to be grater than or equal to sector size. */ if (md->md_stripesize < sectorsize) { - G_STRIPE_DEBUG(0, "Invalid stripe size for %s.stripe.", - md->md_name); + G_STRIPE_DEBUG(0, "Invalid stripe size for %s.", md->md_name); return (NULL); } #endif /* Stripe size have to be power of 2. */ if (!powerof2(md->md_stripesize)) { - G_STRIPE_DEBUG(0, "Invalid stripe size for %s.stripe.", - md->md_name); + G_STRIPE_DEBUG(0, "Invalid stripe size for %s.", md->md_name); return (NULL); } @@ -767,11 +765,11 @@ g_stripe_create(struct g_class *mp, const struct g_stripe_metadata *md, sc = gp->softc; if (sc != NULL && strcmp(sc->sc_name, md->md_name) == 0) { G_STRIPE_DEBUG(0, "Device %s already configured.", - gp->name); + sc->sc_name); return (NULL); } } - gp = g_new_geomf(mp, "%s.stripe", md->md_name); + gp = g_new_geomf(mp, "%s", md->md_name); gp->softc = NULL; /* for a moment */ sc = malloc(sizeof(*sc), M_STRIPE, M_WAITOK | M_ZERO); @@ -781,7 +779,6 @@ g_stripe_create(struct g_class *mp, const struct g_stripe_metadata *md, gp->access = g_stripe_access; gp->dumpconf = g_stripe_dumpconf; - strlcpy(sc->sc_name, md->md_name, sizeof(sc->sc_name)); sc->sc_id = md->md_id; sc->sc_stripesize = md->md_stripesize; sc->sc_stripebits = BITCOUNT(sc->sc_stripesize - 1); @@ -796,7 +793,7 @@ g_stripe_create(struct g_class *mp, const struct g_stripe_metadata *md, sc->sc_geom = gp; sc->sc_provider = NULL; - G_STRIPE_DEBUG(0, "Device %s created (id=%u).", gp->name, sc->sc_id); + G_STRIPE_DEBUG(0, "Device %s created (id=%u).", sc->sc_name, sc->sc_id); return (gp); } @@ -920,7 +917,7 @@ g_stripe_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) } else { gp = g_stripe_create(mp, &md, G_STRIPE_TYPE_AUTOMATIC); if (gp == NULL) { - G_STRIPE_DEBUG(0, "Cannot create device %s.stripe.", + G_STRIPE_DEBUG(0, "Cannot create device %s.", md.md_name); return (NULL); } @@ -1002,7 +999,7 @@ g_stripe_ctl_create(struct gctl_req *req, struct g_class *mp) gp = g_stripe_create(mp, &md, G_STRIPE_TYPE_MANUAL); if (gp == NULL) { - gctl_error(req, "Can't configure %s.stripe.", md.md_name); + gctl_error(req, "Can't configure %s.", md.md_name); return; } @@ -1042,10 +1039,8 @@ g_stripe_find_device(struct g_class *mp, const char *name) sc = gp->softc; if (sc == NULL) continue; - if (strcmp(gp->name, name) == 0 || - strcmp(sc->sc_name, name) == 0) { + if (strcmp(sc->sc_name, name) == 0) return (sc); - } } return (NULL); } @@ -1091,7 +1086,7 @@ g_stripe_ctl_destroy(struct gctl_req *req, struct g_class *mp) error = g_stripe_destroy(sc, *force); if (error != 0) { gctl_error(req, "Cannot destroy device %s (error=%d).", - sc->sc_geom->name, error); + sc->sc_name, error); return; } } diff --git a/sys/geom/stripe/g_stripe.h b/sys/geom/stripe/g_stripe.h index d176924a0b1..5f4edc9153d 100644 --- a/sys/geom/stripe/g_stripe.h +++ b/sys/geom/stripe/g_stripe.h @@ -64,13 +64,13 @@ struct g_stripe_softc { u_int sc_type; /* provider type */ struct g_geom *sc_geom; struct g_provider *sc_provider; - char sc_name[16]; /* stripe name */ uint32_t sc_id; /* stripe unique ID */ struct g_consumer **sc_disks; uint16_t sc_ndisks; uint32_t sc_stripesize; uint32_t sc_stripebits; }; +#define sc_name sc_geom->name #endif /* _KERNEL */ struct g_stripe_metadata { diff --git a/tools/regression/geom_stripe/test-1.sh b/tools/regression/geom_stripe/test-1.sh index c8d59ae5097..a5d4668bf94 100644 --- a/tools/regression/geom_stripe/test-1.sh +++ b/tools/regression/geom_stripe/test-1.sh @@ -13,7 +13,7 @@ gstripe create -s 16384 $name /dev/md${us} /dev/md`expr $us + 1` /dev/md`expr $u # Size of created device should be 1MB * 3. -size=`diskinfo /dev/${name}.stripe | awk '{print $3}'` +size=`diskinfo /dev/stripe/${name} | awk '{print $3}'` if [ $size -eq 3145728 ]; then echo "PASS" diff --git a/tools/regression/geom_stripe/test-2.sh b/tools/regression/geom_stripe/test-2.sh index 17c88341987..b78221de548 100644 --- a/tools/regression/geom_stripe/test-2.sh +++ b/tools/regression/geom_stripe/test-2.sh @@ -16,8 +16,8 @@ mdconfig -a -t malloc -s 3M -u `expr $us + 2` || exit 1 gstripe create -s 8192 $name /dev/md${us} /dev/md`expr $us + 1` /dev/md`expr $us + 2` || exit 1 -dd if=${src} of=/dev/${name}.stripe bs=1m count=$tsize >/dev/null 2>&1 -dd if=/dev/${name}.stripe of=${dst} bs=1m count=$tsize >/dev/null 2>&1 +dd if=${src} of=/dev/stripe/${name} bs=1m count=$tsize >/dev/null 2>&1 +dd if=/dev/stripe/${name} of=${dst} bs=1m count=$tsize >/dev/null 2>&1 if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then echo "FAIL"