Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/kern/bufq_priocscan.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/kern/bufq_priocscan.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.3 retrieving revision 1.11 diff -u -p -r1.3 -r1.11 --- src/sys/kern/bufq_priocscan.c 2004/11/25 04:52:24 1.3 +++ src/sys/kern/bufq_priocscan.c 2008/04/30 12:09:02 1.11 @@ -1,4 +1,4 @@ -/* $NetBSD: bufq_priocscan.c,v 1.3 2004/11/25 04:52:24 yamt Exp $ */ +/* $NetBSD: bufq_priocscan.c,v 1.11 2008/04/30 12:09:02 reinoud Exp $ */ /*- * Copyright (c)2004 YAMAMOTO Takashi, @@ -27,12 +27,13 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.3 2004/11/25 04:52:24 yamt Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.11 2008/04/30 12:09:02 reinoud Exp $"); #include #include #include #include +#include #include /* @@ -46,12 +47,12 @@ struct cscan_queue { daddr_t cq_lastrawblkno; /* b_rawblkno of the last request */ }; -static int __inline cscan_empty(const struct cscan_queue *); +static inline int cscan_empty(const struct cscan_queue *); static void cscan_put(struct cscan_queue *, struct buf *, int); static struct buf *cscan_get(struct cscan_queue *, int); static void cscan_init(struct cscan_queue *); -static __inline int +static inline int cscan_empty(const struct cscan_queue *q) { @@ -167,12 +168,12 @@ static void bufq_priocscan_init(struct b static void bufq_priocscan_put(struct bufq_state *, struct buf *); static struct buf *bufq_priocscan_get(struct bufq_state *, int); -BUFQ_DEFINE(priocscan, BUFQ_PRIOCSCAN, bufq_priocscan_init); +BUFQ_DEFINE(priocscan, 40, bufq_priocscan_init); -static __inline struct cscan_queue *bufq_priocscan_selectqueue( +static inline struct cscan_queue *bufq_priocscan_selectqueue( struct bufq_priocscan *, const struct buf *); -static __inline struct cscan_queue * +static inline struct cscan_queue * bufq_priocscan_selectqueue(struct bufq_priocscan *q, const struct buf *bp) { static const int priocscan_priomap[] = { @@ -204,7 +205,7 @@ bufq_priocscan_get(struct bufq_state *bu const struct priocscan_queue *epq; const struct cscan_queue *cq; struct buf *bp; - boolean_t single; /* true if there's only one non-empty queue */ + bool single; /* true if there's only one non-empty queue */ pq = &q->bq_queue[0]; epq = pq + PRIOCSCAN_NQUEUE; @@ -219,11 +220,11 @@ bufq_priocscan_get(struct bufq_state *bu } first = pq; - single = TRUE; + single = true; for (npq = first + 1; npq < epq; npq++) { cq = &npq->q_queue; if (!cscan_empty(cq)) { - single = FALSE; + single = false; if (pq->q_burst > 0) break; pq = npq; @@ -238,7 +239,9 @@ bufq_priocscan_get(struct bufq_state *bu /* * XXX account only by number of requests. is it good enough? */ - pq->q_burst--; + if (remove) { + pq->q_burst--; + } } else { /* * no queue was selected due to burst counts @@ -256,9 +259,11 @@ bufq_priocscan_get(struct bufq_state *bu /* * reset burst counts */ - for (i = 0; i < PRIOCSCAN_NQUEUE; i++) { - pq = &q->bq_queue[i]; - pq->q_burst = priocscan_burst[i]; + if (remove) { + for (i = 0; i < PRIOCSCAN_NQUEUE; i++) { + pq = &q->bq_queue[i]; + pq->q_burst = priocscan_burst[i]; + } } /* @@ -275,6 +280,28 @@ bufq_priocscan_get(struct bufq_state *bu return bp; } +static struct buf * +bufq_priocscan_cancel(struct bufq_state *bufq, struct buf *buf) +{ + struct cscan_queue *q = bufq->bq_private; + struct bqhead *bqh; + struct buf *bq; + int idx; + + for (idx = 0; idx < 2; idx++) { + bqh = &q->cq_head[idx]; + bq = TAILQ_FIRST(bqh); + while (bq) { + if (bq == buf) { + TAILQ_REMOVE(bqh, bq, b_actq); + return buf; + } + bq = TAILQ_NEXT(bq, b_actq); + } + } + return NULL; +} + static void bufq_priocscan_init(struct bufq_state *bufq) { @@ -283,6 +310,7 @@ bufq_priocscan_init(struct bufq_state *b bufq->bq_get = bufq_priocscan_get; bufq->bq_put = bufq_priocscan_put; + bufq->bq_cancel = bufq_priocscan_cancel; bufq->bq_private = malloc(sizeof(struct bufq_priocscan), M_DEVBUF, M_ZERO);