summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2011-04-06 02:00:11 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2011-04-06 02:00:11 +0000
commitc06861e0bd84e3c3cd49b2962f1ce3f5cf7c1f4a (patch)
tree61ace8cd2adf9f2ebd4bbc72e689f2bbac7e56a4 /sys/dev
parent038e81da93182c99ba13cf85c6ceafd4e5db0a69 (diff)
handle bigmem for metadata reads and writes. this should be pre allocated
but for now this allows us to move forward.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/softraid.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 0a756f68e9f..86bd2f1e038 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.223 2011/04/05 19:52:02 krw Exp $ */
+/* $OpenBSD: softraid.c,v 1.224 2011/04/06 02:00:10 marco Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Marco Peereboom <marco@peereboom.us>
* Copyright (c) 2008 Chris Kuethe <ckuethe@openbsd.org>
@@ -394,20 +394,27 @@ sr_rw(struct sr_softc *sc, dev_t dev, char *buf, size_t size, daddr64_t offset,
{
struct vnode *vp;
struct buf b;
- size_t bufsize;
+ size_t bufsize, bs;
int rv = 1;
+ char *dma_buf, *db;
DNPRINTF(SR_D_MISC, "%s: sr_rw(0x%x, %p, %d, %llu 0x%x)\n",
DEVNAME(sc), dev, buf, size, offset, flags);
+ /* XXX this should be pre allocated */
+ bs = size;
+ db = dma_buf = dma_alloc(size, PR_WAITOK);
+ if (flags == B_WRITE)
+ bcopy(buf, db, bs);
+
if (bdevvp(dev, &vp)) {
printf("%s: sr_rw: failed to allocate vnode\n", DEVNAME(sc));
goto done;
}
while (size > 0) {
- DNPRINTF(SR_D_MISC, "%s: buf %p, size %d, offset %llu)\n",
- DEVNAME(sc), buf, size, offset);
+ DNPRINTF(SR_D_MISC, "%s: dma_buf %p, size %d, offset %llu)\n",
+ DEVNAME(sc), dma_buf, size, offset);
bufsize = (size > MAXPHYS) ? MAXPHYS : size;
@@ -419,7 +426,7 @@ sr_rw(struct sr_softc *sc, dev_t dev, char *buf, size_t size, daddr64_t offset,
b.b_iodone = NULL;
b.b_error = 0;
b.b_blkno = offset;
- b.b_data = buf;
+ b.b_data = dma_buf;
b.b_bcount = bufsize;
b.b_bufsize = bufsize;
b.b_resid = bufsize;
@@ -439,17 +446,22 @@ sr_rw(struct sr_softc *sc, dev_t dev, char *buf, size_t size, daddr64_t offset,
}
size -= bufsize;
- buf += bufsize;
+ dma_buf += bufsize;
offset += howmany(bufsize, DEV_BSIZE);
}
+ if (flags == B_READ)
+ bcopy(db, buf, bs);
+
rv = 0;
done:
if (vp)
vput(vp);
+ dma_free(db, bs);
+
return (rv);
}