svn commit: r217193 - in projects/graid/head: sbin/geom/class/raid sys/geom/raid

Alexander Motin mav at FreeBSD.org
Sun Jan 9 13:23:45 UTC 2011


Author: mav
Date: Sun Jan  9 13:23:45 2011
New Revision: 217193
URL: http://svn.freebsd.org/changeset/base/217193

Log:
  Add options to specify volume and strip sizes.

Modified:
  projects/graid/head/sbin/geom/class/raid/geom_raid.c
  projects/graid/head/sys/geom/raid/md_intel.c

Modified: projects/graid/head/sbin/geom/class/raid/geom_raid.c
==============================================================================
--- projects/graid/head/sbin/geom/class/raid/geom_raid.c	Sun Jan  9 12:50:44 2011	(r217192)
+++ projects/graid/head/sbin/geom/class/raid/geom_raid.c	Sun Jan  9 13:23:45 2011	(r217193)
@@ -51,8 +51,13 @@ uint32_t version = G_RAID_VERSION;
 //static void raid_main(struct gctl_req *req, unsigned flags);
 
 struct g_command class_commands[] = {
-	{ "label", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
-	    "format name level prov ..."
+	{ "label", G_FLAG_VERBOSE, NULL,
+	    {
+		{ 'S', "size", G_VAL_OPTIONAL, G_TYPE_NUMBER },
+		{ 's', "strip", G_VAL_OPTIONAL, G_TYPE_NUMBER },
+		G_OPT_SENTINEL
+	    },
+	    "[-S size] [-s stripsize] format name level prov ..."
 	},
 	{ "stop", G_FLAG_VERBOSE, NULL,
 	    {

Modified: projects/graid/head/sys/geom/raid/md_intel.c
==============================================================================
--- projects/graid/head/sys/geom/raid/md_intel.c	Sun Jan  9 12:50:44 2011	(r217192)
+++ projects/graid/head/sys/geom/raid/md_intel.c	Sun Jan  9 13:23:45 2011	(r217193)
@@ -793,8 +793,9 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
 	char arg[16];
 	const char *verb, *volname, *levelname, *diskname;
 	int *nargs;
-	uint64_t size, sectorsize;
-	int numdisks, i, level, qual;
+	uint64_t size, sectorsize, strip;
+	intmax_t *sizearg, *striparg;
+	int numdisks, i, len, level, qual;
 	int error;
 
 	sc = md->mdo_softc;
@@ -912,7 +913,36 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
 		/* Reserve some space for metadata. */
 		size -= (4096 + sectorsize - 1) / sectorsize + 1;
 
-		size &= ~127;	/* Assume stripe size 64K */
+		len = sizeof(*sizearg);
+		sizearg = gctl_get_param(req, "size", &len);
+		if (sizearg != NULL && len == sizeof(*sizearg)) {
+			if (*sizearg / sectorsize > size) {
+				gctl_error(req, "Size too big.");
+				return (-9);
+			}
+			size = *sizearg / sectorsize;
+		}
+
+		strip = 256;
+		len = sizeof(*striparg);
+		striparg = gctl_get_param(req, "strip", &len);
+		if (striparg != NULL && len == sizeof(*striparg)) {
+			if (*striparg < sectorsize) {
+				gctl_error(req, "Strip size too small.");
+				return (-10);
+			}
+			if (*striparg % sectorsize != 0) {
+				gctl_error(req, "Incorrect strip size.");
+				return (-11);
+			}
+			strip = *striparg / sectorsize;
+			if (strip >= 65536) {
+				gctl_error(req, "Strip size too big.");
+				return (-12);
+			}
+		}
+
+		size -= (size % strip);
 		mvol = intel_get_volume(meta, 0);
 		strlcpy(&mvol->name[0], volname, sizeof(mvol->name));
 		if (level == G_RAID_VOLUME_RL_RAID0)
@@ -924,8 +954,8 @@ g_raid_md_ctl_intel(struct g_raid_md_obj
 		mmap = intel_get_map(mvol, 0);
 		mmap->offset = 0;
 		mmap->disk_sectors = size;
-		mmap->stripe_count = size / 128;
-		mmap->stripe_sectors = 128;
+		mmap->stripe_count = size / strip;
+		mmap->stripe_sectors = strip;
 		mmap->status = INTEL_S_READY;
 		if (level == G_RAID_VOLUME_RL_RAID0)
 			mmap->type = INTEL_T_RAID0;


More information about the svn-src-projects mailing list