aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMatthew D Fleming <mdf@FreeBSD.org>2011-05-13 18:48:00 +0000
committerMatthew D Fleming <mdf@FreeBSD.org>2011-05-13 18:48:00 +0000
commit89cb2a19ec7be4fe31ba6463ecda4c16ea748afe (patch)
treebe49b4c2fcfd4fd77e11fc14e3d844673d1cfd02 /sys/dev
parent14f9771b27f470896789fa3d250743a9380621af (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/md/md.c8
-rw-r--r--sys/dev/null/null.c17
2 files changed, 14 insertions, 11 deletions
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 79bf19c4e5b2..71d036580cb2 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -205,9 +205,6 @@ struct md_s {
vm_object_t object;
};
-/* Used for BIO_DELETE on MD_VNODE */
-static u_char zero[PAGE_SIZE];
-
static struct indir *
new_indir(u_int shift)
{
@@ -560,7 +557,8 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
* that the two cases end up having very little in common.
*/
if (bp->bio_cmd == BIO_DELETE) {
- zerosize = sizeof(zero) - (sizeof(zero) % sc->sectorsize);
+ zerosize = ZERO_REGION_SIZE -
+ (ZERO_REGION_SIZE % sc->sectorsize);
auio.uio_iov = &aiov;
auio.uio_iovcnt = 1;
auio.uio_offset = (vm_ooffset_t)bp->bio_offset;
@@ -573,7 +571,7 @@ mdstart_vnode(struct md_s *sc, struct bio *bp)
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
error = 0;
while (auio.uio_offset < end) {
- aiov.iov_base = zero;
+ aiov.iov_base = __DECONST(void *, zero_region);
aiov.iov_len = end - auio.uio_offset;
if (aiov.iov_len > zerosize)
aiov.iov_len = zerosize;
diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c
index 3005c19ccbf4..04619b26d6b5 100644
--- a/sys/dev/null/null.c
+++ b/sys/dev/null/null.c
@@ -65,8 +65,6 @@ static struct cdevsw zero_cdevsw = {
.d_flags = D_MMAP_ANON,
};
-static void *zbuf;
-
/* ARGSUSED */
static int
null_write(struct cdev *dev __unused, struct uio *uio, int flags __unused)
@@ -95,10 +93,19 @@ null_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data __unused,
static int
zero_read(struct cdev *dev __unused, struct uio *uio, int flags __unused)
{
+ void *zbuf;
+ ssize_t len;
int error = 0;
- while (uio->uio_resid > 0 && error == 0)
- error = uiomove(zbuf, MIN(uio->uio_resid, PAGE_SIZE), uio);
+ KASSERT(uio->uio_rw == UIO_READ,
+ ("Can't be in %s for write", __func__));
+ zbuf = __DECONST(void *, zero_region);
+ while (uio->uio_resid > 0 && error == 0) {
+ len = uio->uio_resid;
+ if (len > ZERO_REGION_SIZE)
+ len = ZERO_REGION_SIZE;
+ error = uiomove(zbuf, len, uio);
+ }
return (error);
}
@@ -111,7 +118,6 @@ null_modevent(module_t mod __unused, int type, void *data __unused)
case MOD_LOAD:
if (bootverbose)
printf("null: <null device, zero device>\n");
- zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO);
null_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &null_cdevsw, 0,
NULL, UID_ROOT, GID_WHEEL, 0666, "null");
zero_dev = make_dev_credf(MAKEDEV_ETERNAL_KLD, &zero_cdevsw, 0,
@@ -121,7 +127,6 @@ null_modevent(module_t mod __unused, int type, void *data __unused)
case MOD_UNLOAD:
destroy_dev(null_dev);
destroy_dev(zero_dev);
- free(zbuf, M_TEMP);
break;
case MOD_SHUTDOWN: