summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_physio.c41
-rw-r--r--sys/kern/vfs_bio.c31
-rw-r--r--sys/kern/vfs_cluster.c16
-rw-r--r--sys/kern/vfs_export.c3
-rw-r--r--sys/kern/vfs_subr.c3
5 files changed, 70 insertions, 24 deletions
diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c
index 652c37a696f2..c6cb72fc1e8e 100644
--- a/sys/kern/kern_physio.c
+++ b/sys/kern/kern_physio.c
@@ -16,7 +16,7 @@
* 4. Modifications may be freely made to this file if the above conditions
* are met.
*
- * $Id: kern_physio.c,v 1.21 1997/08/26 00:15:04 bde Exp $
+ * $Id: kern_physio.c,v 1.22 1997/09/02 20:05:40 bde Exp $
*/
#include <sys/param.h>
@@ -28,6 +28,7 @@
#include <vm/vm_extern.h>
static void physwakeup __P((struct buf *bp));
+static struct buf * phygetvpbuf(dev_t dev, int resid);
int
physio(strategy, bp, dev, rw, minp, uio)
@@ -52,7 +53,7 @@ physio(strategy, bp, dev, rw, minp, uio)
curproc->p_flag |= P_PHYSIO;
/* create and build a buffer header for a transfer */
- bpa = (struct buf *)getpbuf();
+ bpa = (struct buf *)phygetvpbuf(dev, uio->uio_resid);
if (!bp_alloc) {
spl = splbio();
while (bp->b_flags & B_BUSY) {
@@ -70,12 +71,12 @@ physio(strategy, bp, dev, rw, minp, uio)
*/
sa = bpa->b_data;
bp->b_proc = curproc;
- bp->b_dev = dev;
error = bp->b_error = 0;
for(i=0;i<uio->uio_iovcnt;i++) {
while( uio->uio_iov[i].iov_len) {
+ bp->b_dev = dev;
bp->b_bcount = uio->uio_iov[i].iov_len;
bp->b_flags = B_BUSY | B_PHYS | B_CALL | bufflags;
bp->b_iodone = physwakeup;
@@ -168,18 +169,46 @@ u_int
minphys(bp)
struct buf *bp;
{
- u_int maxphys = MAXPHYS;
+ u_int maxphys = DFLTPHYS;
+ struct bdevsw *bdsw;
+ int offset;
- if( ((vm_offset_t) bp->b_data) & PAGE_MASK) {
- maxphys = MAXPHYS - PAGE_SIZE;
+ bdsw = cdevsw[major(bp->b_dev)]->d_bdev;
+
+ if (bdsw && bdsw->d_maxio) {
+ maxphys = bdsw->d_maxio;
+ }
+ if (bp->b_kvasize < maxphys)
+ maxphys = bp->b_kvasize;
+
+ if(((vm_offset_t) bp->b_data) & PAGE_MASK) {
+ maxphys -= PAGE_SIZE;
}
if( bp->b_bcount > maxphys) {
bp->b_bcount = maxphys;
}
+
return bp->b_bcount;
}
+struct buf *
+phygetvpbuf(dev_t dev, int resid)
+{
+ struct bdevsw *bdsw;
+ int maxio;
+
+ bdsw = cdevsw[major(dev)]->d_bdev;
+ if (bdsw == NULL)
+ return getpbuf();
+
+ maxio = bdsw->d_maxio;
+ if (resid > maxio)
+ resid = maxio;
+
+ return getpbuf();
+}
+
int
rawread(dev, uio, ioflag)
dev_t dev;
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 22acde6dac09..86bf5c7c6a6c 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -11,7 +11,7 @@
* 2. Absolutely no warranty of function or purpose is made by the author
* John S. Dyson.
*
- * $Id: vfs_bio.c,v 1.143 1998/01/17 09:16:26 dyson Exp $
+ * $Id: vfs_bio.c,v 1.144 1998/01/22 17:29:51 dyson Exp $
*/
/*
@@ -1132,17 +1132,26 @@ findkvaspace:
if (vm_map_findspace(buffer_map,
vm_map_min(buffer_map), maxsize, &addr)) {
if (kvafreespace > 0) {
- int tfree = 0;
- for (bp1 = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY]);
- bp1 != NULL; bp1 = TAILQ_NEXT(bp1, b_freelist))
- if (bp1->b_kvasize != 0) {
- tfree += bp1->b_kvasize;
- bremfree(bp1);
- bfreekva(bp1);
- brelse(bp1);
- if (tfree >= maxsize)
- goto findkvaspace;
+ int totfree = 0, freed;
+ do {
+ freed = 0;
+ for (bp1 = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY]);
+ bp1 != NULL; bp1 = TAILQ_NEXT(bp1, b_freelist)) {
+ if (bp1->b_kvasize != 0) {
+ totfree += bp1->b_kvasize;
+ freed = bp1->b_kvasize;
+ bremfree(bp1);
+ bfreekva(bp1);
+ brelse(bp1);
+ break;
+ }
}
+ } while (freed);
+ /*
+ * if we found free space, then retry with the same buffer.
+ */
+ if (totfree)
+ goto findkvaspace;
}
bp->b_flags |= B_INVAL;
brelse(bp);
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index 3d82c5e95a49..407d33d8af85 100644
--- a/sys/kern/vfs_cluster.c
+++ b/sys/kern/vfs_cluster.c
@@ -33,7 +33,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94
- * $Id: vfs_cluster.c,v 1.49 1997/11/07 08:53:05 phk Exp $
+ * $Id: vfs_cluster.c,v 1.50 1998/01/06 05:16:01 dyson Exp $
*/
#include <sys/param.h>
@@ -92,12 +92,14 @@ cluster_read(vp, filesize, lblkno, size, cred, totread, seqcount, bpp)
long origtotread;
error = 0;
+ if (vp->v_maxio == 0)
+ vp->v_maxio = DFLTPHYS;
/*
* Try to limit the amount of read-ahead by a few
* ad-hoc parameters. This needs work!!!
*/
- racluster = MAXPHYS/size;
+ racluster = vp->v_maxio/size;
maxra = 2 * racluster + (totread / size);
if (maxra > MAXRA)
maxra = MAXRA;
@@ -356,11 +358,13 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
bp->b_bufsize = 0;
bp->b_npages = 0;
+ if (vp->v_maxio == 0)
+ vp->v_maxio = DFLTPHYS;
inc = btodb(size);
for (bn = blkno, i = 0; i < run; ++i, bn += inc) {
if (i != 0) {
if ((bp->b_npages * PAGE_SIZE) +
- round_page(size) > MAXPHYS)
+ round_page(size) > vp->v_maxio)
break;
if (incore(vp, lbn + i))
@@ -492,6 +496,8 @@ cluster_write(bp, filesize)
int async;
vp = bp->b_vp;
+ if (vp->v_maxio == 0)
+ vp->v_maxio = DFLTPHYS;
if (vp->v_type == VREG) {
async = vp->v_mount->mnt_flag & MNT_ASYNC;
lblocksize = vp->v_mount->mnt_stat.f_iosize;
@@ -507,7 +513,7 @@ cluster_write(bp, filesize)
if (vp->v_clen == 0 || lbn != vp->v_lastw + 1 ||
(bp->b_blkno != vp->v_lasta + btodb(lblocksize))) {
- maxclen = MAXPHYS / lblocksize - 1;
+ maxclen = vp->v_maxio / lblocksize - 1;
if (vp->v_clen != 0) {
/*
* Next block is not sequential.
@@ -703,7 +709,7 @@ cluster_wbuild(vp, size, start_lbn, len)
if ((tbp->b_bcount != size) ||
((bp->b_blkno + dbsize * i) != tbp->b_blkno) ||
- ((tbp->b_npages + bp->b_npages) > (MAXPHYS / PAGE_SIZE))) {
+ ((tbp->b_npages + bp->b_npages) > (vp->v_maxio / PAGE_SIZE))) {
splx(s);
break;
}
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 2bfc934a5386..8b757e5779fc 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $Id: vfs_subr.c,v 1.124 1998/01/17 09:16:28 dyson Exp $
+ * $Id: vfs_subr.c,v 1.125 1998/01/22 17:29:52 dyson Exp $
*/
/*
@@ -458,6 +458,7 @@ getnewvnode(tag, mp, vops, vpp)
vp->v_clen = 0;
vp->v_socket = 0;
vp->v_writecount = 0; /* XXX */
+ vp->v_maxio = 0;
} else {
simple_unlock(&vnode_free_list_slock);
vp = (struct vnode *) zalloc(vnode_zone);
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 2bfc934a5386..8b757e5779fc 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
- * $Id: vfs_subr.c,v 1.124 1998/01/17 09:16:28 dyson Exp $
+ * $Id: vfs_subr.c,v 1.125 1998/01/22 17:29:52 dyson Exp $
*/
/*
@@ -458,6 +458,7 @@ getnewvnode(tag, mp, vops, vpp)
vp->v_clen = 0;
vp->v_socket = 0;
vp->v_writecount = 0; /* XXX */
+ vp->v_maxio = 0;
} else {
simple_unlock(&vnode_free_list_slock);
vp = (struct vnode *) zalloc(vnode_zone);