summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/vfs_bio.c50
-rw-r--r--sys/kern/vfs_cluster.c17
-rw-r--r--sys/nfs/nfs_bio.c22
-rw-r--r--sys/nfs/nfs_syscalls.c6
-rw-r--r--sys/nfs/nfs_vnops.c26
-rw-r--r--sys/sys/buf.h5
-rw-r--r--sys/ufs/ffs/ffs_softdep.c10
-rw-r--r--sys/ufs/lfs/lfs_bio.c8
-rw-r--r--sys/ufs/lfs/lfs_segment.c14
9 files changed, 86 insertions, 72 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index eae71abafb5..405a1173f6d 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.29 2001/02/21 23:24:30 csapuntz Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.30 2001/02/23 14:52:50 csapuntz Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*-
@@ -107,6 +107,9 @@ static __inline struct buf *bio_doread __P((struct vnode *, daddr_t, int,
struct ucred *, int));
int count_lock_queue __P((void));
+
+int lodirtybufs, hidirtybufs, numdirtybufs;
+
void
bremfree(bp)
struct buf *bp;
@@ -164,6 +167,12 @@ bufinit()
binsheadfree(bp, dp);
binshash(bp, &invalhash);
}
+
+ hidirtybufs = nbuf / 4 + 20;
+ numdirtybufs = 0;
+
+ lodirtybufs = hidirtybufs / 2;
+
}
static __inline struct buf *
@@ -327,9 +336,10 @@ bwrite(bp)
* to do this now, because if we don't, the vnode may not
* be properly notified that its I/O has completed.
*/
- if (wasdelayed)
+ if (wasdelayed) {
+ --numdirtybufs;
reassignbuf(bp, bp->b_vp);
- else
+ } else
curproc->p_stats->p_ru.ru_oublock++;
@@ -384,6 +394,7 @@ bdwrite(bp)
SET(bp->b_flags, B_DELWRI);
s = splbio();
reassignbuf(bp, bp->b_vp);
+ ++numdirtybufs;
splx(s);
curproc->p_stats->p_ru.ru_oublock++; /* XXX */
}
@@ -413,20 +424,31 @@ bawrite(bp)
VOP_BWRITE(bp);
}
+/*
+ * Must be called at splbio()
+ */
void
-bdirty(bp)
+buf_dirty(bp)
struct buf *bp;
{
- struct proc *p = curproc; /* XXX */
- int s;
-
if (ISSET(bp->b_flags, B_DELWRI) == 0) {
SET(bp->b_flags, B_DELWRI);
- s = splbio();
reassignbuf(bp, bp->b_vp);
- splx(s);
- if (p)
- p->p_stats->p_ru.ru_oublock++;
+ ++numdirtybufs;
+ }
+}
+
+/*
+ * Must be called at splbio()
+ */
+void
+buf_undirty(bp)
+ struct buf *bp;
+{
+ if (ISSET(bp->b_flags, B_DELWRI)) {
+ CLR(bp->b_flags, B_DELWRI);
+ reassignbuf(bp, bp->b_vp);
+ --numdirtybufs;
}
}
@@ -478,7 +500,11 @@ brelse(bp)
if (LIST_FIRST(&bp->b_dep) != NULL)
buf_deallocate(bp);
- CLR(bp->b_flags, B_DELWRI);
+ if (ISSET(bp->b_flags, B_DELWRI)) {
+ --numdirtybufs;
+ CLR(bp->b_flags, B_DELWRI);
+ }
+
if (bp->b_vp) {
reassignbuf(bp, bp->b_vp);
brelvp(bp);
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index 46fbe3ae206..6f99d0f7077 100644
--- a/sys/kern/vfs_cluster.c
+++ b/sys/kern/vfs_cluster.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_cluster.c,v 1.19 2001/02/23 14:42:38 csapuntz Exp $ */
+/* $OpenBSD: vfs_cluster.c,v 1.20 2001/02/23 14:52:50 csapuntz Exp $ */
/* $NetBSD: vfs_cluster.c,v 1.12 1996/04/22 01:39:05 christos Exp $ */
/*-
@@ -700,13 +700,6 @@ redo:
panic("Clustered write to wrong blocks");
}
- /*
- * We might as well AGE the buffer here; it's either empty, or
- * contains data that we couldn't get rid of (but wanted to).
- */
- tbp->b_flags &= ~(B_READ | B_DONE | B_ERROR | B_DELWRI);
- tbp->b_flags |= (B_ASYNC | B_AGE);
-
if (LIST_FIRST(&tbp->b_dep) != NULL)
buf_start(tbp);
@@ -717,7 +710,13 @@ redo:
tbp->b_bufsize -= size;
s = splbio();
- reassignbuf(tbp, tbp->b_vp); /* put on clean list */
+ buf_undirty(bp);
+ /*
+ * We might as well AGE the buffer here; it's either empty, or
+ * contains data that we couldn't get rid of (but wanted to).
+ */
+ tbp->b_flags &= ~(B_READ | B_DONE | B_ERROR);
+ tbp->b_flags |= (B_ASYNC | B_AGE);
++tbp->b_vp->v_numoutput;
splx(s);
b_save->bs_children[i] = tbp;
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c
index a7c8598f465..950fe138235 100644
--- a/sys/nfs/nfs_bio.c
+++ b/sys/nfs/nfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_bio.c,v 1.17 2001/02/23 14:42:38 csapuntz Exp $ */
+/* $OpenBSD: nfs_bio.c,v 1.18 2001/02/23 14:52:50 csapuntz Exp $ */
/* $NetBSD: nfs_bio.c,v 1.25.4.2 1996/07/08 20:47:04 jtc Exp $ */
/*
@@ -746,10 +746,8 @@ nfs_asyncio(bp, cred)
* is currently doing a write for this file and will pick up the
* delayed writes before going back to sleep.
*/
- bp->b_flags |= B_DELWRI;
-
s = splbio();
- reassignbuf(bp, bp->b_vp);
+ buf_dirty(bp);
splx(s);
biodone(bp);
return (0);
@@ -909,20 +907,12 @@ nfs_doio(bp, cr, p)
* B_DELWRI and B_NEEDCOMMIT flags.
*/
if (error == EINTR || (!error && (bp->b_flags & B_NEEDCOMMIT))) {
- bp->b_flags |= B_DELWRI;
-
- /*
- * Since for the B_ASYNC case, nfs_bwrite() has reassigned the
- * buffer to the clean list, we have to reassign it back to the
- * dirty one. Ugh.
- */
- if (bp->b_flags & B_ASYNC) {
s = splbio();
- reassignbuf(bp, vp);
+ buf_dirty(bp);
splx(s);
- }
- else if (error)
- bp->b_flags |= B_EINTR;
+
+ if (!(bp->b_flags & B_ASYNC) && error)
+ bp->b_flags |= B_EINTR;
} else {
if (error) {
bp->b_flags |= B_ERROR;
diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c
index 74769e1d1f0..6463d1ce197 100644
--- a/sys/nfs/nfs_syscalls.c
+++ b/sys/nfs/nfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_syscalls.c,v 1.16 2000/11/09 17:23:38 art Exp $ */
+/* $OpenBSD: nfs_syscalls.c,v 1.17 2001/02/23 14:52:51 csapuntz Exp $ */
/* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */
/*
@@ -906,8 +906,8 @@ nfssvc_iod(p)
* up to, but not including nfs_strategy().
*/
if (nbp) {
- nbp->b_flags &= ~(B_READ|B_DONE|B_ERROR|B_DELWRI);
- reassignbuf(nbp, nbp->b_vp);
+ nbp->b_flags &= ~(B_READ|B_DONE|B_ERROR);
+ buf_undirty(bp);
nbp->b_vp->v_numoutput++;
}
splx(s);
diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c
index 87dc935fc5c..a49bb3c8fbe 100644
--- a/sys/nfs/nfs_vnops.c
+++ b/sys/nfs/nfs_vnops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vnops.c,v 1.27 2001/02/09 22:26:05 mickey Exp $ */
+/* $OpenBSD: nfs_vnops.c,v 1.28 2001/02/23 14:52:51 csapuntz Exp $ */
/* $NetBSD: nfs_vnops.c,v 1.62.4.1 1996/07/08 20:26:52 jtc Exp $ */
/*
@@ -2762,11 +2762,11 @@ again:
brelse(bp);
else {
s = splbio();
+ buf_undirty(bp);
vp->v_numoutput++;
bp->b_flags |= B_ASYNC;
- bp->b_flags &= ~(B_READ|B_DONE|B_ERROR|B_DELWRI);
+ bp->b_flags &= ~(B_READ|B_DONE|B_ERROR);
bp->b_dirtyoff = bp->b_dirtyend = 0;
- reassignbuf(bp, vp);
splx(s);
biodone(bp);
}
@@ -3049,16 +3049,14 @@ nfs_writebp(bp, force)
bp, bp->b_vp, bp->b_validoff, bp->b_validend, bp->b_dirtyoff,
bp->b_dirtyend);
#endif
- bp->b_flags &= ~(B_READ|B_DONE|B_ERROR|B_DELWRI);
+ bp->b_flags &= ~(B_READ|B_DONE|B_ERROR);
s = splbio();
- if (oldflags & B_ASYNC) {
- if (oldflags & B_DELWRI) {
- reassignbuf(bp, bp->b_vp);
- } else if (p) {
- ++p->p_stats->p_ru.ru_oublock;
- }
- }
+ buf_undirty(bp);
+
+ if ((oldflags & B_ASYNC) && !(oldflags & B_DELWRI) && p)
+ ++p->p_stats->p_ru.ru_oublock;
+
bp->b_vp->v_numoutput++;
splx(s);
@@ -3088,11 +3086,7 @@ nfs_writebp(bp, force)
if( (oldflags & B_ASYNC) == 0) {
int rtval = biowait(bp);
- if (oldflags & B_DELWRI) {
- s = splbio();
- reassignbuf(bp, bp->b_vp);
- splx(s);
- } else if (p) {
+ if (!(oldflags & B_DELWRI) && p) {
++p->p_stats->p_ru.ru_oublock;
}
brelse(bp);
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index 276d047bc96..d525bfab47e 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.h,v 1.17 2001/02/23 14:42:37 csapuntz Exp $ */
+/* $OpenBSD: buf.h,v 1.18 2001/02/23 14:52:49 csapuntz Exp $ */
/* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */
/*
@@ -204,7 +204,8 @@ int breadn __P((struct vnode *, daddr_t, int, daddr_t *, int *, int,
void brelse __P((struct buf *));
void bremfree __P((struct buf *));
void bufinit __P((void));
-void bdirty __P((struct buf *));
+void buf_dirty __P((struct buf *));
+void buf_undirty __P((struct buf *));
int bwrite __P((struct buf *));
struct buf *getblk __P((struct vnode *, daddr_t, int, int, int));
struct buf *geteblk __P((int));
diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c
index 12d9f631618..570beca3f30 100644
--- a/sys/ufs/ffs/ffs_softdep.c
+++ b/sys/ufs/ffs/ffs_softdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_softdep.c,v 1.12 2001/02/21 23:24:31 csapuntz Exp $ */
+/* $OpenBSD: ffs_softdep.c,v 1.13 2001/02/23 14:52:51 csapuntz Exp $ */
/*
* Copyright 1998, 2000 Marshall Kirk McKusick. All Rights Reserved.
*
@@ -3231,7 +3231,7 @@ softdep_disk_write_complete(bp)
WORKLIST_INSERT(&reattach, wk);
if ((bp->b_flags & B_DELWRI) == 0)
stat_indir_blk_ptrs++;
- bdirty(bp);
+ buf_dirty(bp);
continue;
default:
@@ -3390,7 +3390,7 @@ handle_written_inodeblock(inodedep, bp)
inodedep->id_savedino = NULL;
if ((bp->b_flags & B_DELWRI) == 0)
stat_inode_bitmap++;
- bdirty(bp);
+ buf_dirty(bp);
return (1);
}
/*
@@ -3439,7 +3439,7 @@ handle_written_inodeblock(inodedep, bp)
* its correct form.
*/
if (hadchanges)
- bdirty(bp);
+ buf_dirty(bp);
/*
* Process any allocdirects that completed during the update.
*/
@@ -3624,7 +3624,7 @@ handle_written_filepage(pagedep, bp)
if (chgs) {
if ((bp->b_flags & B_DELWRI) == 0)
stat_dir_entry++;
- bdirty(bp);
+ buf_dirty(bp);
}
/*
* If no dependencies remain, the pagedep will be freed.
diff --git a/sys/ufs/lfs/lfs_bio.c b/sys/ufs/lfs/lfs_bio.c
index 5ce206bec8d..f95957927cb 100644
--- a/sys/ufs/lfs/lfs_bio.c
+++ b/sys/ufs/lfs/lfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lfs_bio.c,v 1.5 1996/07/21 08:05:39 tholo Exp $ */
+/* $OpenBSD: lfs_bio.c,v 1.6 2001/02/23 14:52:52 csapuntz Exp $ */
/* $NetBSD: lfs_bio.c,v 1.5 1996/02/09 22:28:49 christos Exp $ */
/*
@@ -119,9 +119,10 @@ lfs_bwrite(v)
ip->i_flag |= IN_CHANGE | IN_MODIFIED | IN_UPDATE;
fs->lfs_avail -= db;
++locked_queue_count;
- bp->b_flags |= B_DELWRI | B_LOCKED;
+ bp->b_flags |= B_LOCKED;
TAILQ_INSERT_TAIL(&bdirties, bp, b_synclist);
bp->b_synctime = time.tv_sec + 30;
+ s = splbio();
if (bdirties.tqh_first == bp) {
untimeout((void (*)__P((void *)))wakeup,
&bdirties);
@@ -129,8 +130,7 @@ lfs_bwrite(v)
&bdirties, 30 * hz);
}
bp->b_flags &= ~(B_READ | B_ERROR);
- s = splbio();
- reassignbuf(bp, bp->b_vp);
+ buf_dirty(bp);
splx(s);
}
brelse(bp);
diff --git a/sys/ufs/lfs/lfs_segment.c b/sys/ufs/lfs/lfs_segment.c
index 6efc84df7ee..5ac2a62cd81 100644
--- a/sys/ufs/lfs/lfs_segment.c
+++ b/sys/ufs/lfs/lfs_segment.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lfs_segment.c,v 1.8 1999/01/11 05:12:39 millert Exp $ */
+/* $OpenBSD: lfs_segment.c,v 1.9 2001/02/23 14:52:52 csapuntz Exp $ */
/* $NetBSD: lfs_segment.c,v 1.4 1996/02/09 22:28:54 christos Exp $ */
/*
@@ -907,8 +907,9 @@ lfs_writeseg(fs, sp)
--locked_queue_count;
if (bp->b_flags & B_DELWRI)
TAILQ_REMOVE(&bdirties, bp, b_synclist);
- bp->b_flags &= ~(B_ERROR | B_READ | B_DELWRI |
+ bp->b_flags &= ~(B_ERROR | B_READ |
B_LOCKED | B_GATHERED);
+ buf_undirty(bp);
if (bp->b_flags & B_CALL) {
/* if B_CALL, it was created with newbuf */
brelvp(bp);
@@ -918,7 +919,6 @@ lfs_writeseg(fs, sp)
} else {
bremfree(bp);
bp->b_flags |= B_DONE;
- reassignbuf(bp, bp->b_vp);
brelse(bp);
}
}
@@ -982,9 +982,13 @@ lfs_writesuper(fs)
/* XXX Toggle between first two superblocks; for now just write first */
bp->b_dev = i_dev;
bp->b_flags |= B_BUSY | B_CALL | B_ASYNC;
- if (bp->b_flags & B_DELWRI)
+ if (bp->b_flags & B_DELWRI) {
+ panic ("lfs_writesuper: buffer should never be delayed */
+#if 0
TAILQ_REMOVE(&bdirties, bp, b_synclist);
- bp->b_flags &= ~(B_DONE | B_ERROR | B_READ | B_DELWRI);
+#endif
+ }
+ bp->b_flags &= ~(B_DONE | B_ERROR | B_READ);
bp->b_iodone = lfs_supercallback;
vop_strategy_a.a_desc = VDESC(vop_strategy);
vop_strategy_a.a_bp = bp;