add some bufq helper functions.

#if 0'ed out as there is no user currently.
This commit is contained in:
yamt 2005-10-16 02:02:23 +00:00
parent ba70e96a09
commit 9f4759ccce
3 changed files with 35 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_bufq.c,v 1.4 2005/10/16 00:30:03 yamt Exp $ */
/* $NetBSD: subr_bufq.c,v 1.5 2005/10/16 02:02:23 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.70 2005/08/20 12:00:01 yamt Exp $ */
/*-
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_bufq.c,v 1.4 2005/10/16 00:30:03 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_bufq.c,v 1.5 2005/10/16 02:02:23 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -157,6 +157,7 @@ bufq_alloc(struct bufq_state **bufqp, const char *strategy, int flags)
*bufqp = bufq = malloc(sizeof(*bufq), M_DEVBUF, M_WAITOK | M_ZERO);
bufq->bq_flags = flags;
bufq->bq_strat = bsp;
(*bsp->bs_initfn)(bufq);
out:
@ -214,6 +215,31 @@ bufq_free(struct bufq_state *bufq)
free(bufq, M_DEVBUF);
}
#if 0
/*
* get a strategy identifier of a buffer queue.
*/
const char *
bufq_getstrategyname(struct bufq_state *bufq)
{
return bufq->bq_strat->bs_name;
}
/*
* move all requests on a buffer queue to another.
*/
void
bufq_move(struct bufq_state *dst, struct bufq_state *src)
{
struct buf *bp;
while ((bp = BUFQ_GET(src)) != NULL) {
BUFQ_PUT(dst, bp);
}
}
#endif
/*
* sysctl function that will print all bufq strategies
* built in the kernel.

View File

@ -1,4 +1,4 @@
/* $NetBSD: bufq.h,v 1.4 2005/10/15 17:29:26 yamt Exp $ */
/* $NetBSD: bufq.h,v 1.5 2005/10/16 02:02:23 yamt Exp $ */
/* NetBSD: buf.h,v 1.75 2004/09/18 16:40:11 yamt Exp */
/*-
@ -103,6 +103,8 @@ void bufq_free(struct bufq_state *);
void bufq_put(struct bufq_state *, struct buf *);
struct buf *bufq_get(struct bufq_state *);
struct buf *bufq_peek(struct bufq_state *);
const char *bufq_getstrategyname(struct bufq_state *);
void bufq_move(struct bufq_state *, struct bufq_state *);
/* Put buffer in queue */
#define BUFQ_PUT(bufq, bp) bufq_put(bufq, bp)

View File

@ -1,4 +1,4 @@
/* $NetBSD: bufq_impl.h,v 1.1 2005/10/15 17:29:26 yamt Exp $ */
/* $NetBSD: bufq_impl.h,v 1.2 2005/10/16 02:02:23 yamt Exp $ */
/* NetBSD: bufq.h,v 1.3 2005/03/31 11:28:53 yamt Exp */
/* NetBSD: buf.h,v 1.75 2004/09/18 16:40:11 yamt Exp */
@ -79,6 +79,8 @@
#error not supposed to be exposed to userland.
#endif
struct bufq_strat;
/*
* Device driver buffer queue.
*/
@ -87,6 +89,7 @@ struct bufq_state {
struct buf *(*bq_get)(struct bufq_state *, int);
void *bq_private;
int bq_flags; /* Flags from bufq_alloc() */
const struct bufq_strat *bq_strat;
};
static __inline void *bufq_private(const struct bufq_state *) __unused;