summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_bio.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-12-10 05:14:04 +0000
committerkib <kib@FreeBSD.org>2012-12-10 05:14:04 +0000
commitd4cecb240caca2c96da882bd13f442396df68816 (patch)
tree1abbbaa1e0cec23fe4813c9d767d52ff8ab2db1c /sys/kern/vfs_bio.c
parent641397eb9a7e8ad64ec02351d1a77decf3be058e (diff)
downloadFreeBSD-src-d4cecb240caca2c96da882bd13f442396df68816.zip
FreeBSD-src-d4cecb240caca2c96da882bd13f442396df68816.tar.gz
Do not ignore zero address, possibly returned by the vm_map_find()
call. The function indicates a failure by the TRUE return value. To be extra safe, assert that the return value from the following vm_map_insert() indicates success. Fix style issues in the nearby lines, reformulate the comment. Reviewed by: alc (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'sys/kern/vfs_bio.c')
-rw-r--r--sys/kern/vfs_bio.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 7c28a22..32a1089 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -2107,15 +2107,16 @@ restart:
if (maxsize != bp->b_kvasize) {
vm_offset_t addr = 0;
+ int rv;
bfreekva(bp);
vm_map_lock(buffer_map);
if (vm_map_findspace(buffer_map,
- vm_map_min(buffer_map), maxsize, &addr)) {
+ vm_map_min(buffer_map), maxsize, &addr)) {
/*
- * Uh oh. Buffer map is to fragmented. We
- * must defragment the map.
+ * Buffer map is too fragmented.
+ * We must defragment the map.
*/
atomic_add_int(&bufdefragcnt, 1);
vm_map_unlock(buffer_map);
@@ -2124,22 +2125,21 @@ restart:
brelse(bp);
goto restart;
}
- if (addr) {
- vm_map_insert(buffer_map, NULL, 0,
- addr, addr + maxsize,
- VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT);
-
- bp->b_kvabase = (caddr_t) addr;
- bp->b_kvasize = maxsize;
- atomic_add_long(&bufspace, bp->b_kvasize);
- atomic_add_int(&bufreusecnt, 1);
- }
+ rv = vm_map_insert(buffer_map, NULL, 0, addr,
+ addr + maxsize, VM_PROT_ALL, VM_PROT_ALL,
+ MAP_NOFAULT);
+ KASSERT(rv == KERN_SUCCESS,
+ ("vm_map_insert(buffer_map) rv %d", rv));
vm_map_unlock(buffer_map);
+ bp->b_kvabase = (caddr_t)addr;
+ bp->b_kvasize = maxsize;
+ atomic_add_long(&bufspace, bp->b_kvasize);
+ atomic_add_int(&bufreusecnt, 1);
}
bp->b_saveaddr = bp->b_kvabase;
bp->b_data = bp->b_saveaddr;
}
- return(bp);
+ return (bp);
}
/*
OpenPOWER on IntegriCloud