commit ff99cb2ffd6a96106021164a402d2118933bf0a5 from: jsg date: Sat May 17 10:13:40 2025 UTC remove unused bufq_switch() bufq_requeue() ok kn@ miod@ tedu@ commit - 3161ed12f319d0321c3cb79df486f8a9c79d2085 commit + ff99cb2ffd6a96106021164a402d2118933bf0a5 blob - cc9c5a033bb242d86eff647d65bf8b358a54b37e blob + e30150b7da820a17d69a19f15660be18341ab486 --- share/man/man9/bufq_init.9 +++ share/man/man9/bufq_init.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bufq_init.9,v 1.6 2015/12/25 20:50:57 bentley Exp $ +.\" $OpenBSD: bufq_init.9,v 1.7 2025/05/17 10:13:40 jsg Exp $ .\" .\" Copyright (c) 2013 David Gwynne .\" @@ -14,16 +14,14 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 25 2015 $ +.Dd $Mdocdate: May 17 2025 $ .Dt BUFQ_INIT 9 .Os .Sh NAME .Nm bufq_init , -.Nm bufq_switch , .Nm bufq_destroy , .Nm bufq_queue , .Nm bufq_dequeue , -.Nm bufq_requeue , .Nm bufq_peek , .Nm bufq_drain .\" .Nm bufq_wait , @@ -35,16 +33,12 @@ .In sys/buf.h .Ft int .Fn bufq_init "struct bufq *bufq" "int type" -.Ft int -.Fn bufq_switch "struct bufq *bufq" "int type" .Ft void .Fn bufq_destroy "struct bufq *bufq" .Ft void .Fn bufq_queue "struct bufq *bufq" "struct buf *bp" .Ft struct buf * .Fn bufq_dequeue "struct bufq *bufq" -.Ft void -.Fn bufq_requeue "struct bufq *bufq" "struct buf *bp" .Ft int .Fn bufq_peek "struct bufq *bufq" .Ft void @@ -65,18 +59,10 @@ by the .Fa type argument. .Pp -.Fn bufq_switch -can be used to change the scheduler currently used by -.Fa bufq -to the algorithm specified by -.Fa type . -.Pp The .Fa type argument to .Fn bufq_init -and -.Fn bufq_switch can be one of the following scheduling algorithms: .Pp .Bl -tag -offset indent -width BUFQ_DEFAULT -compact @@ -106,12 +92,6 @@ is used to get the next buf the has scheduled to be serviced by a disk. The buf will be removed from the queue. .Pp -.Fn bufq_requeue -can be used to return a previously dequeued buf specified by -.Fa bp -to the head of the queue of -.Fa bufq . -.Pp .Fn bufq_peek allows the caller to determine if there are more bufs queued on .Fa bufq @@ -126,23 +106,19 @@ marks them as failed with an error, and returns them to the block layer via .Xr biodone 9 . .Sh CONTEXT -.Fn bufq_init , -.Fn bufq_switch , +.Fn bufq_init and .Fn bufq_destroy can be called during autoconf, or from process context. .Pp .Nm bufq_queue , .Nm bufq_dequeue , -.Nm bufq_requeue , .Nm bufq_peek , and .Nm bufq_drain can be called during autoconf, from process context, or from interrupt context. .Sh RETURN VALUES .Fn bufq_init -and -.Fn bufq_switch will return 0 on success, or an error code as per .Xr errno 2 . .Pp blob - 505770176c4b746a97a264f6c13b706b907d3c92 blob + 5f5be3b74dfd5720697babfedc6e4b5355dce47d --- sys/kern/kern_bufq.c +++ sys/kern/kern_bufq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_bufq.c,v 1.35 2022/12/05 23:18:37 deraadt Exp $ */ +/* $OpenBSD: kern_bufq.c,v 1.36 2025/05/17 10:13:40 jsg Exp $ */ /* * Copyright (c) 2010 Thordur I. Bjornsson * Copyright (c) 2010 David Gwynne @@ -35,7 +35,6 @@ struct bufq_impl { void (*impl_queue)(void *, struct buf *); struct buf *(*impl_dequeue)(void *); - void (*impl_requeue)(void *, struct buf *); int (*impl_peek)(void *); }; @@ -43,14 +42,12 @@ void *bufq_fifo_create(void); void bufq_fifo_destroy(void *); void bufq_fifo_queue(void *, struct buf *); struct buf *bufq_fifo_dequeue(void *); -void bufq_fifo_requeue(void *, struct buf *); int bufq_fifo_peek(void *); void *bufq_nscan_create(void); void bufq_nscan_destroy(void *); void bufq_nscan_queue(void *, struct buf *); struct buf *bufq_nscan_dequeue(void *); -void bufq_nscan_requeue(void *, struct buf *); int bufq_nscan_peek(void *); const struct bufq_impl bufq_impls[BUFQ_HOWMANY] = { @@ -59,7 +56,6 @@ const struct bufq_impl bufq_impls[BUFQ_HOWMANY] = { bufq_fifo_destroy, bufq_fifo_queue, bufq_fifo_dequeue, - bufq_fifo_requeue, bufq_fifo_peek }, { @@ -67,7 +63,6 @@ const struct bufq_impl bufq_impls[BUFQ_HOWMANY] = { bufq_nscan_destroy, bufq_nscan_queue, bufq_nscan_dequeue, - bufq_nscan_requeue, bufq_nscan_peek } }; @@ -116,47 +111,6 @@ bufq_init(struct bufq *bq, int type) return (0); } -int -bufq_switch(struct bufq *bq, int type) -{ - void *data; - void *odata; - int otype; - struct buf *bp; - int ret; - - mtx_enter(&bq->bufq_mtx); - ret = (bq->bufq_type == type); - mtx_leave(&bq->bufq_mtx); - if (ret) - return (0); - - data = bufq_impls[type].impl_create(); - if (data == NULL) - return (ENOMEM); - - mtx_enter(&bq->bufq_mtx); - if (bq->bufq_type != type) { /* might have changed during create */ - odata = bq->bufq_data; - otype = bq->bufq_type; - - while ((bp = bufq_impls[otype].impl_dequeue(odata)) != NULL) - bufq_impls[type].impl_queue(data, bp); - - bq->bufq_data = data; - bq->bufq_type = type; - bq->bufq_impl = &bufq_impls[type]; - } else { - otype = type; - odata = data; - } - mtx_leave(&bq->bufq_mtx); - - bufq_impls[otype].impl_destroy(odata); - - return (0); -} - void bufq_destroy(struct bufq *bq) { @@ -201,14 +155,6 @@ bufq_dequeue(struct bufq *bq) return (bp); } -void -bufq_requeue(struct bufq *bq, struct buf *bp) -{ - mtx_enter(&bq->bufq_mtx); - bq->bufq_impl->impl_requeue(bq->bufq_data, bp); - mtx_leave(&bq->bufq_mtx); -} - int bufq_peek(struct bufq *bq) { @@ -354,14 +300,6 @@ bufq_fifo_dequeue(void *data) return (bp); } -void -bufq_fifo_requeue(void *data, struct buf *bp) -{ - struct bufq_fifo_head *head = data; - - SIMPLEQ_INSERT_HEAD(head, bp, b_bufq.bufq_data_fifo.bqf_entries); -} - int bufq_fifo_peek(void *data) { @@ -491,14 +429,6 @@ bufq_nscan_dequeue(void *vdata) return (bp); } -void -bufq_nscan_requeue(void *vdata, struct buf *bp) -{ - struct bufq_nscan_data *data = vdata; - - SIMPLEQ_INSERT_HEAD(&data->fifo, bp, dsentries); -} - int bufq_nscan_peek(void *vdata) { blob - c956f7c7cb781f812844fbdf4d33f8fd63195611 blob + 5c08b91e6ef97840b7c17b4e95d4b666f6a41efc --- sys/sys/buf.h +++ sys/sys/buf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: buf.h,v 1.116 2025/04/13 09:52:43 jsg Exp $ */ +/* $OpenBSD: buf.h,v 1.117 2025/05/17 10:13:40 jsg Exp $ */ /* $NetBSD: buf.h,v 1.25 1997/04/09 21:12:17 mycroft Exp $ */ /* @@ -84,12 +84,10 @@ struct bufq { }; int bufq_init(struct bufq *, int); -int bufq_switch(struct bufq *, int); void bufq_destroy(struct bufq *); void bufq_queue(struct bufq *, struct buf *); struct buf *bufq_dequeue(struct bufq *); -void bufq_requeue(struct bufq *, struct buf *); int bufq_peek(struct bufq *); void bufq_drain(struct bufq *);