2 * Copyright (c) 2009 Fabio Checconi
3 * Copyright (c) 2010 Luigi Rizzo, Universita` di Pisa
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * This file implements the userspace library used by the 'geom'
33 * command to load and manipulate disk schedulers.
36 #include <sys/cdefs.h>
37 #include <sys/param.h>
38 #include <sys/linker.h>
39 #include <sys/module.h>
45 #include "core/geom.h"
46 #include "misc/subr.h"
48 #define G_SCHED_VERSION 0
50 uint32_t lib_version = G_LIB_VERSION;
51 uint32_t version = G_SCHED_VERSION;
54 * storage for parameters used by this geom class.
55 * Right now only the scheduler name is used.
57 #define GSCHED_ALGO "rr" /* default scheduler */
60 * Adapt to differences in geom library.
61 * in V1 struct g_command misses gc_argname, eld, and G_BOOL is undefined
63 #if G_LIB_VERSION <= 1
64 #define G_TYPE_BOOL G_TYPE_NUMBER
66 #if G_LIB_VERSION >= 3 && G_LIB_VERSION <= 4
67 #define G_ARGNAME NULL,
73 gcmd_createinsert(struct gctl_req *req, unsigned flags __unused)
78 if (gctl_has_param(req, "algo"))
79 reqalgo = gctl_get_ascii(req, "algo");
81 reqalgo = GSCHED_ALGO;
83 snprintf(name, sizeof(name), "gsched_%s", reqalgo);
85 * Do not complain about errors here, gctl_issue()
88 if (modfind(name) < 0)
93 struct g_command class_commands[] = {
94 { "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert,
96 { 'a', "algo", GSCHED_ALGO, G_TYPE_STRING },
99 G_ARGNAME "[-v] [-a algorithm_name] dev ..."
101 { "insert", G_FLAG_VERBOSE | G_FLAG_LOADKLD, gcmd_createinsert,
103 { 'a', "algo", GSCHED_ALGO, G_TYPE_STRING },
106 G_ARGNAME "[-v] [-a algorithm_name] dev ..."
108 { "configure", G_FLAG_VERBOSE, NULL,
110 { 'a', "algo", GSCHED_ALGO, G_TYPE_STRING },
113 G_ARGNAME "[-v] [-a algorithm_name] prov ..."
115 { "destroy", G_FLAG_VERBOSE, NULL,
117 { 'f', "force", NULL, G_TYPE_BOOL },
120 G_ARGNAME "[-fv] prov ..."
122 { "reset", G_FLAG_VERBOSE, NULL, G_NULL_OPTS,
123 G_ARGNAME "[-v] prov ..."