RBT_PROTOTYPE needs to be able to see RBT_HEAD, so this shuffles the headers a bit.
otherwise it just maps RB code to RBT. ok? Index: sys/buf.h =================================================================== RCS file: /cvs/src/sys/sys/buf.h,v retrieving revision 1.103 diff -u -p -r1.103 buf.h --- sys/buf.h 23 May 2016 09:31:28 -0000 1.103 +++ sys/buf.h 15 Sep 2016 06:59:58 -0000 @@ -48,9 +48,6 @@ struct buf; struct vnode; -struct buf_rb_bufs; -RB_PROTOTYPE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare); - LIST_HEAD(bufhead, buf); /* @@ -140,7 +137,7 @@ extern struct bio_ops { /* The buffer header describes an I/O operation in the kernel. */ struct buf { - RB_ENTRY(buf) b_rbbufs; /* vnode "hash" tree */ + RBT_ENTRY(buf) b_rbbufs; /* vnode "hash" tree */ LIST_ENTRY(buf) b_list; /* All allocated buffers. */ LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */ TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */ Index: sys/vnode.h =================================================================== RCS file: /cvs/src/sys/sys/vnode.h,v retrieving revision 1.135 diff -u -p -r1.135 vnode.h --- sys/vnode.h 23 May 2016 09:31:28 -0000 1.135 +++ sys/vnode.h 15 Sep 2016 06:59:58 -0000 @@ -80,7 +80,9 @@ enum vtagtype { */ LIST_HEAD(buflists, buf); -RB_HEAD(buf_rb_bufs, buf); +RBT_HEAD(buf_rb_bufs, buf); +RBT_PROTOTYPE(buf_rb_bufs, buf, b_rbbufs, rb_buf_compare); + RB_HEAD(namecache_rb_cache, namecache); struct uvm_vnode; Index: kern/vfs_bio.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_bio.c,v retrieving revision 1.177 diff -u -p -r1.177 vfs_bio.c --- kern/vfs_bio.c 15 Sep 2016 02:00:16 -0000 1.177 +++ kern/vfs_bio.c 15 Sep 2016 06:59:58 -0000 @@ -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, 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, (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, 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; Index: kern/vfs_subr.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_subr.c,v retrieving revision 1.251 diff -u -p -r1.251 vfs_subr.c --- kern/vfs_subr.c 15 Sep 2016 02:00:16 -0000 1.251 +++ kern/vfs_subr.c 15 Sep 2016 06:59:58 -0000 @@ -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 mo 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++;