1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
5 * Author: Peter J. Braam <braam@clusterfs.com>
6 * Author: Phil Schwan <phil@clusterfs.com>
7 * Author: Robert Read <rread@clusterfs.com>
8 * This file is part of Lustre, http://www.lustre.org.
10 * Lustre is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
14 * Lustre is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with Lustre; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <sys/ioctl.h>
29 #include <sys/socket.h>
30 #include <sys/types.h>
39 #include <linux/lustre_lib.h>
40 #include <linux/lustre_idl.h>
41 #include <linux/lustre_dlm.h>
47 #include <netinet/in.h>
50 #include <asm/page.h> /* needed for PAGE_SIZE - rread*/
55 #include <linux/list.h>
60 static int jt_quit(int argc, char **argv) {
61 Parser_quit(argc, argv);
65 static int jt_noop(int argc, char **argv) {
69 command_t cmdlist[] = {
70 /* Network configuration commands */
71 {"==== network config ====", jt_noop, 0, "network config"},
72 {"network", jt_net_network, 0, "commands that follow apply to net\n"
73 "usage: network <tcp/elan/myrinet>"},
74 {"connect", jt_net_connect, 0, "connect to a remote nid\n"
75 "usage: connect [[<hostname> <port>] | <elan id>]"},
76 {"disconnect", jt_net_disconnect, 0, "disconnect from a remote nid\n"
77 "usage: disconnect <nid>"},
78 {"mynid", jt_net_mynid, 0, "inform the socknal of the local nid. "
79 "The nid defaults to hostname for tcp networks and is automatically "
80 "setup for elan/myrinet networks.\n"
81 "usage: mynid [nid]"},
82 {"add_uuid", jt_net_add_uuid, 0, "associate a name/uuid with a nid\n"
83 "usage: add_uuid <name> <uuid> <nid>"},
84 {"del_uuid", jt_net_del_uuid, 0, "delete a uuid association\n"
85 "usage: del_uuid <uuid>"},
86 {"add_route", jt_net_add_route, 0,
87 "add an entry to the routing table\n"
88 "usage: add_route <gateway> <target> [target]"},
89 {"del_route", jt_net_del_route, 0,
90 "delete an entry from the routing table\n"
91 "usage: del_route <target>"},
92 {"route_list", jt_net_route_list, 0, "print the routing table\n"
94 {"recv_mem", jt_net_recv_mem, 0, "set socket receive buffer size, "
95 "if size is omited the current size is reported.\n"
96 "usage: recv_mem [size]"},
97 {"send_mem", jt_net_send_mem, 0, "set socket send buffer size, "
98 "if size is omited the current size is reported.\n"
99 "usage: send_mem [size]"},
100 {"nagle", jt_net_nagle, 0, "enable/disable nagle, omiting the "
101 "argument will cause the current nagle setting to be reported.\n"
102 "usage: nagle [on/off]"},
104 /* Device selection commands */
105 {"=== device selection ===", jt_noop, 0, "device selection"},
106 {"newdev", jt_dev_newdev, 0, "create a new device\n"
108 {"uuid2dev", jt_dev_uuid2dev, 0,
109 "find a uuid and make it the current device\n"
110 "usage: uuid2dev <uuid>"},
111 {"name2dev", jt_dev_name2dev, 0,
112 "find a name and make it the current device\n"
113 "usage: name2dev <name>"},
114 {"device", jt_dev_device, 0, "set current device to devno\n"
115 "usage: device <devno>"},
116 {"device_list", jt_dev_list, 0, "show all devices\n"
117 "usage: device_list"},
119 /* Device configuration commands */
120 {"==== device config =====", jt_noop, 0, "device config"},
121 {"attach", jt_dev_attach, 0, "name and type the device\n"
122 "usage: attach type [name [uuid]]"},
123 {"setup", jt_dev_setup, 0,
124 "type specific device configuration information\n"
125 "usage: setup <args...>"},
126 {"cleanup", jt_dev_cleanup, 0, "cleanup setup\n"
128 {"detach", jt_dev_detach, 0, "un-name a device\n"
130 {"lovconfig", jt_dev_lov_config, 0,
131 "write lov configuration to a mds device\n"
134 /* Device operations */
135 {"=== device operations ==", jt_noop, 0, "device operations"},
136 {"probe", jt_dev_probe, 0,
137 "build a connection handle to a device. This command is used too "
138 "suspend configuration until lctl has ensured that the mds and osc "
139 "services are available. This is to avoid mount failures in a "
140 "rebooting cluster.\n"
141 "usage: probe [<timeout]"},
142 {"close", jt_dev_close, 0, "close the connection handle\n"
144 {"getattr", jt_dev_getattr, 0, "get attribute for id\n"
145 "usage: getattr <id>"},
146 {"setattr", jt_dev_setattr, 0, "set attribute for id\n"
147 "usage: setattr <id> <mode>"},
148 {"test_getattr", jt_dev_test_getattr, 0,
149 "perform count number of getattr's\n"
150 "usage: test_getattr <count> [verbose]"},
151 {"test_brw", jt_dev_test_brw, 0,
152 "perform count number of bulk read/writes\n"
153 "usage: test_brw <count> [write [verbose [pages [obdos]]]]"},
154 {"test_ldlm", jt_dev_test_ldlm, 0, "perform lock manager test\n"
158 {"create", jt_create, 0, "create [count [mode [verbose]]]"},
159 {"destroy", jt_destroy, 0, "destroy <id>"},
160 {"newconn", jt_newconn, 0, "newconn [newuuid]"},
163 {"======== debug =========", jt_noop, 0, "debug"},
164 {"debug_kernel", jt_debug_kernel, 0,
165 "get debug buffer and dump to a file"
166 "usage: debug_kernel [file] [raw]"},
167 {"debug_file", jt_debug_file, 0,
168 "read debug buffer from input and dump to output"
169 "usage: debug_file <input> [output] [raw]"},
170 {"clear", jt_debug_clear, 0, "clear kernel debug buffer\n"
172 {"mark", jt_debug_mark, 0,"insert marker text in kernel debug buffer\n"
173 "usage: mark <text>"},
174 {"filter", jt_debug_filter, 0, "filter message type\n"
175 "usage: filter <subsystem id/debug mask>"},
176 {"show", jt_debug_show, 0, "show message type\n"
177 "usage: show <subsystem id/debug mask>"},
178 {"debug_list", jt_debug_list, 0, "list subsystem and debug types\n"
179 "usage: debug_list <subs/types>"},
180 {"modules", jt_debug_modules, 0,
181 "provide gdb-friendly module information\n"
182 "usage: modules <path>"},
183 {"panic", jt_debug_panic, 0, "force the kernel to panic\n"
186 /* User interface commands */
187 {"======= control ========", jt_noop, 0, "control commands"},
188 {"help", Parser_help, 0, "help"},
189 {"exit", jt_quit, 0, "quit"},
190 {"quit", jt_quit, 0, "quit"},
194 static void signal_server(int sig) {
196 do_disconnect("sigint", 1);
199 fprintf(stderr, "%s: got signal %d\n", cmdname("sigint"), sig);
203 int main(int argc, char **argv) {
204 struct sigaction sigact;
207 sigact.sa_handler = signal_server;
208 sigfillset(&sigact.sa_mask);
209 sigact.sa_flags = SA_RESTART;
210 sigaction(SIGINT, &sigact, NULL);
212 if (network_setup(argc, argv) < 0)
215 if (device_setup(argc, argv) < 0)
218 if (debug_setup(argc, argv) < 0)
222 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
224 Parser_init("lctl > ", cmdlist);
225 rc = Parser_commands();
228 do_disconnect(argv[0], 1);