summaryrefslogtreecommitdiffstats
path: root/sys/geom/nop
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-07-30 08:19:22 +0000
committerpjd <pjd@FreeBSD.org>2004-07-30 08:19:22 +0000
commit7a7cae7b301959b58ccdd024218b041284190951 (patch)
tree066eb7f5148319fa4f307bc25eef6c3efdd8d8a8 /sys/geom/nop
parent4f6d0f295349dcdd675bb247fbaa2280c293115a (diff)
downloadFreeBSD-src-7a7cae7b301959b58ccdd024218b041284190951.zip
FreeBSD-src-7a7cae7b301959b58ccdd024218b041284190951.tar.gz
- Add '-S' option, which allow to specify sector size for transparent
provider. - Bump version number. This allows for a quite interesting trick. One can setup a stripe with stripe size of 512 bytes and create transparent provider on top of it with sector size equal to <ndisks> * 512. The result will be something like RAID3 without parity disk (every access will touch all disks).
Diffstat (limited to 'sys/geom/nop')
-rw-r--r--sys/geom/nop/g_nop.c23
-rw-r--r--sys/geom/nop/g_nop.h2
2 files changed, 20 insertions, 5 deletions
diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c
index 88283ee..c9e53ea 100644
--- a/sys/geom/nop/g_nop.c
+++ b/sys/geom/nop/g_nop.c
@@ -121,7 +121,7 @@ g_nop_access(struct g_provider *pp, int dr, int dw, int de)
static int
g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
- u_int failprob, off_t offset, off_t size)
+ u_int failprob, off_t offset, off_t size, u_int secsize)
{
struct g_nop_softc *sc;
struct g_geom *gp;
@@ -154,6 +154,12 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
gctl_error(req, "Invalid size for provider %s.", pp->name);
return (EINVAL);
}
+ if (secsize == 0)
+ secsize = pp->sectorsize;
+ else if ((secsize % pp->sectorsize) != 0) {
+ gctl_error(req, "Invalid secsize for provider %s.", pp->name);
+ 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) {
@@ -183,7 +189,7 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
goto fail;
}
newpp->mediasize = size;
- newpp->sectorsize = pp->sectorsize;
+ newpp->sectorsize = secsize;
cp = g_new_consumer(gp);
if (cp == NULL) {
@@ -253,7 +259,7 @@ static void
g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
{
struct g_provider *pp;
- intmax_t *failprob, *offset, *size;
+ intmax_t *failprob, *offset, *secsize, *size;
const char *name;
char param[16];
int i, *nargs;
@@ -296,6 +302,15 @@ g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
gctl_error(req, "Invalid '%s' argument", "size");
return;
}
+ secsize = gctl_get_paraml(req, "secsize", sizeof(*secsize));
+ if (secsize == NULL) {
+ gctl_error(req, "No '%s' argument", "secsize");
+ return;
+ }
+ if (*secsize < 0) {
+ gctl_error(req, "Invalid '%s' argument", "secsize");
+ return;
+ }
for (i = 0; i < *nargs; i++) {
snprintf(param, sizeof(param), "arg%d", i);
@@ -313,7 +328,7 @@ g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
return;
}
if (g_nop_create(req, mp, pp, (u_int)*failprob, (off_t)*offset,
- (off_t)*size) != 0) {
+ (off_t)*size, (u_int)*secsize) != 0) {
return;
}
}
diff --git a/sys/geom/nop/g_nop.h b/sys/geom/nop/g_nop.h
index cb9f38d..378c3ef 100644
--- a/sys/geom/nop/g_nop.h
+++ b/sys/geom/nop/g_nop.h
@@ -30,7 +30,7 @@
#define _G_NOP_H_
#define G_NOP_CLASS_NAME "NOP"
-#define G_NOP_VERSION 2
+#define G_NOP_VERSION 3
#define G_NOP_SUFFIX ".nop"
#ifdef _KERNEL
OpenPOWER on IntegriCloud