summaryrefslogtreecommitdiffstats
path: root/sys/dev/md/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/md/md.c')
-rw-r--r--sys/dev/md/md.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index a2c7a78..dccd5b3 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -911,6 +911,22 @@ mdstart_swap(struct md_s *sc, struct bio *bp)
return (rv != VM_PAGER_ERROR ? 0 : ENOSPC);
}
+static int
+mdstart_null(struct md_s *sc, struct bio *bp)
+{
+
+ switch (bp->bio_cmd) {
+ case BIO_READ:
+ bzero(bp->bio_data, bp->bio_length);
+ cpu_flush_dcache(bp->bio_data, bp->bio_length);
+ break;
+ case BIO_WRITE:
+ break;
+ }
+ bp->bio_resid = 0;
+ return (0);
+}
+
static void
md_kthread(void *arg)
{
@@ -1030,6 +1046,7 @@ mdinit(struct md_s *sc)
pp->flags |= G_PF_ACCEPT_UNMAPPED;
break;
case MD_PRELOAD:
+ case MD_NULL:
break;
}
sc->gp = gp;
@@ -1248,6 +1265,7 @@ mdresize(struct md_s *sc, struct md_ioctl *mdio)
switch (sc->type) {
case MD_VNODE:
+ case MD_NULL:
break;
case MD_SWAP:
if (mdio->md_mediasize <= 0 ||
@@ -1342,6 +1360,19 @@ mdcreate_swap(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
return (error);
}
+static int
+mdcreate_null(struct md_s *sc, struct md_ioctl *mdio, struct thread *td)
+{
+
+ /*
+ * Range check. Disallow negative sizes or any size less then the
+ * size of a page. Then round to a page.
+ */
+ if (sc->mediasize <= 0 || (sc->mediasize % PAGE_SIZE) != 0)
+ return (EDOM);
+
+ return (0);
+}
static int
xmdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
@@ -1374,6 +1405,7 @@ xmdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread
case MD_PRELOAD:
case MD_VNODE:
case MD_SWAP:
+ case MD_NULL:
break;
default:
return (EINVAL);
@@ -1419,6 +1451,10 @@ xmdctlioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thread
sc->start = mdstart_swap;
error = mdcreate_swap(sc, mdio, td);
break;
+ case MD_NULL:
+ sc->start = mdstart_null;
+ error = mdcreate_null(sc, mdio, td);
+ break;
}
if (error != 0) {
mddestroy(sc, td);
@@ -1589,6 +1625,9 @@ g_md_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
case MD_SWAP:
type = "swap";
break;
+ case MD_NULL:
+ type = "null";
+ break;
default:
type = "unknown";
break;
OpenPOWER on IntegriCloud