summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2016-09-16 02:54:52 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2016-09-16 02:54:52 +0000
commitbf41feffd36f2fc4435f198ba4b888cb2a54d9e6 (patch)
treee010dcd18228b68f5cbe182877f89cb324324e30 /sys/kern
parentbe8e0b33e3f87b165d79a77552fec0ba7882f1e6 (diff)
move buf_rb_bufs from RB macros to RBT functions
i had to shuffle the order of some header bits cos RBT_PROTOTYPE needs to see what RBT_HEAD produces.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_bio.c19
-rw-r--r--sys/kern/vfs_subr.c12
2 files changed, 14 insertions, 17 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 7e311877cc1..b5f0cd0f02a 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.177 2016/09/15 02:00:16 dlg Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.178 2016/09/16 02:54:51 dlg Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*
@@ -247,8 +247,7 @@ bufadjust(int newbufpages)
(bcstats.numbufpages > targetpages)) {
bufcache_take(bp);
if (bp->b_vp) {
- RB_REMOVE(buf_rb_bufs,
- &bp->b_vp->v_bufs_tree, bp);
+ RBT_REMOVE(buf_rb_bufs, &bp->b_vp->v_bufs_tree, bp);
brelvp(bp);
}
buf_put(bp);
@@ -758,8 +757,7 @@ brelse(struct buf *bp)
}
if (bp->b_vp) {
- RB_REMOVE(buf_rb_bufs, &bp->b_vp->v_bufs_tree,
- bp);
+ RBT_REMOVE(buf_rb_bufs, &bp->b_vp->v_bufs_tree, bp);
brelvp(bp);
}
bp->b_vp = NULL;
@@ -826,7 +824,7 @@ incore(struct vnode *vp, daddr_t blkno)
/* Search buf lookup tree */
b.b_lblkno = blkno;
- bp = RB_FIND(buf_rb_bufs, &vp->v_bufs_tree, &b);
+ bp = RBT_FIND(buf_rb_bufs, &vp->v_bufs_tree, &b);
if (bp != NULL && ISSET(bp->b_flags, B_INVAL))
bp = NULL;
@@ -862,7 +860,7 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int slpflag, int slptimeo)
start:
s = splbio();
b.b_lblkno = blkno;
- bp = RB_FIND(buf_rb_bufs, &vp->v_bufs_tree, &b);
+ bp = RBT_FIND(buf_rb_bufs, &vp->v_bufs_tree, &b);
if (bp != NULL) {
if (ISSET(bp->b_flags, B_BUSY)) {
SET(bp->b_flags, B_WANTED);
@@ -945,7 +943,7 @@ buf_get(struct vnode *vp, daddr_t blkno, size_t size)
(bp = bufcache_getanycleanbuf())) {
bufcache_take(bp);
if (bp->b_vp) {
- RB_REMOVE(buf_rb_bufs,
+ RBT_REMOVE(buf_rb_bufs,
&bp->b_vp->v_bufs_tree, bp);
brelvp(bp);
}
@@ -1006,7 +1004,7 @@ buf_get(struct vnode *vp, daddr_t blkno, size_t size)
bp->b_blkno = bp->b_lblkno = blkno;
bgetvp(vp, bp);
- if (RB_INSERT(buf_rb_bufs, &vp->v_bufs_tree, bp))
+ if (RBT_INSERT(buf_rb_bufs, &vp->v_bufs_tree, bp))
panic("buf_get: dup lblk vp %p bp %p", vp, bp);
} else {
bp->b_vnbufs.le_next = NOLIST;
@@ -1505,8 +1503,7 @@ hibernate_suspend_bufcache(void)
while ((bp = bufcache_getcleanbuf_range(DMA_CACHE, NUM_CACHES - 1, 1))) {
bufcache_take(bp);
if (bp->b_vp) {
- RB_REMOVE(buf_rb_bufs,
- &bp->b_vp->v_bufs_tree, bp);
+ RBT_REMOVE(buf_rb_bufs, &bp->b_vp->v_bufs_tree, bp);
brelvp(bp);
}
buf_put(bp);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 2bdb9abed61..dc80da9ef95 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.251 2016/09/15 02:00:16 dlg Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.252 2016/09/16 02:54:51 dlg Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -122,11 +122,11 @@ void printlockedvnodes(void);
struct pool vnode_pool;
struct pool uvm_vnode_pool;
-static int rb_buf_compare(struct buf *b1, struct buf *b2);
-RB_GENERATE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare);
+static inline int rb_buf_compare(const struct buf *b1, const struct buf *b2);
+RBT_GENERATE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare);
-static int
-rb_buf_compare(struct buf *b1, struct buf *b2)
+static inline int
+rb_buf_compare(const struct buf *b1, const struct buf *b2)
{
if (b1->b_lblkno < b2->b_lblkno)
return(-1);
@@ -375,7 +375,7 @@ getnewvnode(enum vtagtype tag, struct mount *mp, struct vops *vops,
vp = pool_get(&vnode_pool, PR_WAITOK | PR_ZERO);
vp->v_uvm = pool_get(&uvm_vnode_pool, PR_WAITOK | PR_ZERO);
vp->v_uvm->u_vnode = vp;
- RB_INIT(&vp->v_bufs_tree);
+ RBT_INIT(buf_rb_bufs, &vp->v_bufs_tree);
RB_INIT(&vp->v_nc_tree);
TAILQ_INIT(&vp->v_cache_dst);
numvnodes++;