diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2013-06-11 21:51:56 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2013-06-11 21:51:56 +0000 |
commit | cd87a702480f32ec4a472de5f0a77858ae410181 (patch) | |
tree | cd76d2922f4c6bb4be02de31d56b65fb5b6ce3c0 /sys/kern | |
parent | 1aa094ff74fcf42f3745741419a8609e573826b5 (diff) |
sprinkle knf fairy dust over new buf code
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_sysctl.c | 10 | ||||
-rw-r--r-- | sys/kern/vfs_bio.c | 30 | ||||
-rw-r--r-- | sys/kern/vfs_biomem.c | 3 |
3 files changed, 22 insertions, 21 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 094720abbea..acb3aa89de7 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.237 2013/06/11 19:01:20 beck Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.238 2013/06/11 21:51:55 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -579,10 +579,10 @@ kern_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (EINVAL); } if (bufcachepercent != opct) { - pgs = (b_highpages_total + b_dmapages_total) - * bufcachepercent / 100; - b_dmamaxpages = b_dmapages_total * bufcachepercent - / 100; + pgs = (b_highpages_total + b_dmapages_total) * + bufcachepercent / 100; + b_dmamaxpages = b_dmapages_total * bufcachepercent / + 100; bufadjust(pgs); /* adjust bufpages */ bufhighpages = bufpages; /* set high water mark */ } diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 53c3ca0b495..bdc0b0fbf78 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_bio.c,v 1.148 2013/06/11 19:01:20 beck Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.149 2013/06/11 21:51:55 tedu Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ /* @@ -183,7 +183,7 @@ buf_put(struct buf *bp) bcstats.numbufs--; if (buf_dealloc_mem(bp) != 0) - return; + return; pool_put(&bufpool, bp); } @@ -223,8 +223,8 @@ bufinit(void) KASSERT(bufcachepercent <= 90); KASSERT(bufcachepercent >= 5); if (bufpages == 0) - bufpages = (b_dmapages_total + b_highpages_total) - * bufcachepercent / 100; + bufpages = (b_dmapages_total + b_highpages_total) * + bufcachepercent / 100; if (bufpages < BCACHE_MIN) bufpages = BCACHE_MIN; @@ -326,7 +326,7 @@ bufadjust(int newbufpages) if (!growing && (bcstats.numbufpages > lopages)) { if (bfreeclean(bcstats.numbufpages - lopages, &bufqueues[BQ_CLEANH]) != 0) - (void) bfreeclean(bcstats.numbufpages - lopages, + (void)bfreeclean(bcstats.numbufpages - lopages, &bufqueues[BQ_CLEANL]); } @@ -373,17 +373,16 @@ bufbackoff(struct uvm_constraint_range *range, long size) pdelta = bufpages - buflowpages; oldbufpages = bufpages; - if (b_highpages_total - && (range->ucr_high <= dma_constraint.ucr_high)) { + if (b_highpages_total && + (range->ucr_high <= dma_constraint.ucr_high)) { /* * Free up DMA accessible memory by moving pages to * the high range. */ if (bufhigh(pdelta) == 0) return(0); /* we moved enough pages up high */ - else { + else bufadjust(bufpages - pdelta); /* shrink the cache. */ - } } else { /* Free memory by shrinking the cache. */ bufadjust(bufpages - pdelta); @@ -1026,9 +1025,9 @@ buf_get(struct vnode *vp, daddr_t blkno, size_t size) */ if (bcstats.numbufpages + npages > hipages) { if (bfreeclean(bcstats.numbufpages - lopages, - &bufqueues[BQ_CLEANH]) != 0) - (void) bfreeclean(bcstats.numbufpages - - lopages, &bufqueues[BQ_CLEANL]); + &bufqueues[BQ_CLEANH]) != 0) + (void)bfreeclean(bcstats.numbufpages - + lopages, &bufqueues[BQ_CLEANL]); } @@ -1351,6 +1350,7 @@ bufhigh(int delta) psize_t newdmapages; struct buf *b, *bn; int s; + if (!b_highpages_total) return(-1); s = splbio(); @@ -1374,10 +1374,10 @@ bufhigh(int delta) buf_release(b); } else { /* free up some high memory and try again. */ - if (bfreeclean(delta, &bufqueues[BQ_CLEANH]) - == 0) + if (bfreeclean(delta, + &bufqueues[BQ_CLEANH]) == 0) { goto moveit; - else { + } else { /* otherwise just free the buffer */ buf_release(b); if (b->b_vp) { diff --git a/sys/kern/vfs_biomem.c b/sys/kern/vfs_biomem.c index 1b68aed642d..51dd8261b9c 100644 --- a/sys/kern/vfs_biomem.c +++ b/sys/kern/vfs_biomem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_biomem.c,v 1.24 2013/06/11 19:01:20 beck Exp $ */ +/* $OpenBSD: vfs_biomem.c,v 1.25 2013/06/11 21:51:55 tedu Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> * Copyright (c) 2012,2013 Bob Beck <beck@openbsd.org> @@ -333,6 +333,7 @@ buf_realloc_pages(struct buf *bp, struct uvm_constraint_range *where, vaddr_t va; int dma; int i, r; + KASSERT(!(flags & UVM_PLA_WAITOK) ^ !(flags & UVM_PLA_NOWAIT)); splassert(IPL_BIO); |