Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys One small piece from UBC: create a pool for I/O buffers....
details: https://anonhg.NetBSD.org/src/rev/3b5e9aa005b6
branches: trunk
changeset: 482121:3b5e9aa005b6
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Feb 14 20:12:02 2000 +0000
description:
One small piece from UBC: create a pool for I/O buffers. One small piece
not from UBC: make physio use it instead of its own home-grown thing.
diffstat:
sys/kern/kern_physio.c | 13 +++++++++----
sys/kern/vfs_bio.c | 15 ++++++++++++++-
sys/sys/buf.h | 6 +++++-
3 files changed, 28 insertions(+), 6 deletions(-)
diffs (112 lines):
diff -r 2b2aff166957 -r 3b5e9aa005b6 sys/kern/kern_physio.c
--- a/sys/kern/kern_physio.c Mon Feb 14 19:45:50 2000 +0000
+++ b/sys/kern/kern_physio.c Mon Feb 14 20:12:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_physio.c,v 1.39 2000/01/21 23:21:46 thorpej Exp $ */
+/* $NetBSD: kern_physio.c,v 1.40 2000/02/14 20:12:03 thorpej Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@@ -283,8 +283,11 @@
getphysbuf()
{
struct buf *bp;
+ int s;
- bp = malloc(sizeof(*bp), M_TEMP, M_WAITOK);
+ s = splbio();
+ bp = pool_get(&bufpool, PR_WAITOK);
+ splx(s);
memset(bp, 0, sizeof(*bp));
/* XXXCDC: are the following two lines necessary? */
@@ -301,6 +304,7 @@
putphysbuf(bp)
struct buf *bp;
{
+ int s;
/* XXXCDC: is this necesary? */
if (bp->b_vp)
@@ -308,8 +312,9 @@
if (bp->b_flags & B_WANTED)
panic("putphysbuf: private buf B_WANTED");
- free(bp, M_TEMP);
-
+ s = splbio();
+ pool_put(&bufpool, bp);
+ splx(s);
}
/*
diff -r 2b2aff166957 -r 3b5e9aa005b6 sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c Mon Feb 14 19:45:50 2000 +0000
+++ b/sys/kern/vfs_bio.c Mon Feb 14 20:12:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.64 2000/02/07 20:16:58 thorpej Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.65 2000/02/14 20:12:03 thorpej Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@@ -97,6 +97,11 @@
int needbuffer;
/*
+ * Buffer pool for I/O buffers.
+ */
+struct pool bufpool;
+
+/*
* Insq/Remq for the buffer free lists.
*/
#define binsheadfree(bp, dp) TAILQ_INSERT_HEAD(dp, bp, b_freelist)
@@ -144,6 +149,14 @@
register int i;
int base, residual;
+ /*
+ * Initialize the buffer pool. This pool is used for buffers
+ * which are strictly I/O control blocks, not buffer cache
+ * buffers.
+ */
+ pool_init(&bufpool, sizeof(struct buf), 0, 0, 0, "bufpl", 0,
+ NULL, NULL, M_DEVBUF);
+
for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)
TAILQ_INIT(dp);
bufhashtbl = hashinit(nbuf, M_CACHE, M_WAITOK, &bufhash);
diff -r 2b2aff166957 -r 3b5e9aa005b6 sys/sys/buf.h
--- a/sys/sys/buf.h Mon Feb 14 19:45:50 2000 +0000
+++ b/sys/sys/buf.h Mon Feb 14 20:12:02 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.39 2000/02/07 20:16:59 thorpej Exp $ */
+/* $NetBSD: buf.h,v 1.40 2000/02/14 20:12:02 thorpej Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -80,6 +80,7 @@
#ifndef _SYS_BUF_H_
#define _SYS_BUF_H_
+#include <sys/pool.h>
#include <sys/queue.h>
#define NOLIST ((struct buf *)0x87654321)
@@ -271,6 +272,8 @@
int bufpages; /* Number of memory pages in the buffer pool. */
extern int nswbuf; /* Number of swap I/O buffer headers. */
+extern struct pool bufpool; /* I/O buf pool */
+
__BEGIN_DECLS
void allocbuf __P((struct buf *, int));
void bawrite __P((struct buf *));
@@ -301,6 +304,7 @@
void minphys __P((struct buf *bp));
int physio __P((void (*strategy)(struct buf *), struct buf *bp, dev_t dev,
int flags, void (*minphys)(struct buf *), struct uio *uio));
+
void brelvp __P((struct buf *));
void reassignbuf __P((struct buf *, struct vnode *));
void bgetvp __P((struct vnode *, struct buf *));
Home |
Main Index |
Thread Index |
Old Index