Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Oct 2015 15:02:07 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r289520 - in stable/10: sbin/geom/class/nop sys/geom/nop
Message-ID:  <201510181502.t9IF27E1001950@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sun Oct 18 15:02:07 2015
New Revision: 289520
URL: https://svnweb.freebsd.org/changeset/base/289520

Log:
  MFC r287827:
  
  Add a way to specify stripesize and stripeoffset to gnop(8). This makes
  it possible to "simulate" 4K media, to eg test alignment handling.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  stable/10/sbin/geom/class/nop/geom_nop.c
  stable/10/sbin/geom/class/nop/gnop.8
  stable/10/sys/geom/nop/g_nop.c
  stable/10/sys/geom/nop/g_nop.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/geom/class/nop/geom_nop.c
==============================================================================
--- stable/10/sbin/geom/class/nop/geom_nop.c	Sun Oct 18 14:59:38 2015	(r289519)
+++ stable/10/sbin/geom/class/nop/geom_nop.c	Sun Oct 18 15:02:07 2015	(r289520)
@@ -43,14 +43,16 @@ struct g_command class_commands[] = {
 	    {
 		{ 'e', "error", "-1", G_TYPE_NUMBER },
 		{ 'o', "offset", "0", G_TYPE_NUMBER },
+		{ 'p', "stripesize", "0", G_TYPE_NUMBER },
+		{ 'P', "stripeoffset", "0", G_TYPE_NUMBER },
 		{ 'r', "rfailprob", "-1", G_TYPE_NUMBER },
 		{ 's', "size", "0", G_TYPE_NUMBER },
 		{ 'S', "secsize", "0", G_TYPE_NUMBER },
 		{ 'w', "wfailprob", "-1", G_TYPE_NUMBER },
 		G_OPT_SENTINEL
 	    },
-	    "[-v] [-e error] [-o offset] [-r rfailprob] [-s size] "
-	    "[-S secsize] [-w wfailprob] dev ..."
+	    "[-v] [-e error] [-o offset] [-p stripesize] [-P stripeoffset] "
+	    "[-r rfailprob] [-s size] [-S secsize] [-w wfailprob] dev ..."
 	},
 	{ "configure", G_FLAG_VERBOSE, NULL,
 	    {

Modified: stable/10/sbin/geom/class/nop/gnop.8
==============================================================================
--- stable/10/sbin/geom/class/nop/gnop.8	Sun Oct 18 14:59:38 2015	(r289519)
+++ stable/10/sbin/geom/class/nop/gnop.8	Sun Oct 18 15:02:07 2015	(r289520)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 14, 2013
+.Dd September 15, 2015
 .Dt GNOP 8
 .Os
 .Sh NAME
@@ -36,6 +36,8 @@
 .Op Fl v
 .Op Fl e Ar error
 .Op Fl o Ar offset
+.Op Fl p Ar stripesize
+.Op Fl P Ar stripeoffset
 .Op Fl r Ar rfailprob
 .Op Fl s Ar size
 .Op Fl S Ar secsize
@@ -115,6 +117,10 @@ Specifies the error number to return on 
 Force the removal of the specified provider.
 .It Fl o Ar offset
 Where to begin on the original provider.
+.It Fl p Ar stripesize
+Value of the stripesize property of the transparent provider.
+.It Fl P Ar stripeoffset
+Value of the stripeoffset property of the transparent provider.
 .It Fl r Ar rfailprob
 Specifies read failure probability in percent.
 .It Fl s Ar size

Modified: stable/10/sys/geom/nop/g_nop.c
==============================================================================
--- stable/10/sys/geom/nop/g_nop.c	Sun Oct 18 14:59:38 2015	(r289519)
+++ stable/10/sys/geom/nop/g_nop.c	Sun Oct 18 15:02:07 2015	(r289520)
@@ -162,7 +162,7 @@ g_nop_access(struct g_provider *pp, int 
 static int
 g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
     int ioerror, u_int rfailprob, u_int wfailprob, off_t offset, off_t size,
-    u_int secsize)
+    u_int secsize, u_int stripesize, u_int stripeoffset)
 {
 	struct g_nop_softc *sc;
 	struct g_geom *gp;
@@ -208,6 +208,18 @@ g_nop_create(struct gctl_req *req, struc
 		return (EINVAL);
 	}
 	size -= size % secsize;
+	if ((stripesize % pp->sectorsize) != 0) {
+		gctl_error(req, "Invalid stripesize for provider %s.", pp->name);
+		return (EINVAL);
+	}
+	if ((stripeoffset % pp->sectorsize) != 0) {
+		gctl_error(req, "Invalid stripeoffset for provider %s.", pp->name);
+		return (EINVAL);
+	}
+	if (stripesize != 0 && stripeoffset >= stripesize) {
+		gctl_error(req, "stripeoffset is too big.");
+		return (EINVAL);
+	}
 	snprintf(name, sizeof(name), "%s%s", pp->name, G_NOP_SUFFIX);
 	LIST_FOREACH(gp, &mp->geom, geom) {
 		if (strcmp(gp->name, name) == 0) {
@@ -219,6 +231,8 @@ g_nop_create(struct gctl_req *req, struc
 	sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
 	sc->sc_offset = offset;
 	sc->sc_explicitsize = explicitsize;
+	sc->sc_stripesize = stripesize;
+	sc->sc_stripeoffset = stripeoffset;
 	sc->sc_error = ioerror;
 	sc->sc_rfailprob = rfailprob;
 	sc->sc_wfailprob = wfailprob;
@@ -238,6 +252,8 @@ g_nop_create(struct gctl_req *req, struc
 	newpp->flags |= G_PF_DIRECT_SEND | G_PF_DIRECT_RECEIVE;
 	newpp->mediasize = size;
 	newpp->sectorsize = secsize;
+	newpp->stripesize = stripesize;
+	newpp->stripeoffset = stripeoffset;
 
 	cp = g_new_consumer(gp);
 	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
@@ -304,7 +320,8 @@ static void
 g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
 {
 	struct g_provider *pp;
-	intmax_t *error, *rfailprob, *wfailprob, *offset, *secsize, *size;
+	intmax_t *error, *rfailprob, *wfailprob, *offset, *secsize, *size,
+	    *stripesize, *stripeoffset;
 	const char *name;
 	char param[16];
 	int i, *nargs;
@@ -370,6 +387,24 @@ g_nop_ctl_create(struct gctl_req *req, s
 		gctl_error(req, "Invalid '%s' argument", "secsize");
 		return;
 	}
+	stripesize = gctl_get_paraml(req, "stripesize", sizeof(*stripesize));
+	if (stripesize == NULL) {
+		gctl_error(req, "No '%s' argument", "stripesize");
+		return;
+	}
+	if (*stripesize < 0) {
+		gctl_error(req, "Invalid '%s' argument", "stripesize");
+		return;
+	}
+	stripeoffset = gctl_get_paraml(req, "stripeoffset", sizeof(*stripeoffset));
+	if (stripeoffset == NULL) {
+		gctl_error(req, "No '%s' argument", "stripeoffset");
+		return;
+	}
+	if (*stripeoffset < 0) {
+		gctl_error(req, "Invalid '%s' argument", "stripeoffset");
+		return;
+	}
 
 	for (i = 0; i < *nargs; i++) {
 		snprintf(param, sizeof(param), "arg%d", i);
@@ -390,7 +425,8 @@ g_nop_ctl_create(struct gctl_req *req, s
 		    *error == -1 ? EIO : (int)*error,
 		    *rfailprob == -1 ? 0 : (u_int)*rfailprob,
 		    *wfailprob == -1 ? 0 : (u_int)*wfailprob,
-		    (off_t)*offset, (off_t)*size, (u_int)*secsize) != 0) {
+		    (off_t)*offset, (off_t)*size, (u_int)*secsize,
+		    (u_int)*stripesize, (u_int)*stripeoffset) != 0) {
 			return;
 		}
 	}

Modified: stable/10/sys/geom/nop/g_nop.h
==============================================================================
--- stable/10/sys/geom/nop/g_nop.h	Sun Oct 18 14:59:38 2015	(r289519)
+++ stable/10/sys/geom/nop/g_nop.h	Sun Oct 18 15:02:07 2015	(r289520)
@@ -59,6 +59,8 @@ struct g_nop_softc {
 	int		sc_error;
 	off_t		sc_offset;
 	off_t		sc_explicitsize;
+	off_t		sc_stripesize;
+	off_t		sc_stripeoffset;
 	u_int		sc_rfailprob;
 	u_int		sc_wfailprob;
 	uintmax_t	sc_reads;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201510181502.t9IF27E1001950>