Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Modularize the various bufq strategies
details: https://anonhg.NetBSD.org/src/rev/d0b6bdf3e1a4
branches: trunk
changeset: 348923:d0b6bdf3e1a4
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Wed Nov 16 00:46:46 2016 +0000
description:
Modularize the various bufq strategies
diffstat:
sys/kern/bufq_disksort.c | 21 +++++++-
sys/kern/bufq_fcfs.c | 21 +++++++-
sys/kern/bufq_priocscan.c | 21 +++++++-
sys/kern/bufq_readprio.c | 20 ++++++-
sys/kern/init_main.c | 8 ++-
sys/kern/subr_bufq.c | 119 +++++++++++++++++++++++++++++++++------------
sys/sys/bufq.h | 3 +-
sys/sys/bufq_impl.h | 19 ++++--
8 files changed, 181 insertions(+), 51 deletions(-)
diffs (truncated from 491 to 300 lines):
diff -r 679f90868f3d -r d0b6bdf3e1a4 sys/kern/bufq_disksort.c
--- a/sys/kern/bufq_disksort.c Tue Nov 15 22:31:07 2016 +0000
+++ b/sys/kern/bufq_disksort.c Wed Nov 16 00:46:46 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_disksort.c,v 1.11 2009/01/19 14:54:28 yamt Exp $ */
+/* $NetBSD: bufq_disksort.c,v 1.12 2016/11/16 00:46:46 pgoyette Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*-
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.11 2009/01/19 14:54:28 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.12 2016/11/16 00:46:46 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,6 +76,7 @@
#include <sys/bufq.h>
#include <sys/bufq_impl.h>
#include <sys/kmem.h>
+#include <sys/module.h>
/*
* Seek sort for disks.
@@ -227,3 +228,19 @@
bufq->bq_fini = bufq_disksort_fini;
TAILQ_INIT(&disksort->bq_head);
}
+
+MODULE(MODULE_CLASS_MISC, bufq_disksort, NULL);
+
+static int
+bufq_disksort_modcmd(modcmd_t cmd, void *opaque)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ return bufq_register(&bufq_strat_disksort);
+ case MODULE_CMD_FINI:
+ return bufq_unregister(&bufq_strat_disksort);
+ default:
+ return ENOTTY;
+ }
+}
diff -r 679f90868f3d -r d0b6bdf3e1a4 sys/kern/bufq_fcfs.c
--- a/sys/kern/bufq_fcfs.c Tue Nov 15 22:31:07 2016 +0000
+++ b/sys/kern/bufq_fcfs.c Wed Nov 16 00:46:46 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_fcfs.c,v 1.10 2009/01/19 14:54:28 yamt Exp $ */
+/* $NetBSD: bufq_fcfs.c,v 1.11 2016/11/16 00:46:46 pgoyette Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*-
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.10 2009/01/19 14:54:28 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.11 2016/11/16 00:46:46 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,6 +76,7 @@
#include <sys/bufq.h>
#include <sys/bufq_impl.h>
#include <sys/kmem.h>
+#include <sys/module.h>
/*
* First-come first-served sort for disks.
@@ -151,3 +152,19 @@
fcfs = (struct bufq_fcfs *)bufq->bq_private;
TAILQ_INIT(&fcfs->bq_head);
}
+
+MODULE(MODULE_CLASS_MISC, bufq_fcfs, NULL);
+
+static int
+bufq_fcfs_modcmd(modcmd_t cmd, void *opaque)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ return bufq_register(&bufq_strat_fcfs);
+ case MODULE_CMD_FINI:
+ return bufq_unregister(&bufq_strat_fcfs);
+ default:
+ return ENOTTY;
+ }
+}
diff -r 679f90868f3d -r d0b6bdf3e1a4 sys/kern/bufq_priocscan.c
--- a/sys/kern/bufq_priocscan.c Tue Nov 15 22:31:07 2016 +0000
+++ b/sys/kern/bufq_priocscan.c Wed Nov 16 00:46:46 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_priocscan.c,v 1.18 2014/01/28 12:50:54 martin Exp $ */
+/* $NetBSD: bufq_priocscan.c,v 1.19 2016/11/16 00:46:46 pgoyette Exp $ */
/*-
* Copyright (c)2004,2005,2006,2008,2009,2011,2012 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.18 2014/01/28 12:50:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_priocscan.c,v 1.19 2016/11/16 00:46:46 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -36,6 +36,7 @@
#include <sys/bufq_impl.h>
#include <sys/kmem.h>
#include <sys/rbtree.h>
+#include <sys/module.h>
#undef PRIOCSCAN_USE_GLOBAL_POSITION
@@ -442,3 +443,19 @@
cscan_init(cq, sortby);
}
}
+
+MODULE(MODULE_CLASS_MISC, bufq_priocscan, NULL);
+
+static int
+bufq_priocscan_modcmd(modcmd_t cmd, void *opaque)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ return bufq_register(&bufq_strat_priocscan);
+ case MODULE_CMD_FINI:
+ return bufq_unregister(&bufq_strat_priocscan);
+ default:
+ return ENOTTY;
+ }
+}
diff -r 679f90868f3d -r d0b6bdf3e1a4 sys/kern/bufq_readprio.c
--- a/sys/kern/bufq_readprio.c Tue Nov 15 22:31:07 2016 +0000
+++ b/sys/kern/bufq_readprio.c Wed Nov 16 00:46:46 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bufq_readprio.c,v 1.13 2009/01/19 14:54:28 yamt Exp $ */
+/* $NetBSD: bufq_readprio.c,v 1.14 2016/11/16 00:46:46 pgoyette Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*-
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bufq_readprio.c,v 1.13 2009/01/19 14:54:28 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bufq_readprio.c,v 1.14 2016/11/16 00:46:46 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,6 +76,7 @@
#include <sys/bufq.h>
#include <sys/bufq_impl.h>
#include <sys/kmem.h>
+#include <sys/module.h>
/*
* Seek sort for disks.
@@ -280,3 +281,18 @@
TAILQ_INIT(&prio->bq_write);
}
+MODULE(MODULE_CLASS_MISC, bufq_readprio, NULL);
+
+static int
+bufq_readprio_modcmd(modcmd_t cmd, void *opaque)
+{
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ return bufq_register(&bufq_strat_readprio);
+ case MODULE_CMD_FINI:
+ return bufq_unregister(&bufq_strat_readprio);
+ default:
+ return ENOTTY;
+ }
+}
diff -r 679f90868f3d -r d0b6bdf3e1a4 sys/kern/init_main.c
--- a/sys/kern/init_main.c Tue Nov 15 22:31:07 2016 +0000
+++ b/sys/kern/init_main.c Wed Nov 16 00:46:46 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.484 2016/11/02 00:11:59 pgoyette Exp $ */
+/* $NetBSD: init_main.c,v 1.485 2016/11/16 00:46:46 pgoyette Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.484 2016/11/02 00:11:59 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.485 2016/11/16 00:46:46 pgoyette Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@@ -175,6 +175,7 @@
#include <sys/ksyms.h>
#include <sys/uidinfo.h>
#include <sys/kprintf.h>
+#include <sys/bufq.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
#endif
@@ -427,6 +428,9 @@
/* Second part of module system initialization. */
module_start_unload_thread();
+ /* Initialize the bufq strategy sub-system */
+ bufq_init();
+
/* Initialize the file systems. */
#ifdef NVNODE_IMPLICIT
/*
diff -r 679f90868f3d -r d0b6bdf3e1a4 sys/kern/subr_bufq.c
--- a/sys/kern/subr_bufq.c Tue Nov 15 22:31:07 2016 +0000
+++ b/sys/kern/subr_bufq.c Wed Nov 16 00:46:46 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_bufq.c,v 1.21 2014/02/25 18:30:11 pooka Exp $ */
+/* $NetBSD: subr_bufq.c,v 1.22 2016/11/16 00:46:46 pgoyette Exp $ */
/* NetBSD: subr_disk.c,v 1.70 2005/08/20 12:00:01 yamt Exp $ */
/*-
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_bufq.c,v 1.21 2014/02/25 18:30:11 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_bufq.c,v 1.22 2016/11/16 00:46:46 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -76,22 +76,51 @@
#include <sys/bufq.h>
#include <sys/bufq_impl.h>
#include <sys/kmem.h>
-#include <sys/once.h>
#include <sys/sysctl.h>
-
-BUFQ_DEFINE(dummy, 0, NULL); /* so that bufq_strats won't be empty */
+#include <sys/module.h>
#define STRAT_MATCH(id, bs) (strcmp((id), (bs)->bs_name) == 0)
-static int bufq_init(void);
static void sysctl_kern_bufq_strategies_setup(struct sysctllog **);
+static SLIST_HEAD(, bufq_strat) bufq_strat_list;
+
+static kmutex_t bufq_mutex;
static struct sysctllog *sysctllog;
-static int
+
+void
bufq_init(void)
{
+ mutex_init(&bufq_mutex, MUTEX_DEFAULT, IPL_NONE);
+ SLIST_INIT(&bufq_strat_list);
sysctl_kern_bufq_strategies_setup(&sysctllog);
+}
+
+int
+bufq_register(struct bufq_strat *bs)
+{
+
+ mutex_enter(&bufq_mutex);
+ SLIST_INSERT_HEAD(&bufq_strat_list, bs, bs_next);
+ bs->bs_refcnt = 0;
+ mutex_exit(&bufq_mutex);
+
+ return 0;
+}
+
+int
+bufq_unregister(struct bufq_strat *bs)
+{
+
+ mutex_enter(&bufq_mutex);
+ if (bs->bs_refcnt != 0) {
+ mutex_exit(&bufq_mutex);
+ return EBUSY;
+ }
+ SLIST_REMOVE(&bufq_strat_list, bs, bufq_strat, bs_next);
+ mutex_exit(&bufq_mutex);
+
return 0;
}
@@ -101,14 +130,12 @@
int
bufq_alloc(struct bufq_state **bufqp, const char *strategy, int flags)
{
- __link_set_decl(bufq_strats, const struct bufq_strat);
- const struct bufq_strat *bsp;
Home |
Main Index |
Thread Index |
Old Index