From f52bd684f3c79523192bd6e7adfd672b4d48cea2 Mon Sep 17 00:00:00 2001 From: Eivind Eklund Date: Tue, 5 Mar 2002 18:20:58 +0000 Subject: [PATCH] * Move bswlist declaration and initialization from kern/vfs_bio.c to vm/vm_pager.c, which is the only place it is used. * Make the QUEUE_* definitions and bufqueues local to vfs_bio.c. * constify buf_wmesg. --- sys/kern/vfs_bio.c | 19 +++++++++++++++---- sys/sys/buf.h | 16 +--------------- sys/vm/vm_pager.c | 7 ++++++- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index fb4f524b4225..70d3a924f9d8 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -68,7 +68,6 @@ struct buf_ops buf_ops_bio = { * carnal knowledge of buffers. This knowledge should be moved to vfs_bio.c. */ struct buf *buf; /* buffer header pool */ -struct swqueue bswlist; struct mtx buftimelock; /* Interlock on setting prio and timo */ static void vm_hold_free_pages(struct buf * bp, vm_offset_t from, @@ -207,13 +206,26 @@ static LIST_HEAD(bufhashhdr, buf) *bufhashtbl; * on them.) */ static struct bufhashhdr invalhash; + +/* + * Definitions for the buffer free lists. + */ +#define BUFFER_QUEUES 6 /* number of free buffer queues */ + +#define QUEUE_NONE 0 /* on no queue */ +#define QUEUE_LOCKED 1 /* locked buffers */ +#define QUEUE_CLEAN 2 /* non-B_DELWRI buffers */ +#define QUEUE_DIRTY 3 /* B_DELWRI buffers */ +#define QUEUE_EMPTYKVA 4 /* empty buffer headers w/KVA assignment */ +#define QUEUE_EMPTY 5 /* empty buffer headers */ + /* Queues for free buffers with various properties */ -static struct bqueues bufqueues[BUFFER_QUEUES] = { { 0 } }; +static TAILQ_HEAD(bqueues, buf) bufqueues[BUFFER_QUEUES] = { { 0 } }; /* * Single global constant for BUF_WMESG, to avoid getting multiple references. * buf_wmesg is referred from macros. */ -char *buf_wmesg = BUF_WMESG; +const char *buf_wmesg = BUF_WMESG; #define VFS_BIO_NEED_ANY 0x01 /* any freeable buffer */ #define VFS_BIO_NEED_DIRTYFLUSH 0x02 /* waiting for dirty buffer flush */ @@ -471,7 +483,6 @@ bufinit(void) GIANT_REQUIRED; - TAILQ_INIT(&bswlist); LIST_INIT(&invalhash); mtx_init(&buftimelock, "buftime lock", MTX_DEF); diff --git a/sys/sys/buf.h b/sys/sys/buf.h index b6c367cd0090..ca0383ef630e 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -254,7 +254,7 @@ struct buf { * Buffer locking */ extern struct mtx buftimelock; /* Interlock on setting prio and timo */ -extern char *buf_wmesg; /* Default buffer lock message */ +extern const char *buf_wmesg; /* Default buffer lock message */ #define BUF_WMESG "bufwait" #include /* XXX for curthread */ #include @@ -431,18 +431,6 @@ buf_countdeps(struct buf *bp, int i) #endif /* _KERNEL */ -/* - * Definitions for the buffer free lists. - */ -#define BUFFER_QUEUES 6 /* number of free buffer queues */ - -#define QUEUE_NONE 0 /* on no queue */ -#define QUEUE_LOCKED 1 /* locked buffers */ -#define QUEUE_CLEAN 2 /* non-B_DELWRI buffers */ -#define QUEUE_DIRTY 3 /* B_DELWRI buffers */ -#define QUEUE_EMPTYKVA 4 /* empty buffer headers w/KVA assignment */ -#define QUEUE_EMPTY 5 /* empty buffer headers */ - /* * Zero out the buffer's data area. */ @@ -468,8 +456,6 @@ extern char *buffers; /* The buffer contents. */ extern int bufpages; /* Number of memory pages in the buffer pool. */ extern struct buf *swbuf; /* Swap I/O buffer headers. */ extern int nswbuf; /* Number of swap I/O buffer headers. */ -extern TAILQ_HEAD(swqueue, buf) bswlist; -extern TAILQ_HEAD(bqueues, buf) bufqueues[BUFFER_QUEUES]; struct uio; diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 6cb678a9d471..c95e1c69e98a 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -194,12 +194,14 @@ vm_map_t pager_map; static int bswneeded; static vm_offset_t swapbkva; /* swap buffers kva */ struct mtx pbuf_mtx; +static TAILQ_HEAD(swqueue, buf) bswlist; void vm_pager_init() { struct pagerops **pgops; + TAILQ_INIT(&bswlist); /* * Initialize known pagers */ @@ -347,12 +349,15 @@ vm_pager_object_lookup(pg_list, handle) * initialize a physical buffer */ +/* + * XXX This probably belongs in vfs_bio.c + */ static void initpbuf(struct buf *bp) { bp->b_rcred = NOCRED; bp->b_wcred = NOCRED; - bp->b_qindex = QUEUE_NONE; + bp->b_qindex = 0; /* On no queue (QUEUE_NONE) */ bp->b_data = (caddr_t) (MAXPHYS * (bp - swbuf)) + swapbkva; bp->b_kvabase = bp->b_data; bp->b_kvasize = MAXPHYS;