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>
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #include <portals/ptlctl.h>
33 static int jt_quit(int argc, char **argv) {
34 Parser_quit(argc, argv);
38 static int jt_noop(int argc, char **argv) {
42 static int jt_opt_ignore_errors(int argc, char **argv) {
43 Parser_ignore_errors(1);
47 command_t cmdlist[] = {
49 {"--device", jt_opt_device, 0,
50 "run <command> after connecting to device <devno>\n"
51 "--device <devno> <command [args ...]>"},
52 {"--threads", jt_opt_threads, 0,
53 "run <threads> separate instances of <command> on device <devno>\n"
54 "--threads <threads> <verbose> <devno> <command [args ...]>"},
55 {"--ignore_errors", jt_opt_ignore_errors, 0,
56 "ignore errors that occur during script processing\n"
58 {"ignore_errors", jt_opt_ignore_errors, 0,
59 "ignore errors that occur during script processing\n"
62 /* Network configuration commands */
63 {"==== network config ====", jt_noop, 0, "network config"},
64 {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
65 "usage: network <tcp/elan/myrinet>"},
66 {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
67 "usage: connect [[<hostname> <port>] | <elan id>]"},
68 {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
69 "usage: disconnect <nid>"},
70 {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
71 "The nid defaults to hostname for tcp networks and is automatically "
72 "setup for elan/myrinet networks.\n"
73 "usage: mynid [nid]"},
74 {"add_uuid", jt_ptl_add_uuid, 0, "associate a UUID with a nid\n"
75 "usage: add_uuid <uuid> <nid>"},
76 {"close_uuid", jt_ptl_close_uuid, 0, "disconnect a UUID\n"
77 "usage: close_uuid <uuid>)"},
78 {"del_uuid", jt_ptl_del_uuid, 0, "delete a UUID association\n"
79 "usage: del_uuid <uuid>"},
80 {"add_route", jt_ptl_add_route, 0,
81 "add an entry to the routing table\n"
82 "usage: add_route <gateway> <target> [target]"},
83 {"del_route", jt_ptl_del_route, 0,
84 "delete an entry from the routing table\n"
85 "usage: del_route <target>"},
86 {"route_list", jt_ptl_print_routes, 0, "print the routing table\n"
88 {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
89 "if size is omited the current size is reported.\n"
90 "usage: recv_mem [size]"},
91 {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
92 "if size is omited the current size is reported.\n"
93 "usage: send_mem [size]"},
94 {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omiting the "
95 "argument will cause the current nagle setting to be reported.\n"
96 "usage: nagle [on/off]"},
98 /* Device selection commands */
99 {"=== device selection ===", jt_noop, 0, "device selection"},
100 {"newdev", jt_obd_newdev, 0, "create a new device\n"
103 {"uuid2dev", jt_obd_uuid2dev, 0,
104 "find device attached with <uuid> and make it the current device\n"
105 "usage: uuid2dev <uuid>"},
107 {"name2dev", jt_obd_name2dev, 0,
108 "find device attached with <name> and make it the current device\n"
109 "usage: name2dev <name>"},
110 {"device", jt_obd_device, 0, "set current device to <devno>\n"
111 "usage: device <devno>"},
112 {"device_list", jt_obd_list, 0, "show all devices\n"
113 "usage: device_list"},
115 /* Device configuration commands */
116 {"==== device config =====", jt_noop, 0, "device config"},
117 {"attach", jt_obd_attach, 0,
118 "set the type of the current device (with <name> and <uuid>)\n"
119 "usage: attach type [name [uuid]]"},
120 {"setup", jt_obd_setup, 0,
121 "type specific device configuration information\n"
122 "usage: setup <args...>"},
123 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
125 {"detach", jt_obd_detach, 0,
126 "remove driver (and name and uuid) from current device\n"
128 {"lov_setconfig", jt_obd_lov_setconfig, 0,
129 "write lov configuration to an mds device\n"
130 "usage: lov_setconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
131 {"lov_getconfig", jt_obd_lov_getconfig, 0,
132 "read lov configuration from an mds device\n"
133 "usage: lov_getconfig lov-uuid"},
135 /* Device operations */
136 {"=== device operations ==", jt_noop, 0, "device operations"},
137 {"probe", jt_obd_connect, 0,
138 "build a connection handle to a device. This command is used to "
139 "suspend configuration until lctl has ensured that the mds and osc "
140 "services are available. This is to avoid mount failures in a "
141 "rebooting cluster.\n"
142 "usage: probe [timeout]"},
143 {"close", jt_obd_disconnect, 0,
144 "close the connection handle\n"
146 {"getattr", jt_obd_getattr, 0,
147 "get attribute for OST object <objid>\n"
148 "usage: getattr <objid>"},
149 {"setattr", jt_obd_setattr, 0,
150 "set mode attribute for OST object <objid>\n"
151 "usage: setattr <objid> <mode>"},
152 {"create", jt_obd_create, 0,
153 "create <num> OST objects (with <mode>)\n"
154 "usage: create [num [mode [verbose]]]"},
155 {"destroy", jt_obd_destroy, 0,
156 "destroy OST object <objid>\n"
157 "usage: destroy <objid>"},
158 {"test_getattr", jt_obd_test_getattr, 0,
159 "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
160 "usage: test_getattr <num> [verbose [[t]objid]]"},
161 {"test_brw", jt_obd_test_brw, 0,
162 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
163 "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
164 {"test_ldlm", jt_obd_test_ldlm, 0,
165 "perform lock manager test\n"
167 {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
168 "start lock manager stress test\n"
169 "usage: ldlm_regress_start [numthreads [refheld [numres [numext]]]]"},
170 {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
171 "stop lock manager stress test (no args)\n"},
172 {"dump_ldlm", jt_obd_dump_ldlm, 0,
173 "dump all lock manager state (no args)"},
174 {"lov_set_osc_active", jt_obd_lov_set_osc_active, 0,
175 "(de)activate an OSC in a LOV\n"
176 "usage: lov_set_osc_active <OSC UUID> <1|0 (active|inactive)>"},
177 {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
178 {"failconn", jt_obd_failconn, 0, "failconn <uuid>"},
181 {"======== debug =========", jt_noop, 0, "debug"},
182 {"debug_kernel", jt_dbg_debug_kernel, 0,
183 "get debug buffer and dump to a file"
184 "usage: debug_kernel [file] [raw]"},
185 {"debug_file", jt_dbg_debug_file, 0,
186 "read debug buffer from input and dump to output"
187 "usage: debug_file <input> [output] [raw]"},
188 {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
190 {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
191 "usage: mark <text>"},
192 {"filter", jt_dbg_filter, 0, "filter message type\n"
193 "usage: filter <subsystem id/debug mask>"},
194 {"show", jt_dbg_show, 0, "show message type\n"
195 "usage: show <subsystem id/debug mask>"},
196 {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
197 "usage: debug_list <subs/types>"},
198 {"modules", jt_dbg_modules, 0,
199 "provide gdb-friendly module information\n"
200 "usage: modules <path>"},
201 {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
204 /* User interface commands */
205 {"======= control ========", jt_noop, 0, "control commands"},
206 {"help", Parser_help, 0, "help"},
207 {"exit", jt_quit, 0, "quit"},
208 {"quit", jt_quit, 0, "quit"},
214 int main(int argc, char **argv)
220 ptl_initialize(argc, argv);
221 if (obd_initialize(argc, argv) < 0)
223 if (dbg_initialize(argc, argv) < 0)
227 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
229 Parser_init("lctl > ", cmdlist);
230 rc = Parser_commands();
233 obd_cleanup(argc, argv);