From: Matthew Dillon Date: Sun, 30 Apr 2006 18:52:37 +0000 (+0000) Subject: The pbuf subsystem now initializes b_kvabase and b_kvasize at startup and X-Git-Tag: v2.0.1~5008 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/312dcd01e39b41c5e63bb9e2082a3531a1ac693b The pbuf subsystem now initializes b_kvabase and b_kvasize at startup and no longer reinitializes these fields in initpbuf(). Users of getpbuf() may no longer modify b_kvabase or b_kvasize. b_data may still be modified. --- diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index e2e3c74d16..3ac6febdf0 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -12,7 +12,7 @@ * John S. Dyson. * * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.20 2003/05/28 18:38:10 alc Exp $ - * $DragonFly: src/sys/kern/vfs_bio.c,v 1.68 2006/04/30 18:25:35 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_bio.c,v 1.69 2006/04/30 18:52:36 dillon Exp $ */ /* @@ -519,7 +519,7 @@ clearbiocache(struct bio *bio) * Since this call frees up buffer space, we call bufspacewakeup(). */ static void -bfreekva(struct buf * bp) +bfreekva(struct buf *bp) { int count; @@ -2429,7 +2429,7 @@ allocbuf(struct buf *bp, int size) if (newbsize < bp->b_bufsize) { /* - * malloced buffers are not shrunk + * Malloced buffers are not shrunk */ if (bp->b_flags & B_MALLOC) { if (newbsize) { diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 1a32a8080b..1d980e9a81 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -34,7 +34,7 @@ * * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94 * $FreeBSD: src/sys/kern/vfs_cluster.c,v 1.92.2.9 2001/11/18 07:10:59 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.22 2006/04/30 17:22:17 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.23 2006/04/30 18:52:36 dillon Exp $ */ #include "opt_debug_cluster.h" @@ -484,10 +484,10 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, bp->b_xio.xio_pages[j] = bogus_page; } } - if (bp->b_bufsize > bp->b_kvasize) + if (bp->b_bufsize > bp->b_kvasize) { panic("cluster_rbuild: b_bufsize(%d) > b_kvasize(%d)", bp->b_bufsize, bp->b_kvasize); - bp->b_kvasize = bp->b_bufsize; + } pmap_qenter(trunc_page((vm_offset_t) bp->b_data), (vm_page_t *)bp->b_xio.xio_pages, bp->b_xio.xio_npages); @@ -922,11 +922,11 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) finishcluster: pmap_qenter(trunc_page((vm_offset_t) bp->b_data), (vm_page_t *) bp->b_xio.xio_pages, bp->b_xio.xio_npages); - if (bp->b_bufsize > bp->b_kvasize) + if (bp->b_bufsize > bp->b_kvasize) { panic( "cluster_wbuild: b_bufsize(%d) > b_kvasize(%d)\n", bp->b_bufsize, bp->b_kvasize); - bp->b_kvasize = bp->b_bufsize; + } totalwritten += bp->b_bufsize; bp->b_dirtyoff = 0; bp->b_dirtyend = bp->b_bufsize; diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 1b75ba656e..0a4518a467 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_pager.c,v 1.54.2.2 2001/11/18 07:11:00 dillon Exp $ - * $DragonFly: src/sys/vm/vm_pager.c,v 1.20 2006/04/30 18:25:37 dillon Exp $ + * $DragonFly: src/sys/vm/vm_pager.c,v 1.21 2006/04/30 18:52:37 dillon Exp $ */ /* @@ -205,21 +205,29 @@ vm_pager_bufferinit(void) struct buf *bp; int i; - bp = swbuf; /* - * Now set up swap and physical I/O buffer headers. + * Reserve KVM space for pbuf data. + */ + swapbkva = kmem_alloc_pageable(pager_map, nswbuf * MAXPHYS); + if (!swapbkva) + panic("Not enough pager_map VM space for physical buffers"); + + /* + * Initial pbuf setup. */ - for (i = 0; i < nswbuf; i++, bp++) { + bp = swbuf; + for (i = 0; i < nswbuf; ++i, ++bp) { + bp->b_kvabase = (caddr_t)(i * MAXPHYS) + swapbkva; + bp->b_kvasize = MAXPHYS; TAILQ_INSERT_HEAD(&bswlist, bp, b_freelist); BUF_LOCKINIT(bp); LIST_INIT(&bp->b_dep); } + /* + * Allow the clustering code to use half of our pbufs. + */ cluster_pbuf_freecnt = nswbuf / 2; - - swapbkva = kmem_alloc_pageable(pager_map, nswbuf * MAXPHYS); - if (!swapbkva) - panic("Not enough pager_map VM space for physical buffers"); } /* @@ -307,16 +315,13 @@ vm_pager_object_lookup(struct pagerlst *pg_list, void *handle) } /* - * initialize a physical buffer + * Initialize a physical buffer. */ - static void initpbuf(struct buf *bp) { bp->b_qindex = 0; /* BQUEUE_NONE */ - bp->b_data = (caddr_t) (MAXPHYS * (bp - swbuf)) + swapbkva; - bp->b_kvabase = bp->b_data; - bp->b_kvasize = MAXPHYS; + bp->b_data = bp->b_kvabase; bp->b_flags = B_PAGING; bp->b_cmd = BUF_CMD_DONE; bp->b_error = 0;