1139825Simp/*- 21541Srgrimes * Copyright (c) 1991, 1993 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * This code is derived from software contributed to Berkeley by 61541Srgrimes * The Mach Operating System project at Carnegie-Mellon University. 71541Srgrimes * 81541Srgrimes * Redistribution and use in source and binary forms, with or without 91541Srgrimes * modification, are permitted provided that the following conditions 101541Srgrimes * are met: 111541Srgrimes * 1. Redistributions of source code must retain the above copyright 121541Srgrimes * notice, this list of conditions and the following disclaimer. 131541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer in the 151541Srgrimes * documentation and/or other materials provided with the distribution. 161541Srgrimes * 4. Neither the name of the University nor the names of its contributors 171541Srgrimes * may be used to endorse or promote products derived from this software 181541Srgrimes * without specific prior written permission. 191541Srgrimes * 201541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 211541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 221541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 231541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 241541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 251541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 261541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 271541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 281541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 291541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 301541Srgrimes * SUCH DAMAGE. 311541Srgrimes * 321817Sdg * from: @(#)vm_pager.c 8.6 (Berkeley) 1/12/94 331541Srgrimes * 341541Srgrimes * 351541Srgrimes * Copyright (c) 1987, 1990 Carnegie-Mellon University. 361541Srgrimes * All rights reserved. 371541Srgrimes * 381541Srgrimes * Authors: Avadis Tevanian, Jr., Michael Wayne Young 395455Sdg * 401541Srgrimes * Permission to use, copy, modify and distribute this software and 411541Srgrimes * its documentation is hereby granted, provided that both the copyright 421541Srgrimes * notice and this permission notice appear in all copies of the 431541Srgrimes * software, derivative works or modified versions, and any portions 441541Srgrimes * thereof, and that both notices appear in supporting documentation. 455455Sdg * 465455Sdg * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 475455Sdg * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 481541Srgrimes * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 495455Sdg * 501541Srgrimes * Carnegie Mellon requests users of this software to return to 511541Srgrimes * 521541Srgrimes * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 531541Srgrimes * School of Computer Science 541541Srgrimes * Carnegie Mellon University 551541Srgrimes * Pittsburgh PA 15213-3890 561541Srgrimes * 571541Srgrimes * any improvements or extensions that they make and grant Carnegie the 581541Srgrimes * rights to redistribute these changes. 591541Srgrimes */ 601541Srgrimes 611541Srgrimes/* 621541Srgrimes * Paging space routine stubs. Emulates a matchmaker-like interface 631541Srgrimes * for builtin pagers. 641541Srgrimes */ 651541Srgrimes 66116226Sobrien#include <sys/cdefs.h> 67116226Sobrien__FBSDID("$FreeBSD$"); 68116226Sobrien 691541Srgrimes#include <sys/param.h> 701541Srgrimes#include <sys/systm.h> 7141059Speter#include <sys/kernel.h> 7244739Sjulian#include <sys/vnode.h> 7360041Sphk#include <sys/bio.h> 741887Sdg#include <sys/buf.h> 7569517Sbde#include <sys/ucred.h> 7630354Sphk#include <sys/malloc.h> 771541Srgrimes 781541Srgrimes#include <vm/vm.h> 7912662Sdg#include <vm/vm_param.h> 8012662Sdg#include <vm/vm_object.h> 811541Srgrimes#include <vm/vm_page.h> 829507Sdg#include <vm/vm_pager.h> 8312662Sdg#include <vm/vm_extern.h> 841541Srgrimes 8542957Sdillonint cluster_pbuf_freecnt = -1; /* unlimited to begin with */ 8642957Sdillon 8792727Salfredstatic int dead_pager_getpages(vm_object_t, vm_page_t *, int, int); 8892727Salfredstatic vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t, 89194766Skib vm_ooffset_t, struct ucred *); 9092727Salfredstatic void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *); 9192727Salfredstatic boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *); 9292727Salfredstatic void dead_pager_dealloc(vm_object_t); 9334611Sdyson 9443129Sdillonstatic int 9534611Sdysondead_pager_getpages(obj, ma, count, req) 9634611Sdyson vm_object_t obj; 9734611Sdyson vm_page_t *ma; 9834611Sdyson int count; 9934611Sdyson int req; 10034611Sdyson{ 10134611Sdyson return VM_PAGER_FAIL; 10234611Sdyson} 10334611Sdyson 10443129Sdillonstatic vm_object_t 105189004Srdivackydead_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot, 106194766Skib vm_ooffset_t off, struct ucred *cred) 10734611Sdyson{ 10834611Sdyson return NULL; 10934611Sdyson} 11034611Sdyson 11143129Sdillonstatic void 11234611Sdysondead_pager_putpages(object, m, count, flags, rtvals) 11334611Sdyson vm_object_t object; 11434611Sdyson vm_page_t *m; 11534611Sdyson int count; 11634611Sdyson int flags; 11734611Sdyson int *rtvals; 11834611Sdyson{ 11934611Sdyson int i; 12043129Sdillon 12134611Sdyson for (i = 0; i < count; i++) { 12234611Sdyson rtvals[i] = VM_PAGER_AGAIN; 12334611Sdyson } 12434611Sdyson} 12534611Sdyson 12643129Sdillonstatic int 12734611Sdysondead_pager_haspage(object, pindex, prev, next) 12834611Sdyson vm_object_t object; 12934611Sdyson vm_pindex_t pindex; 13034611Sdyson int *prev; 13134611Sdyson int *next; 13234611Sdyson{ 13334611Sdyson if (prev) 13434611Sdyson *prev = 0; 13534611Sdyson if (next) 13634611Sdyson *next = 0; 13734611Sdyson return FALSE; 13834611Sdyson} 13934611Sdyson 14043129Sdillonstatic void 14134611Sdysondead_pager_dealloc(object) 14234611Sdyson vm_object_t object; 14334611Sdyson{ 14434611Sdyson return; 14534611Sdyson} 14634611Sdyson 14745567Seivindstatic struct pagerops deadpagerops = { 148118466Sphk .pgo_alloc = dead_pager_alloc, 149118466Sphk .pgo_dealloc = dead_pager_dealloc, 150118466Sphk .pgo_getpages = dead_pager_getpages, 151118466Sphk .pgo_putpages = dead_pager_putpages, 152118466Sphk .pgo_haspage = dead_pager_haspage, 15334611Sdyson}; 15434611Sdyson 15542957Sdillonstruct pagerops *pagertab[] = { 1569507Sdg &defaultpagerops, /* OBJT_DEFAULT */ 1579507Sdg &swappagerops, /* OBJT_SWAP */ 1589507Sdg &vnodepagerops, /* OBJT_VNODE */ 1599507Sdg &devicepagerops, /* OBJT_DEVICE */ 16060757Speter &physpagerops, /* OBJT_PHYS */ 161195840Sjhb &deadpagerops, /* OBJT_DEAD */ 162236925Skib &sgpagerops, /* OBJT_SG */ 163236925Skib &mgtdevicepagerops, /* OBJT_MGTDEVICE */ 1641541Srgrimes}; 1651541Srgrimes 166141629Sphkstatic const int npagers = sizeof(pagertab) / sizeof(pagertab[0]); 16742957Sdillon 1681541Srgrimes/* 1691541Srgrimes * Kernel address space for mapping pages. 1701541Srgrimes * Used by pagers where KVAs are needed for IO. 1711541Srgrimes * 1721541Srgrimes * XXX needs to be large enough to support the number of pending async 1731541Srgrimes * cleaning requests (NPENDINGIO == 64) * the maximum swap cluster size 1741541Srgrimes * (MAXPHYS == 64k) if you want to get the most efficiency. 1751541Srgrimes */ 1761541Srgrimesvm_map_t pager_map; 17712820Sphkstatic int bswneeded; 17812820Sphkstatic vm_offset_t swapbkva; /* swap buffers kva */ 17975474Salfredstruct mtx pbuf_mtx; 18091700Seivindstatic TAILQ_HEAD(swqueue, buf) bswlist; 1811541Srgrimes 1821541Srgrimesvoid 1831541Srgrimesvm_pager_init() 1841541Srgrimes{ 1851541Srgrimes struct pagerops **pgops; 1861541Srgrimes 18791700Seivind TAILQ_INIT(&bswlist); 1881541Srgrimes /* 1891541Srgrimes * Initialize known pagers 1901541Srgrimes */ 1911541Srgrimes for (pgops = pagertab; pgops < &pagertab[npagers]; pgops++) 192229189Skib if ((*pgops)->pgo_init != NULL) 1935455Sdg (*(*pgops)->pgo_init) (); 1941541Srgrimes} 1951541Srgrimes 1961887Sdgvoid 1971887Sdgvm_pager_bufferinit() 1981887Sdg{ 1991887Sdg struct buf *bp; 2001887Sdg int i; 2015455Sdg 20293818Sjhb mtx_init(&pbuf_mtx, "pbuf mutex", NULL, MTX_DEF); 2031887Sdg bp = swbuf; 2041887Sdg /* 2051887Sdg * Now set up swap and physical I/O buffer headers. 2061887Sdg */ 20732724Sdyson for (i = 0; i < nswbuf; i++, bp++) { 2081887Sdg TAILQ_INSERT_HEAD(&bswlist, bp, b_freelist); 20948225Smckusick BUF_LOCKINIT(bp); 21048225Smckusick LIST_INIT(&bp->b_dep); 2111887Sdg bp->b_rcred = bp->b_wcred = NOCRED; 21240790Speter bp->b_xflags = 0; 2131887Sdg } 2141887Sdg 21542957Sdillon cluster_pbuf_freecnt = nswbuf / 2; 216149035Skan vnode_pbuf_freecnt = nswbuf / 2 + 1; 21742957Sdillon 218118413Salc swapbkva = kmem_alloc_nofault(pager_map, nswbuf * MAXPHYS); 2195455Sdg if (!swapbkva) 2201887Sdg panic("Not enough pager_map VM space for physical buffers"); 2211887Sdg} 2221887Sdg 2231541Srgrimes/* 2241541Srgrimes * Allocate an instance of a pager of the given type. 2251541Srgrimes * Size, protection and offset parameters are passed in for pagers that 2261541Srgrimes * need to perform page-level validation (e.g. the device pager). 2271541Srgrimes */ 2289507Sdgvm_object_t 22976827Salfredvm_pager_allocate(objtype_t type, void *handle, vm_ooffset_t size, 230194766Skib vm_prot_t prot, vm_ooffset_t off, struct ucred *cred) 2311541Srgrimes{ 23276827Salfred vm_object_t ret; 2331541Srgrimes struct pagerops *ops; 2341541Srgrimes 2359507Sdg ops = pagertab[type]; 2361541Srgrimes if (ops) 237194766Skib ret = (*ops->pgo_alloc) (handle, size, prot, off, cred); 23876827Salfred else 23976827Salfred ret = NULL; 24076827Salfred return (ret); 2411541Srgrimes} 2421541Srgrimes 243114774Salc/* 244114774Salc * The object must be locked. 245114774Salc */ 2461541Srgrimesvoid 2479507Sdgvm_pager_deallocate(object) 2489507Sdg vm_object_t object; 2491541Srgrimes{ 250114774Salc 251114774Salc VM_OBJECT_LOCK_ASSERT(object, MA_OWNED); 2529507Sdg (*pagertab[object->type]->pgo_dealloc) (object); 2531541Srgrimes} 2541541Srgrimes 25542957Sdillon/* 25642957Sdillon * vm_pager_get_pages() - inline, see vm/vm_pager.h 25742957Sdillon * vm_pager_put_pages() - inline, see vm/vm_pager.h 25842957Sdillon * vm_pager_has_page() - inline, see vm/vm_pager.h 25942957Sdillon */ 2601549Srgrimes 261171737Salc/* 262171737Salc * Search the specified pager object list for an object with the 263171737Salc * specified handle. If an object with the specified handle is found, 264171737Salc * increase its reference count and return it. Otherwise, return NULL. 265171737Salc * 266171737Salc * The pager object list must be locked. 267171737Salc */ 2689507Sdgvm_object_t 269171737Salcvm_pager_object_lookup(struct pagerlst *pg_list, void *handle) 2701541Srgrimes{ 27179242Sdillon vm_object_t object; 2721541Srgrimes 273171737Salc TAILQ_FOREACH(object, pg_list, pager_object_list) { 274236481Savg if (object->handle == handle) { 275236481Savg VM_OBJECT_LOCK(object); 276236481Savg if ((object->flags & OBJ_DEAD) == 0) { 277236481Savg vm_object_reference_locked(object); 278236481Savg VM_OBJECT_UNLOCK(object); 279236481Savg break; 280236481Savg } 281171737Salc VM_OBJECT_UNLOCK(object); 282171737Salc } 283171737Salc } 284171737Salc return (object); 2851541Srgrimes} 2861541Srgrimes 2871541Srgrimes/* 28820054Sdyson * initialize a physical buffer 28920054Sdyson */ 29020054Sdyson 29191700Seivind/* 29291700Seivind * XXX This probably belongs in vfs_bio.c 29391700Seivind */ 29420054Sdysonstatic void 29548274Speterinitpbuf(struct buf *bp) 29648274Speter{ 297137723Sphk KASSERT(bp->b_bufobj == NULL, ("initpbuf with bufobj")); 298137723Sphk KASSERT(bp->b_vp == NULL, ("initpbuf with vp")); 29920054Sdyson bp->b_rcred = NOCRED; 30020054Sdyson bp->b_wcred = NOCRED; 30191700Seivind bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */ 302116605Sphk bp->b_saveaddr = (caddr_t) (MAXPHYS * (bp - swbuf)) + swapbkva; 303116605Sphk bp->b_data = bp->b_saveaddr; 304116605Sphk bp->b_kvabase = bp->b_saveaddr; 30520054Sdyson bp->b_kvasize = MAXPHYS; 30640790Speter bp->b_xflags = 0; 30748225Smckusick bp->b_flags = 0; 30858934Sphk bp->b_ioflags = 0; 30958345Sphk bp->b_iodone = NULL; 31048225Smckusick bp->b_error = 0; 311111463Sjeff BUF_LOCK(bp, LK_EXCLUSIVE, NULL); 31220054Sdyson} 31320054Sdyson 31420054Sdyson/* 3155455Sdg * allocate a physical buffer 31642957Sdillon * 31742957Sdillon * There are a limited number (nswbuf) of physical buffers. We need 31842957Sdillon * to make sure that no single subsystem is able to hog all of them, 31942957Sdillon * so each subsystem implements a counter which is typically initialized 32042957Sdillon * to 1/2 nswbuf. getpbuf() decrements this counter in allocation and 32142957Sdillon * increments it on release, and blocks if the counter hits zero. A 32242957Sdillon * subsystem may initialize the counter to -1 to disable the feature, 32342957Sdillon * but it must still be sure to match up all uses of getpbuf() with 32442957Sdillon * relpbuf() using the same variable. 32542957Sdillon * 32642957Sdillon * NOTE: pfreecnt can be NULL, but this 'feature' will be removed 32742957Sdillon * relatively soon when the rest of the subsystems get smart about it. XXX 3281887Sdg */ 3291887Sdgstruct buf * 330137722Sphkgetpbuf(int *pfreecnt) 3315455Sdg{ 3321887Sdg struct buf *bp; 3331887Sdg 33475474Salfred mtx_lock(&pbuf_mtx); 33542957Sdillon 33648590Smckay for (;;) { 33748590Smckay if (pfreecnt) { 33848590Smckay while (*pfreecnt == 0) { 33975474Salfred msleep(pfreecnt, &pbuf_mtx, PVM, "wswbuf0", 0); 34048590Smckay } 34142957Sdillon } 34242957Sdillon 34348590Smckay /* get a bp from the swap buffer header pool */ 34448590Smckay if ((bp = TAILQ_FIRST(&bswlist)) != NULL) 34548590Smckay break; 34648590Smckay 3471887Sdg bswneeded = 1; 34875474Salfred msleep(&bswneeded, &pbuf_mtx, PVM, "wswbuf1", 0); 34948590Smckay /* loop in case someone else grabbed one */ 3501887Sdg } 3511887Sdg TAILQ_REMOVE(&bswlist, bp, b_freelist); 35242957Sdillon if (pfreecnt) 35342957Sdillon --*pfreecnt; 35475474Salfred mtx_unlock(&pbuf_mtx); 3551887Sdg 35620054Sdyson initpbuf(bp); 3571887Sdg return bp; 3581887Sdg} 3591887Sdg 3601887Sdg/* 36142957Sdillon * allocate a physical buffer, if one is available. 36242957Sdillon * 36342957Sdillon * Note that there is no NULL hack here - all subsystems using this 36442957Sdillon * call understand how to use pfreecnt. 3651887Sdg */ 3661887Sdgstruct buf * 367137722Sphktrypbuf(int *pfreecnt) 3685455Sdg{ 3691887Sdg struct buf *bp; 3701887Sdg 37175474Salfred mtx_lock(&pbuf_mtx); 37242957Sdillon if (*pfreecnt == 0 || (bp = TAILQ_FIRST(&bswlist)) == NULL) { 37375474Salfred mtx_unlock(&pbuf_mtx); 3741887Sdg return NULL; 3751887Sdg } 3761887Sdg TAILQ_REMOVE(&bswlist, bp, b_freelist); 37742957Sdillon 37842957Sdillon --*pfreecnt; 37942957Sdillon 38075474Salfred mtx_unlock(&pbuf_mtx); 3811887Sdg 38220054Sdyson initpbuf(bp); 38320054Sdyson 3841887Sdg return bp; 3851887Sdg} 3861887Sdg 3871887Sdg/* 3881887Sdg * release a physical buffer 38942957Sdillon * 39042957Sdillon * NOTE: pfreecnt can be NULL, but this 'feature' will be removed 39142957Sdillon * relatively soon when the rest of the subsystems get smart about it. XXX 3921887Sdg */ 3931887Sdgvoid 394137722Sphkrelpbuf(struct buf *bp, int *pfreecnt) 3951887Sdg{ 3961887Sdg 3971887Sdg if (bp->b_rcred != NOCRED) { 3981887Sdg crfree(bp->b_rcred); 3991887Sdg bp->b_rcred = NOCRED; 4001887Sdg } 4011887Sdg if (bp->b_wcred != NOCRED) { 4021887Sdg crfree(bp->b_wcred); 4031887Sdg bp->b_wcred = NOCRED; 4041887Sdg } 40542957Sdillon 406137723Sphk KASSERT(bp->b_vp == NULL, ("relpbuf with vp")); 407137723Sphk KASSERT(bp->b_bufobj == NULL, ("relpbuf with bufobj")); 408137723Sphk 40948225Smckusick BUF_UNLOCK(bp); 4105166Sdg 411113138Salc mtx_lock(&pbuf_mtx); 4121887Sdg TAILQ_INSERT_HEAD(&bswlist, bp, b_freelist); 4131887Sdg 4141887Sdg if (bswneeded) { 4151887Sdg bswneeded = 0; 4169507Sdg wakeup(&bswneeded); 4171887Sdg } 41842957Sdillon if (pfreecnt) { 41942957Sdillon if (++*pfreecnt == 1) 42042957Sdillon wakeup(pfreecnt); 42142957Sdillon } 42275474Salfred mtx_unlock(&pbuf_mtx); 4231887Sdg} 424137721Sphk 425137721Sphk/* 426137721Sphk * Associate a p-buffer with a vnode. 427137721Sphk * 428137721Sphk * Also sets B_PAGING flag to indicate that vnode is not fully associated 429137721Sphk * with the buffer. i.e. the bp has not been linked into the vnode or 430137721Sphk * ref-counted. 431137721Sphk */ 432137721Sphkvoid 433137721Sphkpbgetvp(struct vnode *vp, struct buf *bp) 434137721Sphk{ 435137721Sphk 436137721Sphk KASSERT(bp->b_vp == NULL, ("pbgetvp: not free")); 437137723Sphk KASSERT(bp->b_bufobj == NULL, ("pbgetvp: not free (bufobj)")); 438137721Sphk 439137721Sphk bp->b_vp = vp; 440137721Sphk bp->b_flags |= B_PAGING; 441137721Sphk bp->b_bufobj = &vp->v_bufobj; 442137721Sphk} 443137721Sphk 444137721Sphk/* 445137725Sphk * Associate a p-buffer with a vnode. 446137725Sphk * 447137725Sphk * Also sets B_PAGING flag to indicate that vnode is not fully associated 448137725Sphk * with the buffer. i.e. the bp has not been linked into the vnode or 449137725Sphk * ref-counted. 450137725Sphk */ 451137725Sphkvoid 452137725Sphkpbgetbo(struct bufobj *bo, struct buf *bp) 453137725Sphk{ 454137725Sphk 455137725Sphk KASSERT(bp->b_vp == NULL, ("pbgetbo: not free (vnode)")); 456137725Sphk KASSERT(bp->b_bufobj == NULL, ("pbgetbo: not free (bufobj)")); 457137725Sphk 458137725Sphk bp->b_flags |= B_PAGING; 459137725Sphk bp->b_bufobj = bo; 460137725Sphk} 461137725Sphk 462137725Sphk/* 463137721Sphk * Disassociate a p-buffer from a vnode. 464137721Sphk */ 465137721Sphkvoid 466137721Sphkpbrelvp(struct buf *bp) 467137721Sphk{ 468137721Sphk 469137721Sphk KASSERT(bp->b_vp != NULL, ("pbrelvp: NULL")); 470137721Sphk KASSERT(bp->b_bufobj != NULL, ("pbrelvp: NULL bufobj")); 471137721Sphk 472137721Sphk /* XXX REMOVE ME */ 473137721Sphk BO_LOCK(bp->b_bufobj); 474137721Sphk if (TAILQ_NEXT(bp, b_bobufs) != NULL) { 475137721Sphk panic( 476137721Sphk "relpbuf(): b_vp was probably reassignbuf()d %p %x", 477137721Sphk bp, 478137721Sphk (int)bp->b_flags 479137721Sphk ); 480137721Sphk } 481137721Sphk BO_UNLOCK(bp->b_bufobj); 482137721Sphk bp->b_vp = NULL; 483137721Sphk bp->b_bufobj = NULL; 484137721Sphk bp->b_flags &= ~B_PAGING; 485137721Sphk} 486137725Sphk 487137725Sphk/* 488137725Sphk * Disassociate a p-buffer from a bufobj. 489137725Sphk */ 490137725Sphkvoid 491137725Sphkpbrelbo(struct buf *bp) 492137725Sphk{ 493137725Sphk 494137725Sphk KASSERT(bp->b_vp == NULL, ("pbrelbo: vnode")); 495137725Sphk KASSERT(bp->b_bufobj != NULL, ("pbrelbo: NULL bufobj")); 496137725Sphk 497137725Sphk /* XXX REMOVE ME */ 498137725Sphk BO_LOCK(bp->b_bufobj); 499137725Sphk if (TAILQ_NEXT(bp, b_bobufs) != NULL) { 500137725Sphk panic( 501137725Sphk "relpbuf(): b_vp was probably reassignbuf()d %p %x", 502137725Sphk bp, 503137725Sphk (int)bp->b_flags 504137725Sphk ); 505137725Sphk } 506137725Sphk BO_UNLOCK(bp->b_bufobj); 507137725Sphk bp->b_bufobj = NULL; 508137725Sphk bp->b_flags &= ~B_PAGING; 509137725Sphk} 510