summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2013-11-20 23:52:43 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2013-11-20 23:52:43 +0000
commit7b94095cf0a818b343aa7e09be6c62e3efe98798 (patch)
tree2a541add54d7dfcd0ddaa482ac65f779c6df33d0 /sys/kern
parent1a77a1640204b2e1d0ca6aac94fdaadd33e2d672 (diff)
now that all the direct users of disksort have been removed, we can now
safely remove disksort. most hardware and pretty much all of the kernel has moved to logical block addressing when dealing with disks, so the assumptions disksort was built against arent useful these days. it also has bad edge cases with lots of sequential writes being able to starve other io requests in the system. these issues have been addressed by becks nscan implementation, which disksort was previously deprecated in favour of. this removes the guts of disksort and the bufq wrapper around it. ok miod@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_bufq.c76
-rw-r--r--sys/kern/subr_disk.c98
2 files changed, 3 insertions, 171 deletions
diff --git a/sys/kern/kern_bufq.c b/sys/kern/kern_bufq.c
index ebfde41a7af..7c085fc793d 100644
--- a/sys/kern/kern_bufq.c
+++ b/sys/kern/kern_bufq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_bufq.c,v 1.25 2013/04/10 01:35:55 guenther Exp $ */
+/* $OpenBSD: kern_bufq.c,v 1.26 2013/11/20 23:52:42 dlg Exp $ */
/*
* Copyright (c) 2010 Thordur I. Bjornsson <thib@openbsd.org>
* Copyright (c) 2010 David Gwynne <dlg@openbsd.org>
@@ -42,13 +42,6 @@ struct bufq_impl {
int (*impl_peek)(void *);
};
-void *bufq_disksort_create(void);
-void bufq_disksort_destroy(void *);
-void bufq_disksort_queue(void *, struct buf *);
-struct buf *bufq_disksort_dequeue(void *);
-void bufq_disksort_requeue(void *, struct buf *);
-int bufq_disksort_peek(void *);
-
void *bufq_fifo_create(void);
void bufq_fifo_destroy(void *);
void bufq_fifo_queue(void *, struct buf *);
@@ -65,14 +58,6 @@ int bufq_nscan_peek(void *);
const struct bufq_impl bufq_impls[BUFQ_HOWMANY] = {
{
- bufq_disksort_create,
- bufq_disksort_destroy,
- bufq_disksort_queue,
- bufq_disksort_dequeue,
- bufq_disksort_requeue,
- bufq_disksort_peek
- },
- {
bufq_fifo_create,
bufq_fifo_destroy,
bufq_fifo_queue,
@@ -323,61 +308,6 @@ bufq_restart(void)
mtx_leave(&bufqs_mtx);
}
-/*
- * disksort implementation.
- */
-
-void *
-bufq_disksort_create(void)
-{
- return (malloc(sizeof(struct buf), M_DEVBUF, M_NOWAIT | M_ZERO));
-}
-
-void
-bufq_disksort_destroy(void *data)
-{
- free(data, M_DEVBUF);
-}
-
-void
-bufq_disksort_queue(void *data, struct buf *bp)
-{
- disksort((struct buf *)data, bp);
-}
-
-struct buf *
-bufq_disksort_dequeue(void *data)
-{
- struct buf *bufq = data;
- struct buf *bp;
-
- bp = bufq->b_actf;
- if (bp != NULL)
- bufq->b_actf = bp->b_actf;
- if (bufq->b_actf == NULL)
- bufq->b_actb = &bufq->b_actf;
-
- return (bp);
-}
-
-void
-bufq_disksort_requeue(void *data, struct buf *bp)
-{
- struct buf *bufq = data;
-
- bp->b_actf = bufq->b_actf;
- bufq->b_actf = bp;
- if (bp->b_actf == NULL)
- bufq->b_actb = &bp->b_actf;
-}
-
-int
-bufq_disksort_peek(void *data)
-{
- struct buf *bufq = data;
-
- return (bufq->b_actf != NULL);
-}
/*
* fifo implementation
@@ -444,9 +374,7 @@ bufq_fifo_peek(void *data)
* nscan implementation
*/
-#define BUF_INORDER(ba, bb) \
- (((ba)->b_cylinder < (bb)->b_cylinder) || \
- ((ba)->b_cylinder == (bb)->b_cylinder && (ba)->b_blkno < (bb)->b_blkno))
+#define BUF_INORDER(ba, bb) ((ba)->b_blkno < (bb)->b_blkno)
#define dsentries b_bufq.bufq_data_nscan.bqf_entries
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 57a4027e57c..fccc90c1a58 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.158 2013/11/18 17:45:01 deraadt Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.159 2013/11/20 23:52:42 dlg Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -91,99 +91,6 @@ void sr_map_root(void);
void disk_attach_callback(void *, void *);
/*
- * Seek sort for disks. We depend on the driver which calls us using b_resid
- * as the current cylinder number.
- *
- * The argument ap structure holds a b_actf activity chain pointer on which we
- * keep two queues, sorted in ascending cylinder order. The first queue holds
- * those requests which are positioned after the current cylinder (in the first
- * request); the second holds requests which came in after their cylinder number
- * was passed. Thus we implement a one way scan, retracting after reaching the
- * end of the drive to the first request on the second queue, at which time it
- * becomes the first queue.
- *
- * A one-way scan is natural because of the way UNIX read-ahead blocks are
- * allocated.
- */
-
-void
-disksort(struct buf *ap, struct buf *bp)
-{
- struct buf *bq;
-
- /* If the queue is empty, then it's easy. */
- if (ap->b_actf == NULL) {
- bp->b_actf = NULL;
- ap->b_actf = bp;
- return;
- }
-
- /*
- * If we lie after the first (currently active) request, then we
- * must locate the second request list and add ourselves to it.
- */
- bq = ap->b_actf;
- if (bp->b_cylinder < bq->b_cylinder) {
- while (bq->b_actf) {
- /*
- * Check for an ``inversion'' in the normally ascending
- * cylinder numbers, indicating the start of the second
- * request list.
- */
- if (bq->b_actf->b_cylinder < bq->b_cylinder) {
- /*
- * Search the second request list for the first
- * request at a larger cylinder number. We go
- * before that; if there is no such request, we
- * go at end.
- */
- do {
- if (bp->b_cylinder <
- bq->b_actf->b_cylinder)
- goto insert;
- if (bp->b_cylinder ==
- bq->b_actf->b_cylinder &&
- bp->b_blkno < bq->b_actf->b_blkno)
- goto insert;
- bq = bq->b_actf;
- } while (bq->b_actf);
- goto insert; /* after last */
- }
- bq = bq->b_actf;
- }
- /*
- * No inversions... we will go after the last, and
- * be the first request in the second request list.
- */
- goto insert;
- }
- /*
- * Request is at/after the current request...
- * sort in the first request list.
- */
- while (bq->b_actf) {
- /*
- * We want to go after the current request if there is an
- * inversion after it (i.e. it is the end of the first
- * request list), or if the next request is a larger cylinder
- * than our request.
- */
- if (bq->b_actf->b_cylinder < bq->b_cylinder ||
- bp->b_cylinder < bq->b_actf->b_cylinder ||
- (bp->b_cylinder == bq->b_actf->b_cylinder &&
- bp->b_blkno < bq->b_actf->b_blkno))
- goto insert;
- bq = bq->b_actf;
- }
- /*
- * Neither a second list nor a larger request... we go at the end of
- * the first list, which is the same as the end of the whole schebang.
- */
-insert: bp->b_actf = bq->b_actf;
- bq->b_actf = bp;
-}
-
-/*
* Compute checksum for disk label.
*/
u_int
@@ -720,9 +627,6 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp)
bp->b_bcount = sz << DEV_BSHIFT;
}
- /* calculate cylinder for disksort to order transfers with */
- bp->b_cylinder = (bp->b_blkno + DL_SECTOBLK(lp, DL_GETPOFFSET(p))) /
- DL_SECTOBLK(lp, lp->d_secpercyl);
return (0);
bad: