-/* $OpenBSD: vfs_bio.c,v 1.13 1997/01/05 11:09:01 niklas Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.14 1997/04/14 04:23:23 tholo Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*-
if (ISSET(bp->b_flags, (B_NOCACHE|B_ERROR)))
SET(bp->b_flags, B_INVAL);
+ if (ISSET(bp->b_flags, B_VFLUSH)) {
+ /*
+ * This is a delayed write buffer that was just flushed to
+ * disk. It is still on the LRU queue. If it's become
+ * invalid, then we need to move it to a different queue;
+ * otherwise leave it in its current position.
+ */
+ CLR(bp->b_flags, B_VFLUSH);
+ if (!ISSET(bp->b_flags, B_ERROR|B_INVAL|B_LOCKED|B_AGE))
+ goto already_queued;
+ else
+ bremfree(bp);
+ }
+
if ((bp->b_bufsize <= 0) || ISSET(bp->b_flags, B_INVAL)) {
/*
* If it's invalid or empty, dissociate it from its vnode
binstailfree(bp, bufq);
}
+already_queued:
/* Unlock the buffer. */
CLR(bp->b_flags, (B_AGE | B_ASYNC | B_BUSY | B_NOCACHE));
return (0);
}
+ if (ISSET(bp->b_flags, B_VFLUSH)) {
+ /*
+ * This is a delayed write buffer being flushed to disk. Make
+ * sure it gets aged out of the queue when it's finished, and
+ * leave it off the LRU queue.
+ */
+ CLR(bp->b_flags, B_VFLUSH);
+ SET(bp->b_flags, B_AGE);
+ splx(s);
+ goto start;
+ }
+
/* Buffer is no longer on free lists. */
SET(bp->b_flags, B_BUSY);
/* If buffer was a delayed write, start it, and go back to the top. */
if (ISSET(bp->b_flags, B_DELWRI)) {
splx(s);
- bawrite (bp);
+ /*
+ * This buffer has gone through the LRU, so make sure it gets
+ * reused ASAP.
+ */
+ SET(bp->b_flags, B_AGE);
+ bawrite(bp);
goto start;
}
-/* $OpenBSD: vfs_subr.c,v 1.8 1997/02/24 14:20:02 niklas Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.9 1997/04/14 04:23:26 tholo Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
return (error);
break;
}
- bremfree(bp);
- bp->b_flags |= B_BUSY;
+ bp->b_flags |= B_BUSY | B_VFLUSH;
splx(s);
/*
* XXX Since there are no node locks for NFS, I believe
continue;
if ((bp->b_flags & B_DELWRI) == 0)
panic("vflushbuf: not dirty");
- bremfree(bp);
- bp->b_flags |= B_BUSY;
+ bp->b_flags |= B_BUSY | B_VFLUSH;
splx(s);
/*
* Wait for I/O associated with indirect blocks to complete,
-/* $OpenBSD: buf.h,v 1.5 1996/06/11 03:25:14 tholo Exp $ */
-/* $NetBSD: buf.h,v 1.24 1996/02/18 11:55:45 fvdl Exp $ */
+/* $OpenBSD: buf.h,v 1.6 1997/04/14 04:23:21 tholo Exp $ */
+/* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */
#define B_WRITEINPROG 0x01000000 /* Write in progress. */
#define B_XXX 0x02000000 /* Debugging flag. */
+#define B_VFLUSH 0x04000000 /* Buffer is being synced. */
/*
* This structure describes a clustered I/O. It is stored in the b_saveaddr