Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys lookup bufq using link_set rather than a switch statement.
details: https://anonhg.NetBSD.org/src/rev/182f697cb20e
branches: trunk
changeset: 571469:182f697cb20e
user: yamt <yamt%NetBSD.org@localhost>
date: Thu Nov 25 04:52:23 2004 +0000
description:
lookup bufq using link_set rather than a switch statement.
diffstat:
sys/conf/files | 23 ++++++++++++----
sys/kern/bufq_disksort.c | 12 ++++++--
sys/kern/bufq_fcfs.c | 12 ++++++--
sys/kern/bufq_priocscan.c | 10 +++++--
sys/kern/bufq_readprio.c | 12 ++++++--
sys/kern/subr_disk.c | 65 ++++++++++++++++++++++++++++------------------
sys/sys/bufq.h | 23 ++++++++++++----
7 files changed, 107 insertions(+), 50 deletions(-)
diffs (truncated from 369 to 300 lines):
diff -r 8e71af79646d -r 182f697cb20e sys/conf/files
--- a/sys/conf/files Thu Nov 25 04:50:48 2004 +0000
+++ b/sys/conf/files Thu Nov 25 04:52:23 2004 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files,v 1.697 2004/11/13 07:58:14 kent Exp $
+# $NetBSD: files,v 1.698 2004/11/25 04:52:23 yamt Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -25,7 +25,11 @@
defparam DEFCORENAME
defflag opt_pipe.h PIPE_SOCKETPAIR PIPE_NODIRECT
-defflag opt_bufq.h NEW_BUFQ_STRATEGY
+#defflag BUFQ_DISKSORT
+#defflag BUFQ_FCFS
+defflag BUFQ_PRIOCSCAN
+defflag BUFQ_READPRIO
+defflag NEW_BUFQ_STRATEGY # same as BUFQ_READPRIO
defparam SOMAXKVA
defflag opt_sock_counters.h SOSEND_COUNTERS
@@ -328,6 +332,13 @@
device aic: scsi
file dev/ic/aic6360.c aic
+define scsi_low
+file dev/scsipi/scsi_low.c scsi_low
+
+# FutureDomain TMC18C[35]0
+device stg: scsi, scsi_low
+file dev/ic/tmc18c30.c stg
+
# SMC 93Cx6 Serial EEPROM devices
#
define smc93cx6
@@ -1165,10 +1176,10 @@
file dev/rndpool.c rnd needs-flag
file dev/sequencer.c sequencer needs-flag
file dev/vnd.c vnd needs-flag
-file kern/bufq_disksort.c
-file kern/bufq_fcfs.c
-file kern/bufq_priocscan.c
-file kern/bufq_readprio.c
+file kern/bufq_disksort.c #bufq_disksort
+file kern/bufq_fcfs.c #bufq_fcfs
+file kern/bufq_priocscan.c bufq_priocscan
+file kern/bufq_readprio.c bufq_readprio | new_bufq_strategy
file kern/core_elf32.c exec_elf32
file kern/core_elf64.c exec_elf64
file kern/core_netbsd.c
diff -r 8e71af79646d -r 182f697cb20e sys/kern/bufq_disksort.c
--- a/sys/kern/bufq_disksort.c Thu Nov 25 04:50:48 2004 +0000
+++ b/sys/kern/bufq_disksort.c Thu Nov 25 04:52:23 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_disksort.c,v 1.2 2004/10/28 07:07:46 yamt Exp $ */
+/* $NetBSD: bufq_disksort.c,v 1.3 2004/11/25 04:52:24 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*-
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.2 2004/10/28 07:07:46 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.3 2004/11/25 04:52:24 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -101,6 +101,12 @@
TAILQ_HEAD(, buf) bq_head; /* actual list of buffers */
};
+static void bufq_disksort_init(struct bufq_state *);
+static void bufq_disksort_put(struct bufq_state *, struct buf *);
+static struct buf *bufq_disksort_get(struct bufq_state *, int);
+
+BUFQ_DEFINE(disksort, BUFQ_DISKSORT, bufq_disksort_init);
+
static void
bufq_disksort_put(struct bufq_state *bufq, struct buf *bp)
{
@@ -191,7 +197,7 @@
return (bp);
}
-void
+static void
bufq_disksort_init(struct bufq_state *bufq)
{
struct bufq_disksort *disksort;
diff -r 8e71af79646d -r 182f697cb20e sys/kern/bufq_fcfs.c
--- a/sys/kern/bufq_fcfs.c Thu Nov 25 04:50:48 2004 +0000
+++ b/sys/kern/bufq_fcfs.c Thu Nov 25 04:52:23 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_fcfs.c,v 1.2 2004/10/28 07:07:46 yamt Exp $ */
+/* $NetBSD: bufq_fcfs.c,v 1.3 2004/11/25 04:52:24 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*-
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.2 2004/10/28 07:07:46 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.3 2004/11/25 04:52:24 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -93,6 +93,12 @@
TAILQ_HEAD(, buf) bq_head; /* actual list of buffers */
};
+static void bufq_fcfs_init(struct bufq_state *);
+static void bufq_fcfs_put(struct bufq_state *, struct buf *);
+static struct buf *bufq_fcfs_get(struct bufq_state *, int);
+
+BUFQ_DEFINE(fcfs, BUFQ_FCFS, bufq_fcfs_init);
+
static void
bufq_fcfs_put(struct bufq_state *bufq, struct buf *bp)
{
@@ -115,7 +121,7 @@
return (bp);
}
-void
+static void
bufq_fcfs_init(struct bufq_state *bufq)
{
struct bufq_fcfs *fcfs;
diff -r 8e71af79646d -r 182f697cb20e sys/kern/bufq_priocscan.c
--- a/sys/kern/bufq_priocscan.c Thu Nov 25 04:50:48 2004 +0000
+++ b/sys/kern/bufq_priocscan.c Thu Nov 25 04:52:23 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_priocscan.c,v 1.2 2004/10/28 07:07:46 yamt Exp $ */
+/* $NetBSD: bufq_priocscan.c,v 1.3 2004/11/25 04:52:24 yamt Exp $ */
/*-
* Copyright (c)2004 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.2 2004/10/28 07:07:46 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.3 2004/11/25 04:52:24 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -163,8 +163,12 @@
64, 16, 4
};
+static void bufq_priocscan_init(struct bufq_state *);
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);
+
static __inline struct cscan_queue *bufq_priocscan_selectqueue(
struct bufq_priocscan *, const struct buf *);
@@ -271,7 +275,7 @@
return bp;
}
-void
+static void
bufq_priocscan_init(struct bufq_state *bufq)
{
struct bufq_priocscan *q;
diff -r 8e71af79646d -r 182f697cb20e sys/kern/bufq_readprio.c
--- a/sys/kern/bufq_readprio.c Thu Nov 25 04:50:48 2004 +0000
+++ b/sys/kern/bufq_readprio.c Thu Nov 25 04:52:23 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_readprio.c,v 1.2 2004/10/28 07:07:46 yamt Exp $ */
+/* $NetBSD: bufq_readprio.c,v 1.3 2004/11/25 04:52:24 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*-
@@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_readprio.c,v 1.2 2004/10/28 07:07:46 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_readprio.c,v 1.3 2004/11/25 04:52:24 yamt Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -104,6 +104,12 @@
int bq_read_burst; /* # of consecutive reads */
};
+static void bufq_readprio_init(struct bufq_state *);
+static void bufq_prio_put(struct bufq_state *, struct buf *);
+static struct buf *bufq_prio_get(struct bufq_state *, int);
+
+BUFQ_DEFINE(readprio, BUFQ_READ_PRIO, bufq_readprio_init);
+
static void
bufq_prio_put(struct bufq_state *bufq, struct buf *bp)
{
@@ -212,7 +218,7 @@
return (bp);
}
-void
+static void
bufq_readprio_init(struct bufq_state *bufq)
{
struct bufq_prio *prio;
diff -r 8e71af79646d -r 182f697cb20e sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c Thu Nov 25 04:50:48 2004 +0000
+++ b/sys/kern/subr_disk.c Thu Nov 25 04:52:23 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.64 2004/10/28 07:07:46 yamt Exp $ */
+/* $NetBSD: subr_disk.c,v 1.65 2004/11/25 04:52:24 yamt Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
@@ -74,10 +74,9 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.64 2004/10/28 07:07:46 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.65 2004/11/25 04:52:24 yamt Exp $");
#include "opt_compat_netbsd.h"
-#include "opt_bufq.h"
#include <sys/param.h>
#include <sys/kernel.h>
@@ -98,11 +97,9 @@
int disk_count; /* number of drives in global disklist */
struct simplelock disklist_slock = SIMPLELOCK_INITIALIZER;
-#ifdef NEW_BUFQ_STRATEGY
-int bufq_disk_default_strat = BUFQ_READ_PRIO;
-#else /* NEW_BUFQ_STRATEGY */
-int bufq_disk_default_strat = BUFQ_DISKSORT;
-#endif /* NEW_BUFQ_STRATEGY */
+int bufq_disk_default_strat = _BUFQ_DEFAULT;
+
+BUFQ_DEFINE(dummy, 0, NULL); /* so that bufq_strats won't be empty */
/*
* Compute checksum for disk label.
@@ -481,39 +478,55 @@
void
bufq_alloc(struct bufq_state *bufq, int flags)
{
- void (*initfn)(struct bufq_state *);
+ __link_set_decl(bufq_strats, const struct bufq_strat);
+ int methodid;
+ const struct bufq_strat *bsp;
+ const struct bufq_strat * const *it;
bufq->bq_flags = flags;
+ methodid = flags & BUFQ_METHOD_MASK;
switch (flags & BUFQ_SORT_MASK) {
case BUFQ_SORT_RAWBLOCK:
case BUFQ_SORT_CYLINDER:
break;
case 0:
- if ((flags & BUFQ_METHOD_MASK) == BUFQ_FCFS)
+ if (methodid == BUFQ_FCFS)
break;
/* FALLTHROUGH */
default:
panic("bufq_alloc: sort out of range");
}
- switch (flags & BUFQ_METHOD_MASK) {
- case BUFQ_FCFS:
- initfn = bufq_fcfs_init;
- break;
- case BUFQ_DISKSORT:
- initfn = bufq_disksort_init;
- break;
- case BUFQ_READ_PRIO:
- initfn = bufq_readprio_init;
- break;
- case BUFQ_PRIOCSCAN:
- initfn = bufq_priocscan_init;
- break;
- default:
- panic("bufq_alloc: method out of range");
+ /*
+ * select strategy.
+ * if a strategy specified by flags is found, use it.
+ * otherwise, select one with the largest id number. XXX
+ */
+ bsp = NULL;
+ __link_set_foreach(it, bufq_strats) {
+ if ((*it) == &bufq_strat_dummy)
+ continue;
+ if (methodid == (*it)->bs_id) {
+ bsp = *it;
+ break;
Home |
Main Index |
Thread Index |
Old Index