diff options
author | 2003-06-25 20:52:57 +0000 | |
---|---|---|
committer | 2003-06-25 20:52:57 +0000 | |
commit | f634e4568771738bcb7dba26082c1e6903c2fe36 (patch) | |
tree | 1df485ef2c1d1c4c5fee2759ad993be560980645 /sys/kern/subr_disk.c | |
parent | Fix getopt string for -D (diff) | |
download | wireguard-openbsd-f634e4568771738bcb7dba26082c1e6903c2fe36.tar.xz wireguard-openbsd-f634e4568771738bcb7dba26082c1e6903c2fe36.zip |
implement new means of manipulating buf queues, bufq.
accessed with BUFQ macros, bufq structs support extensible, potentially
changable algorithms and queue formats. the current default scheme
should support nice priority based queuing, but is missing some vfs_bio.c
support.
only on wd.c for now, other drivers are easy converts.
as a side bonus, this makes the driver code look cleaner.
idea for the name comes from netbsd, but this scheme is incompatible.
thanks to various people for testing.
ok grange@
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r-- | sys/kern/subr_disk.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index b26bb3a40b7..cace466e490 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.22 2003/06/02 23:28:06 millert Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.23 2003/06/25 20:52:57 tedu Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -525,3 +525,38 @@ dk_mountroot() } return (*mountrootfn)(); } + +void +bufq_default_add(struct bufq *bq, struct buf *bp) +{ + struct bufq_default *bufq = (struct bufq_default *)bq; + struct proc *p = bp->b_proc; + struct buf *head; + + if (p == NULL || p->p_nice < NZERO) + head = &bufq->bufq_head[0]; + else if (p->p_nice == NZERO) + head = &bufq->bufq_head[1]; + else + head = &bufq->bufq_head[2]; + + disksort(head, bp); +} + +struct buf * +bufq_default_get(struct bufq *bq) +{ + struct bufq_default *bufq = (struct bufq_default *)bq; + struct buf *bp, *head; + int i; + + for (i = 0; i < 3; i++) { + head = &bufq->bufq_head[i]; + if ((bp = head->b_actf)) + break; + } + if (bp == NULL) + return (NULL); + head->b_actf = bp->b_actf; + return (bp); +} |