Date: Sun, 17 Jan 2010 06:20:31 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r202454 - in head: lib/libgeom sbin/geom/core sys/geom Message-ID: <201001170620.o0H6KVUJ032434@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Sun Jan 17 06:20:30 2010 New Revision: 202454 URL: http://svn.freebsd.org/changeset/base/202454 Log: Expose stripe offset and stripe size through libgeom and geom(8) userland utilities. Reviewed by: pjd, mav (earlier version) Modified: head/lib/libgeom/geom_util.c head/lib/libgeom/geom_xml2tree.c head/lib/libgeom/libgeom.3 head/lib/libgeom/libgeom.h head/sbin/geom/core/geom.c head/sys/geom/geom_dump.c Modified: head/lib/libgeom/geom_util.c ============================================================================== --- head/lib/libgeom/geom_util.c Sat Jan 16 20:51:33 2010 (r202453) +++ head/lib/libgeom/geom_util.c Sun Jan 17 06:20:30 2010 (r202454) @@ -114,6 +114,32 @@ g_sectorsize(int fd) } /* + * Return stripe size of the given provider. + */ +off_t +g_stripesize(int fd) +{ + off_t stripesize; + + if (g_ioctl_arg(fd, DIOCGSTRIPESIZE, &stripesize) == -1) + return (-1); + return (stripesize); +} + +/* + * Return stripe size of the given provider. + */ +off_t +g_stripeoffset(int fd) +{ + off_t stripeoffset; + + if (g_ioctl_arg(fd, DIOCGSTRIPEOFFSET, &stripeoffset) == -1) + return (-1); + return (stripeoffset); +} + +/* * Return the correct provider name. */ char * Modified: head/lib/libgeom/geom_xml2tree.c ============================================================================== --- head/lib/libgeom/geom_xml2tree.c Sat Jan 16 20:51:33 2010 (r202453) +++ head/lib/libgeom/geom_xml2tree.c Sun Jan 17 06:20:30 2010 (r202454) @@ -230,6 +230,16 @@ EndElement(void *userData, const char *n free(p); return; } + if (!strcmp(name, "stripesize") && mt->provider != NULL) { + mt->provider->lg_stripesize = strtoumax(p, NULL, 0); + free(p); + return; + } + if (!strcmp(name, "stripeoffset") && mt->provider != NULL) { + mt->provider->lg_stripeoffset = strtoumax(p, NULL, 0); + free(p); + return; + } if (!strcmp(name, "config")) { mt->config = NULL; Modified: head/lib/libgeom/libgeom.3 ============================================================================== --- head/lib/libgeom/libgeom.3 Sat Jan 16 20:51:33 2010 (r202453) +++ head/lib/libgeom/libgeom.3 Sun Jan 17 06:20:30 2010 (r202454) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 8, 2008 +.Dd January 16, 2010 .Dt LIBGEOM 3 .Os .Sh NAME @@ -50,6 +50,8 @@ .Nm g_close , .Nm g_mediasize , .Nm g_sectorsize , +.Nm g_stripeoffset , +.Nm g_stripesize , .Nm g_flush , .Nm g_delete , .Nm g_device_path , @@ -101,6 +103,10 @@ .Fn g_mediasize "int fd" .Ft ssize_t .Fn g_sectorsize "int fd" +.Ft ssize_t +.Fn g_stripeoffset "int fd" +.Ft ssize_t +.Fn g_stripesize "int fd" .Ft int .Fn g_flush "int fd" .Ft int @@ -297,6 +303,14 @@ The function returns sector size of the given provider. .Pp The +.Fn g_stripeoffset +function returns stripe size of the given provider. +.Pp +The +.Fn g_stripesize +function returns stripe size of the given provider. +.Pp +The .Fn g_flush function sends .Dv BIO_FLUSH Modified: head/lib/libgeom/libgeom.h ============================================================================== --- head/lib/libgeom/libgeom.h Sat Jan 16 20:51:33 2010 (r202453) +++ head/lib/libgeom/libgeom.h Sun Jan 17 06:20:30 2010 (r202454) @@ -123,6 +123,8 @@ struct gprovider { char *lg_mode; off_t lg_mediasize; u_int lg_sectorsize; + off_t lg_stripeoffset; + off_t lg_stripesize; struct gconf lg_config; }; @@ -149,6 +151,8 @@ int g_open(const char *, int); int g_close(int); off_t g_mediasize(int); ssize_t g_sectorsize(int); +off_t g_stripeoffset(int); +off_t g_stripesize(int); int g_flush(int); int g_delete(int, off_t, off_t); int g_get_ident(int, char *, size_t); Modified: head/sbin/geom/core/geom.c ============================================================================== --- head/sbin/geom/core/geom.c Sat Jan 16 20:51:33 2010 (r202453) +++ head/sbin/geom/core/geom.c Sun Jan 17 06:20:30 2010 (r202454) @@ -772,6 +772,10 @@ list_one_provider(struct gprovider *pp, printf("%sMediasize: %jd (%s)\n", prefix, (intmax_t)pp->lg_mediasize, buf); printf("%sSectorsize: %u\n", prefix, pp->lg_sectorsize); + if (pp->lg_stripesize > 0) { + printf("%sStripesize: %ju\n", prefix, pp->lg_stripesize); + printf("%sStripeoffset: %ju\n", prefix, pp->lg_stripeoffset); + } printf("%sMode: %s\n", prefix, pp->lg_mode); LIST_FOREACH(conf, &pp->lg_config, lg_config) { printf("%s%s: %s\n", prefix, conf->lg_name, conf->lg_val); @@ -796,6 +800,10 @@ list_one_consumer(struct gconsumer *cp, printf("%sMediasize: %jd (%s)\n", prefix, (intmax_t)pp->lg_mediasize, buf); printf("%sSectorsize: %u\n", prefix, pp->lg_sectorsize); + if (pp->lg_stripesize > 0) { + printf("%sStripesize: %ju\n", prefix, pp->lg_stripesize); + printf("%sStripeoffset: %ju\n", prefix, pp->lg_stripeoffset); + } printf("%sMode: %s\n", prefix, cp->lg_mode); } LIST_FOREACH(conf, &cp->lg_config, lg_config) { Modified: head/sys/geom/geom_dump.c ============================================================================== --- head/sys/geom/geom_dump.c Sat Jan 16 20:51:33 2010 (r202453) +++ head/sys/geom/geom_dump.c Sun Jan 17 06:20:30 2010 (r202454) @@ -185,6 +185,10 @@ g_conf_provider(struct sbuf *sb, struct sbuf_printf(sb, "\t <mediasize>%jd</mediasize>\n", (intmax_t)pp->mediasize); sbuf_printf(sb, "\t <sectorsize>%u</sectorsize>\n", pp->sectorsize); + if (pp->stripesize > 0) { + sbuf_printf(sb, "\t <stripesize>%u</stripesize>\n", pp->stripesize); + sbuf_printf(sb, "\t <stripeoffset>%u</stripeoffset>\n", pp->stripeoffset); + } if (pp->geom->flags & G_GEOM_WITHER) ; else if (pp->geom->dumpconf != NULL) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001170620.o0H6KVUJ032434>