summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Greenman <dg@FreeBSD.org>1995-03-02 19:36:50 +0000
committerDavid Greenman <dg@FreeBSD.org>1995-03-02 19:36:50 +0000
commit9d55322b7508e9b7ba7410b583498de463b18a52 (patch)
tree3ef09ecdd736b849ef8ba883b9926a4d9daafd1f
parent0e6a76efea76454dc7010d1ecd07a01a4aa2a8da (diff)
Notes
-rw-r--r--sys/kern/vfs_cluster.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index bec268ddc8ec..ea06f3eb0259 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.9 1995/01/24 10:00:46 davidg Exp $
+ * $Id: vfs_cluster.c,v 1.10 1995/02/22 09:39:20 davidg Exp $
*/
#include <sys/param.h>
@@ -502,24 +502,40 @@ cluster_wbuild(vp, last_bp, size, start_lbn, len, lbn)
size, vp->v_mount->mnt_stat.f_iosize);
#endif
redo:
- while ((!incore(vp, start_lbn) || start_lbn == lbn) && len) {
- ++start_lbn;
- --len;
- }
+ if( (lbn != -1) || (last_bp == 0)) {
+ while ((!(tbp = incore(vp, start_lbn)) || (tbp->b_flags & B_BUSY)
+ || (start_lbn == lbn)) && len) {
+ ++start_lbn;
+ --len;
+ }
- pb = (struct buf *) trypbuf();
- /* Get more memory for current buffer */
- if (len <= 1 || pb == 0) {
- relpbuf(pb);
- if (last_bp) {
- bawrite(last_bp);
- } else if (len) {
- bp = getblk(vp, start_lbn, size, 0, 0);
- bawrite(bp);
+ pb = (struct buf *) trypbuf();
+ /* Get more memory for current buffer */
+ if (len <= 1 || pb == 0) {
+ relpbuf(pb);
+ if (last_bp) {
+ bawrite(last_bp);
+ } else if (len) {
+ bp = getblk(vp, start_lbn, size, 0, 0);
+ bawrite(bp);
+ }
+ return;
+ }
+ tbp = getblk(vp, start_lbn, size, 0, 0);
+ } else {
+ tbp = last_bp;
+ if( tbp->b_flags & B_BUSY) {
+ printf("vfs_cluster: warning: buffer already busy\n");
+ }
+ tbp->b_flags |= B_BUSY;
+ last_bp = 0;
+ pb = (struct buf *) trypbuf();
+ if( pb == 0) {
+ bawrite(tbp);
+ return;
}
- return;
}
- tbp = getblk(vp, start_lbn, size, 0, 0);
+
if (!(tbp->b_flags & B_DELWRI)) {
relpbuf(pb);
++start_lbn;
@@ -574,6 +590,9 @@ redo:
if ((tbp->b_flags & (B_INVAL | B_CLUSTEROK)) != B_CLUSTEROK)
break;
+ if ((tbp->b_npages + bp->b_npages) > (MAXPHYS / PAGE_SIZE))
+ break;
+
/*
* Get the desired block buffer (unless it is the
* final sequential block whose buffer was passed in