Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src The buffer returned by BUFQ_PEEK must remain the same until ...
details: https://anonhg.NetBSD.org/src/rev/42f9fae020c3
branches: trunk
changeset: 534372:42f9fae020c3
user: hannken <hannken%NetBSD.org@localhost>
date: Tue Jul 23 14:00:16 2002 +0000
description:
The buffer returned by BUFQ_PEEK must remain the same until BUFQ_GET is
called. It may be used as the "current" buffer.
diffstat:
share/man/man9/bufq.9 | 5 +++-
sys/kern/subr_disk.c | 59 ++++++++++++++++++++++++++++++--------------------
2 files changed, 39 insertions(+), 25 deletions(-)
diffs (122 lines):
diff -r 996bf15be975 -r 42f9fae020c3 share/man/man9/bufq.9
--- a/share/man/man9/bufq.9 Tue Jul 23 11:08:28 2002 +0000
+++ b/share/man/man9/bufq.9 Tue Jul 23 14:00:16 2002 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: bufq.9,v 1.2 2002/07/21 15:32:17 hannken Exp $
+.\" $NetBSD: bufq.9,v 1.3 2002/07/23 14:00:17 hannken Exp $
.\"
.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -120,6 +120,9 @@
if the queue is empty.
.It Fn BUFQ_PEEK "bufq"
Get the next buf from the queue without removal.
+The next buf will remain the same until
+.Fn BUFQ_GET
+is called.
Returns
.Dv NULL
if the queue is empty.
diff -r 996bf15be975 -r 42f9fae020c3 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c Tue Jul 23 11:08:28 2002 +0000
+++ b/sys/kern/subr_disk.c Tue Jul 23 14:00:16 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.40 2002/07/21 15:32:19 hannken Exp $ */
+/* $NetBSD: subr_disk.c,v 1.41 2002/07/23 14:00:16 hannken Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.40 2002/07/21 15:32:19 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.41 2002/07/23 14:00:16 hannken Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -659,6 +659,7 @@
struct bufq_prio {
TAILQ_HEAD(, buf) bq_read, bq_write; /* actual list of buffers */
struct buf *bq_write_next; /* next request in bq_write */
+ struct buf *bq_next; /* current request */
int bq_read_burst; /* # of consecutive reads */
};
@@ -881,37 +882,45 @@
struct buf *bp;
/*
- * If at least one list is empty, select the other.
+ * If no current request, get next from the lists.
*/
-
- if (TAILQ_FIRST(&prio->bq_read) == NULL) {
- bp = prio->bq_write_next;
- prio->bq_read_burst = 0;
- } else if (prio->bq_write_next == NULL) {
- bp = TAILQ_FIRST(&prio->bq_read);
- prio->bq_read_burst = 0;
- } else {
+ if (prio->bq_next == NULL) {
/*
- * Both list have requests. Select the read list up
- * to PRIO_READ_BURST times, then select the write
- * list PRIO_WRITE_REQ times.
+ * If at least one list is empty, select the other.
*/
- if (prio->bq_read_burst++ < PRIO_READ_BURST)
- bp = TAILQ_FIRST(&prio->bq_read);
- else if (prio->bq_read_burst < PRIO_READ_BURST + PRIO_WRITE_REQ)
- bp = prio->bq_write_next;
- else {
- bp = TAILQ_FIRST(&prio->bq_read);
+ if (TAILQ_FIRST(&prio->bq_read) == NULL) {
+ prio->bq_next = prio->bq_write_next;
+ prio->bq_read_burst = 0;
+ } else if (prio->bq_write_next == NULL) {
+ prio->bq_next = TAILQ_FIRST(&prio->bq_read);
prio->bq_read_burst = 0;
+ } else {
+ /*
+ * Both list have requests. Select the read list up
+ * to PRIO_READ_BURST times, then select the write
+ * list PRIO_WRITE_REQ times.
+ */
+
+ if (prio->bq_read_burst++ < PRIO_READ_BURST)
+ prio->bq_next = TAILQ_FIRST(&prio->bq_read);
+ else if (prio->bq_read_burst <
+ PRIO_READ_BURST + PRIO_WRITE_REQ)
+ prio->bq_next = prio->bq_write_next;
+ else {
+ prio->bq_next = TAILQ_FIRST(&prio->bq_read);
+ prio->bq_read_burst = 0;
+ }
}
}
- if (bp != NULL && remove) {
- if ((bp->b_flags & B_READ) == B_READ)
- TAILQ_REMOVE(&prio->bq_read, bp, b_actq);
+ bp = prio->bq_next;
+
+ if (prio->bq_next != NULL && remove) {
+ if ((prio->bq_next->b_flags & B_READ) == B_READ)
+ TAILQ_REMOVE(&prio->bq_read, prio->bq_next, b_actq);
else {
- TAILQ_REMOVE(&prio->bq_write, bp, b_actq);
+ TAILQ_REMOVE(&prio->bq_write, prio->bq_next, b_actq);
/*
* Advance the write pointer.
*/
@@ -921,6 +930,8 @@
prio->bq_write_next =
TAILQ_FIRST(&prio->bq_write);
}
+
+ prio->bq_next = NULL;
}
return(bp);
Home |
Main Index |
Thread Index |
Old Index