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