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.
30 #include <portals/api-support.h>
31 #include <portals/ptlctl.h>
35 static int jt_quit(int argc, char **argv) {
36 Parser_quit(argc, argv);
40 static int jt_noop(int argc, char **argv) {
44 static int jt_opt_ignore_errors(int argc, char **argv) {
45 Parser_ignore_errors(1);
49 command_t cmdlist[] = {
51 {"--device", jt_opt_device, 0,
52 "run <command> after connecting to device <devno>\n"
53 "--device <devno> <command [args ...]>"},
54 {"--threads", jt_opt_threads, 0,
55 "run <threads> separate instances of <command> on device <devno>\n"
56 "--threads <threads> <verbose> <devno> <command [args ...]>"},
57 {"--ignore_errors", jt_opt_ignore_errors, 0,
58 "ignore errors that occur during script processing\n"
60 {"ignore_errors", jt_opt_ignore_errors, 0,
61 "ignore errors that occur during script processing\n"
63 {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"},
65 /* Network configuration commands */
66 {"==== network config ====", jt_noop, 0, "network config"},
67 {"--net", jt_opt_net, 0, "run <command> after setting network to <net>\n"
68 "usage: --net <tcp/elan/myrinet/scimac> <command>"},
69 {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
70 "usage: network <tcp/elan/myrinet/scimac>"},
71 {"autoconn_list", jt_ptl_print_autoconnects, 0, "print autoconnect entries\n"
72 "usage: print_autoconns"},
73 {"add_autoconn", jt_ptl_add_autoconnect, 0, "add an autoconnect entry\n"
74 "usage: add_autoconn <nid> <host> <port> [ise]"},
75 {"del_autoconn", jt_ptl_del_autoconnect, 0, "remove an autoconnect entry\n"
76 "usage: del_autoconn [<nid>] [<host>] [ks]"},
77 {"conn_list", jt_ptl_print_connections, 0, "connect to a remote nid\n"
78 "usage: print_conns"},
79 {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
80 "usage: connect <host> <port> [iIOC]"},
81 {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
82 "usage: disconnect [<nid>]"},
83 {"active_tx", jt_ptl_print_active_txs, 0, "print active transmits (no args)\n"
85 {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
86 "The nid defaults to hostname for tcp networks and is automatically "
87 "setup for elan/myrinet/scimac networks.\n"
88 "usage: mynid [<nid>]"},
89 {"shownid", jt_ptl_shownid, 0, "print the local NID\n"
91 {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n"
92 "usage: add_uuid <uuid> <nid> <net_type>"},
93 {"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n"
94 "usage: close_uuid <uuid> <net-type>)"},
95 {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
96 "usage: del_uuid <uuid>"},
97 {"add_route", jt_ptl_add_route, 0,
98 "add an entry to the portals routing table\n"
99 "usage: add_route <gateway> <target> [<target>]"},
100 {"del_route", jt_ptl_del_route, 0,
101 "delete the route via the given gateway to the given targets from the portals routing table\n"
102 "usage: del_route <gateway> [<target>] [<target>]"},
103 {"set_route", jt_ptl_notify_router, 0,
104 "enable/disable routes via the given gateway in the portals routing table\n"
105 "usage: set_route <gateway> <up/down> [<time>]"},
106 {"route_list", jt_ptl_print_routes, 0, "print the portals routing table\n"
107 "usage: route_list"},
108 {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
109 "if size is omited the current size is reported.\n"
110 "usage: recv_mem [size]"},
111 {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
112 "if size is omited the current size is reported.\n"
113 "usage: send_mem [size]"},
114 {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omitting the "
115 "argument will cause the current nagle setting to be reported.\n"
116 "usage: nagle [on/off]"},
117 {"fail", jt_ptl_fail_nid, 0, "fail/restore communications.\n"
118 "Omitting the count means indefinitely, 0 means restore, "
119 "otherwise fail 'count' messages.\n"
120 "usage: fail nid|_all_ [count]"},
122 /* Device selection commands */
123 {"=== device selection ===", jt_noop, 0, "device selection"},
124 {"newdev", jt_lcfg_newdev, 0, "create a new device\n"
126 {"device", jt_obd_device, 0,
127 "set current device to <%name|$name|devno>\n"
128 "usage: device <%name|$name|devno>"},
129 {"cfg_device", jt_lcfg_device, 0,
130 "set current device being configured to <$name>\n"
131 "usage: device <name>"},
132 {"device_list", jt_obd_list, 0, "show all devices\n"
133 "usage: device_list"},
134 {"dl", jt_obd_list, 0, "show all devices\n"
136 {"lustre_build_version", jt_get_version, 0,
137 "print the build version of lustre\n"
138 "usage: lustre_build_version"},
140 /* Device configuration commands */
141 {"==== device config =====", jt_noop, 0, "device config"},
142 {"attach", jt_lcfg_attach, 0,
143 "set the type of the current device (with <name> and <uuid>)\n"
144 "usage: attach type [name [uuid]]"},
145 {"setup", jt_lcfg_setup, 0,
146 "type specific device configuration information\n"
147 "usage: setup <args...>"},
148 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
149 "usage: cleanup [force | failover]"},
150 {"detach", jt_obd_detach, 0,
151 "remove driver (and name and uuid) from current device\n"
153 {"lov_setup", jt_lcfg_lov_setup, 0,
154 "write setup an lov device\n"
155 "usage: lov_setconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
156 {"lov_getconfig", jt_obd_lov_getconfig, 0,
157 "read lov configuration from an mds device\n"
158 "usage: lov_getconfig lov-uuid"},
159 {"record", jt_cfg_record, 0, "record commands that follow in log\n"
160 "usage: record cfg-uuid-name"},
161 {"endrecord", jt_cfg_endrecord, 0, "stop recording\n"
163 {"parse", jt_cfg_parse, 0, "parse the log of recorded commands for this config\n"
164 "usage: parse config-uuid-name"},
165 {"dump_log", jt_cfg_dump_log, 0, "print log of recorded commands for this config to kernel debug log\n"
166 "usage: dump_log config-uuid-name"},
168 /* Device operations */
169 {"=== device operations ==", jt_noop, 0, "device operations"},
170 {"probe", jt_obd_connect, 0,
171 "build a connection handle to a device. This command is used to "
172 "suspend configuration until lctl has ensured that the mds and osc "
173 "services are available. This is to avoid mount failures in a "
174 "rebooting cluster.\n"
175 "usage: probe [timeout]"},
176 {"close", jt_obd_disconnect, 0,
177 "close the connection handle\n"
179 {"getattr", jt_obd_getattr, 0,
180 "get attribute for OST object <objid>\n"
181 "usage: getattr <objid>"},
182 {"setattr", jt_obd_setattr, 0,
183 "set mode attribute for OST object <objid>\n"
184 "usage: setattr <objid> <mode>"},
185 {"create", jt_obd_create, 0,
186 "create <num> OST objects (with <mode>)\n"
187 "usage: create [num [mode [verbose [lsm data]]]]"},
188 {"destroy", jt_obd_destroy, 0,
189 "destroy OST object <objid> [num [verbose]]\n"
190 "usage: destroy <num> objects, starting at objid <objid>"},
191 {"test_getattr", jt_obd_test_getattr, 0,
192 "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
193 "usage: test_getattr <num> [verbose [[t]objid]]"},
194 {"test_brw", jt_obd_test_brw, 0,
195 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
196 "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
197 {"get_stripe", jt_obd_get_stripe, 0,
198 "show stripe info for an echo client object\n"
199 "usage: get_stripe objid\n"},
200 {"set_stripe", jt_obd_set_stripe, 0,
201 "set stripe info for an echo client object\n"
202 "usage: set_stripe objid[=width!count[@offset][:id:id...]\n"},
203 {"unset_stripe", jt_obd_unset_stripe, 0,
204 "unset stripe info for an echo client object\n"
205 "usage: unset_stripe objid\n"},
206 {"test_ldlm", jt_obd_test_ldlm, 0,
207 "perform lock manager test\n"
209 {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
210 "start lock manager stress test\n"
211 "usage: ldlm_regress_start [numthreads [refheld [numres [numext]]]]"},
212 {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
213 "stop lock manager stress test (no args)\n"},
214 {"dump_ldlm", jt_obd_dump_ldlm, 0,
215 "dump all lock manager state (no args)"},
216 {"activate", jt_obd_activate, 0, "activate an import\n"},
217 {"deactivate", jt_obd_deactivate, 0, "deactivate an import\n"},
218 {"recover", jt_obd_recover, 0, "usage: recover [<connection UUID>]"},
219 {"lookup", jt_obd_mdc_lookup, 0, "usage: lookup <directory> <file>"},
220 {"notransno", jt_obd_no_transno, 0,
221 "disable sending of committed-transno updates\n"},
222 {"readonly", jt_obd_set_readonly, 0,
223 "disable writes to the underlying device\n"},
224 {"abort_recovery", jt_obd_abort_recovery, 0,
225 "abort recovery on MDS device\n"},
226 {"mount_option", jt_lcfg_mount_option, 0,
227 "usage: mount_option profile osc_name [mdc_name] \n"},
228 {"del_mount_option", jt_lcfg_del_mount_option, 0,
229 "usage: del_mount_option profile\n"},
230 {"set_timeout", jt_lcfg_set_timeout, 0,
231 "usage: set_timeout <secs>\n"},
232 {"set_lustre_upcall", jt_lcfg_set_lustre_upcall, 0,
233 "usage: set_lustre_upcall </full/path/to/upcall> \n"},
235 /* Llog operations */
236 {"llog_catlist", jt_llog_catlist, 0,
237 "list all catalog logs on current device.\n"
238 "usage: llog_catlist"},
239 {"llog_info", jt_llog_info, 0,
240 "print log header information.\n"
241 "usage: llog_info <$logname|#oid#ogr#ogen>\n"
242 " oid, ogr and ogen are hexadecimal."},
243 {"llog_print", jt_llog_print, 0,
244 "print log content information.\n"
245 "usage: llog_print <$logname|#oid#ogr#ogen> [from] [to]\n"
246 " oid, ogr and ogen are hexadecimal.\n"
247 " print all records from index 1 by default."},
248 {"llog_check", jt_llog_check, 0,
249 "print log content information.\n"
250 "usage: llog_check <$logname|#oid#ogr#ogen> [from] [to]\n"
251 " oid, ogr and ogen are hexadecimal.\n"
252 " check all records from index 1 by default."},
253 {"llog_cancel", jt_llog_cancel, 0,
254 "cancel one record in log.\n"
255 "usage: llog_cancel <catlog id|catlog name> <log id> <index>"},
256 {"llog_remove", jt_llog_remove, 0,
257 "remove one log from catlog, erase it from disk.\n"
258 "usage: llog_remove <catlog id|catlog name> <log id>"},
261 {"======== debug =========", jt_noop, 0, "debug"},
262 {"debug_daemon", jt_dbg_debug_daemon, 0,
263 "debug daemon control and dump to a file"
264 "usage: debug_daemon [start file <#MB>|stop|pause|continue]"},
265 {"debug_kernel", jt_dbg_debug_kernel, 0,
266 "get debug buffer and dump to a file"
267 "usage: debug_kernel [file] [raw]"},
268 {"dk", jt_dbg_debug_kernel, 0,
269 "get debug buffer and dump to a file"
270 "usage: dk [file] [raw]"},
271 {"debug_file", jt_dbg_debug_file, 0,
272 "read debug buffer from input and dump to output"
273 "usage: debug_file <input> [output] [raw]"},
274 {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
276 {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
277 "usage: mark <text>"},
278 {"filter", jt_dbg_filter, 0, "filter message type\n"
279 "usage: filter <subsystem id/debug mask>"},
280 {"show", jt_dbg_show, 0, "show message type\n"
281 "usage: show <subsystem id/debug mask>"},
282 {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
283 "usage: debug_list <subs/types>"},
284 {"modules", jt_dbg_modules, 0,
285 "provide gdb-friendly module information\n"
286 "usage: modules <path>"},
287 {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
289 {"lwt", jt_ptl_lwt, 0,
290 "light-weight tracing\n"
293 {"memhog", jt_ptl_memhog, 0,
294 "memory pressure testing\n"
295 "usage: memhog <page count> [<gfp flags>]"},
297 /* User interface commands */
298 {"======= control ========", jt_noop, 0, "control commands"},
299 {"help", Parser_help, 0, "help"},
300 {"exit", jt_quit, 0, "quit"},
301 {"quit", jt_quit, 0, "quit"},
305 int lctl_main(int argc, char **argv)
311 ptl_initialize(argc, argv);
312 if (obd_initialize(argc, argv) < 0)
314 if (dbg_initialize(argc, argv) < 0)
317 Parser_init("lctl > ", cmdlist);
320 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
322 rc = Parser_commands();
325 obd_finalize(argc, argv);
330 int main (int argc, char **argv)
332 return (lctl_main (argc, argv));