diff options
author | phk <phk@FreeBSD.org> | 2003-03-18 09:42:33 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-03-18 09:42:33 +0000 |
commit | abd9cc6d2bcbbc28d5b00a910e3cc51625255cbf (patch) | |
tree | 1c1f50af00e2e7b30b7d8bd0d202a205e3b2fa40 /sys/geom/geom_stats.c | |
parent | eef257a93e011a4e140ebc8b497d65adb03449bb (diff) | |
download | FreeBSD-src-abd9cc6d2bcbbc28d5b00a910e3cc51625255cbf.zip FreeBSD-src-abd9cc6d2bcbbc28d5b00a910e3cc51625255cbf.tar.gz |
Retire the GEOM private statistics code and use devstat instead.
Diffstat (limited to 'sys/geom/geom_stats.c')
-rw-r--r-- | sys/geom/geom_stats.c | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/sys/geom/geom_stats.c b/sys/geom/geom_stats.c deleted file mode 100644 index 03e1c75..0000000 --- a/sys/geom/geom_stats.c +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * Copyright (c) 2002 Poul-Henning Kamp - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The names of the authors may not be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ - -#include "opt_geom.h" - -#include <sys/param.h> -#include <sys/systm.h> -#include <sys/kernel.h> -#include <sys/sysctl.h> -#include <sys/bio.h> -#include <sys/conf.h> -#include <sys/disk.h> -#include <sys/malloc.h> -#include <sys/sysctl.h> -#include <vm/vm.h> -#include <vm/pmap.h> - -#include <sys/lock.h> -#include <sys/mutex.h> -#include <geom/geom.h> -#include <geom/geom_int.h> -#include <geom/geom_stats.h> - -#define statsperpage (PAGE_SIZE / sizeof(struct g_stat)) - -struct statspage { - TAILQ_ENTRY(statspage) list; - struct g_stat *stat; - u_int nfree; -}; - -static TAILQ_HEAD(, statspage) pagelist = TAILQ_HEAD_INITIALIZER(pagelist); - -struct g_stat * -g_stat_new(void *id) -{ - struct g_stat *gsp; - struct statspage *spp; - u_int u; - - g_topology_assert(); - TAILQ_FOREACH(spp, &pagelist, list) { - if (spp->nfree > 0) - break; - } - if (spp == NULL) { - spp = g_malloc(sizeof *spp, M_ZERO | M_WAITOK); - TAILQ_INSERT_TAIL(&pagelist, spp, list); - spp->stat = g_malloc(PAGE_SIZE, M_ZERO | M_WAITOK); - spp->nfree = statsperpage; - } - gsp = spp->stat; - for (u = 0; u < statsperpage; u++) { - if (gsp->id == NULL) - break; - gsp++; - } - spp->nfree--; - gsp->id = id; - return (gsp); -} - -void -g_stat_delete(struct g_stat *gsp) -{ - struct statspage *spp; - - bzero(gsp, sizeof *gsp); - TAILQ_FOREACH(spp, &pagelist, list) { - if (gsp >= spp->stat && gsp < (spp->stat + statsperpage)) { - spp->nfree++; - return; - } - } -} - -static d_mmap_t g_stat_mmap; - -static struct cdevsw geom_stats_cdevsw = { - .d_open = nullopen, - .d_close = nullclose, - .d_mmap = g_stat_mmap, - .d_name = "g_stats", - .d_maj = GEOM_MAJOR, -}; - -static int -g_stat_mmap(dev_t dev, vm_offset_t offset, vm_offset_t *paddr, int nprot) -{ - struct statspage *spp; - - if (nprot != VM_PROT_READ) - return (-1); - TAILQ_FOREACH(spp, &pagelist, list) { - if (offset == 0) { - *paddr = vtophys(spp->stat); - return (0); - } - offset -= PAGE_SIZE; - } - return (-1); -} - -void -g_stat_init(void) -{ - make_dev(&geom_stats_cdevsw, GEOM_MINOR_STATS, - UID_ROOT, GID_WHEEL, 0400, GEOM_STATS_DEVICE); -} |