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 <lnet/lnetctl.h>
34 static int jt_quit(int argc, char **argv) {
35 Parser_quit(argc, argv);
39 static int jt_noop(int argc, char **argv) {
43 static int jt_opt_ignore_errors(int argc, char **argv) {
44 Parser_ignore_errors(1);
48 command_t cmdlist[] = {
50 {"===== metacommands =======", jt_noop, 0, "metacommands"},
51 {"--device", jt_opt_device, 0,
52 "run <command> after connecting to device <devno>\n"
53 "--device <devno> <command [args ...]>"},
54 {"--ignore_errors", jt_opt_ignore_errors, 0,
55 "ignore errors that occur during script processing\n"
57 {"ignore_errors", jt_opt_ignore_errors, 0,
58 "ignore errors that occur during script processing\n"
61 /* User interface commands */
62 {"======== control =========", jt_noop, 0, "control commands"},
63 {"help", Parser_help, 0, "help"},
64 {"lustre_build_version", jt_get_version, 0,
65 "print the build version of lustre\n"
66 "usage: lustre_build_version"},
67 {"exit", jt_quit, 0, "quit"},
68 {"quit", jt_quit, 0, "quit"},
70 /* Network configuration commands */
71 {"===== network config =====", jt_noop, 0, "network config"},
72 {"--net", jt_opt_net, 0, "run <command> after setting network to <net>\n"
73 "usage: --net <tcp/elan/gm/...> <command>"},
74 {"network", jt_ptl_network, 0, "configure LNET"
75 "usage: network up|down"},
76 {"net", jt_ptl_network, 0, "configure LNET"
77 "usage: net up|down"},
78 {"list_nids", jt_ptl_list_nids, 0, "list local NIDs"
79 "usage: list_nids [all]"},
80 {"which_nid", jt_ptl_which_nid, 0, "choose a NID"
81 "usage: which_nid NID [NID...]"},
82 {"interface_list", jt_ptl_print_interfaces,0,"print interface entries\n"
83 "usage: interface_list"},
84 {"peer_list", jt_ptl_print_peers, 0, "print peer entries\n"
86 {"conn_list", jt_ptl_print_connections, 0, "print all the connected remote nid\n"
88 {"active_tx", jt_ptl_print_active_txs, 0, "print active transmits\n"
90 {"route_list", jt_ptl_print_routes, 0,
91 "print the portals routing table, same as show_route\n"
93 {"show_route", jt_ptl_print_routes, 0,
94 "print the portals routing table, same as route_list\n"
96 {"ping", jt_ptl_ping, 0, "Check LNET connectivity\n"
97 "usage: ping nid [timeout] [pid]"},
99 /* Device selection commands */
100 {"==== device selection ====", jt_noop, 0, "device selection"},
101 {"device", jt_obd_device, 0,
102 "set current device to <name|devno>\n"
103 "usage: device <%name|$name|devno>"},
104 {"device_list", jt_obd_list, 0, "show all devices\n"
105 "usage: device_list"},
106 {"dl", jt_obd_list, 0, "show all devices\n"
109 /* Device operations */
110 {"==== device operations ===", jt_noop, 0, "device operations"},
111 {"activate", jt_obd_activate, 0, "activate an import\n"},
112 {"deactivate", jt_obd_deactivate, 0, "deactivate an import. "
113 "This command should be used on failed OSC devices in an MDT LOV.\n"},
114 {"abort_recovery", jt_obd_abort_recovery, 0,
115 "abort recovery on a restarting MDT or OST device\n"},
116 {"set_timeout", jt_lcfg_set_timeout, 0,
117 "usage: conf_param obd_timeout=<secs>\n"},
118 {"conf_param", jt_lcfg_mgsparam, 0, "set a permanent config param. "
119 "This command must be run on the MGS node\n"
120 "usage: conf_param <target.keyword=val> ...\n"},
121 {"local_param", jt_lcfg_param, 0, "set a temporary, local param\n"
122 "usage: local_param <target.keyword=val> ...\n"},
125 {"==== debugging control ===", jt_noop, 0, "debug"},
126 {"debug_daemon", jt_dbg_debug_daemon, 0,
127 "debug daemon control and dump to a file\n"
128 "usage: debug_daemon {start file [#MB]|stop}"},
129 {"debug_kernel", jt_dbg_debug_kernel, 0,
130 "get debug buffer and dump to a file, same as dk\n"
131 "usage: debug_kernel [file] [raw]"},
132 {"dk", jt_dbg_debug_kernel, 0,
133 "get debug buffer and dump to a file, same as debug_kernel\n"
134 "usage: dk [file] [raw]"},
135 {"debug_file", jt_dbg_debug_file, 0,
136 "convert a binary debug file dumped by the kernel to ASCII text\n"
137 "usage: debug_file <input> [output]"},
138 {"df", jt_dbg_debug_file, 0,
139 "read debug buffer from input and dump to output, same as debug_file\n"
140 "usage: df <input> [output]"},
141 {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
143 {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
144 "usage: mark <text>"},
145 {"filter", jt_dbg_filter, 0, "filter message type\n"
146 "usage: filter <subsystem id/debug mask>"},
147 {"show", jt_dbg_show, 0, "Show specific type of messages\n"
148 "usage: show <subsystem id/debug mask>"},
149 {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
150 "usage: debug_list <subs/types>"},
151 {"modules", jt_dbg_modules, 0,
152 "provide gdb-friendly module information\n"
153 "usage: modules <path>"},
155 /* Device configuration commands */
156 {"== device setup (these are not normally used post 1.4) ==",
157 jt_noop, 0, "device config"},
158 {"attach", jt_lcfg_attach, 0,
159 "set the type, name, and uuid of the current device\n"
160 "usage: attach type name uuid"},
161 {"detach", jt_obd_detach, 0,
162 "remove driver (and name and uuid) from current device\n"
164 {"setup", jt_lcfg_setup, 0,
165 "type specific device configuration information\n"
166 "usage: setup <args...>"},
167 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
168 "usage: cleanup [force | failover]"},
169 {"dump_cfg", jt_cfg_dump_log, 0, "print log of recorded commands for this config to kernel debug log\n"
170 "usage: dump_cfg config-uuid-name"},
172 /* Test only commands */
173 {"=== testing (DANGEROUS) ==", jt_noop, 0, "testing (DANGEROUS)"},
174 {"--threads", jt_opt_threads, 0,
175 "run <threads> separate instances of <command> on device <devno>\n"
176 "--threads <threads> <verbose> <devno> <command [args ...]>"},
177 {"lookup", jt_obd_mdc_lookup, 0, "report file mode info\n"
178 "usage: lookup <directory> <file>"},
179 {"readonly", jt_obd_set_readonly, 0,
180 "disable writes to the underlying device\n"},
181 {"notransno", jt_obd_no_transno, 0,
182 "disable sending of committed-transno updates\n"},
183 {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n"
184 "usage: add_uuid <uuid> <nid>"},
185 {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
186 "usage: del_uuid <uuid>"},
187 {"add_peer", jt_ptl_add_peer, 0, "add an peer entry\n"
188 "usage: add_peer <nid> <host> <port>"},
189 {"del_peer", jt_ptl_del_peer, 0, "remove an peer entry\n"
190 "usage: del_autoconn [<nid>] [<host>] [ks]"},
191 {"add_conn ", jt_lcfg_add_conn, 0,
192 "usage: add_conn <conn_uuid> [priority]\n"},
193 {"del_conn ", jt_lcfg_del_conn, 0,
194 "usage: del_conn <conn_uuid> \n"},
195 {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
196 "usage: disconnect [<nid>]"},
197 {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
198 "The nid defaults to hostname for tcp networks and is automatically "
199 "setup for elan/myrinet networks.\n"
200 "usage: mynid [<nid>]"},
201 {"fail", jt_ptl_fail_nid, 0, "fail/restore communications.\n"
202 "Omitting the count means indefinitely, 0 means restore, "
203 "otherwise fail 'count' messages.\n"
204 "usage: fail nid|_all_ [count]"},
205 {"getattr", jt_obd_getattr, 0,
206 "get attribute for OST object <objid>\n"
207 "usage: getattr <objid>"},
208 {"setattr", jt_obd_setattr, 0,
209 "set mode attribute for OST object <objid>\n"
210 "usage: setattr <objid> <mode>"},
211 {"create", jt_obd_create, 0,
212 "create <num> OST objects (with <mode>)\n"
213 "usage: create [num [mode [verbose [lsm data]]]]"},
214 {"destroy", jt_obd_destroy, 0,
215 "destroy OST object <objid> [num [verbose]]\n"
216 "usage: destroy <num> objects, starting at objid <objid>"},
217 {"test_getattr", jt_obd_test_getattr, 0,
218 "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
219 "usage: test_getattr <num> [verbose [[t]objid]]"},
220 {"test_setattr", jt_obd_test_setattr, 0,
221 "do <num> setattrs (on OST object <objid> (objid+1 on each thread))\n"
222 "usage: test_setattr <num> [verbose [[t]objid]]"},
223 {"test_brw", jt_obd_test_brw, 0,
224 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
225 "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
226 {"lwt", jt_ptl_lwt, 0,
227 "light-weight tracing\n"
230 {"memhog", jt_ptl_memhog, 0,
231 "memory pressure testing\n"
232 "usage: memhog <page count> [<gfp flags>]"},
234 {"== obsolete (DANGEROUS) ==", jt_noop, 0, "obsolete (DANGEROUS)"},
235 /* some test scripts still use these */
236 {"cfg_device", jt_obd_device, 0,
237 "set current device to <name>\n"
238 "usage: device <name>"},
239 {"recover", jt_obd_recover, 0,
240 "try to restore a lost connection immediately\n"
241 "usage: recover [MDC/OSC device]"},
242 /* saving for sanity 44a */
243 {"lov_getconfig", jt_obd_lov_getconfig, 0,
244 "read lov configuration from an mds device\n"
245 "usage: lov_getconfig <mountpoint>"},
246 /* Llog operations */
247 {"llog_catlist", jt_llog_catlist, 0,
248 "list all catalog logs on current device.\n"
249 "usage: llog_catlist"},
250 {"llog_info", jt_llog_info, 0,
251 "print log header information.\n"
252 "usage: llog_info <$logname|#oid#ogr#ogen>\n"
253 " oid, ogr and ogen are hexadecimal."},
254 {"llog_print", jt_llog_print, 0,
255 "print log content information.\n"
256 "usage: llog_print <$logname|#oid#ogr#ogen> [from] [to]\n"
257 " oid, ogr and ogen are hexadecimal.\n"
258 " print all records from index 1 by default."},
259 {"llog_check", jt_llog_check, 0,
260 "print log content information.\n"
261 "usage: llog_check <$logname|#oid#ogr#ogen> [from] [to]\n"
262 " oid, ogr and ogen are hexadecimal.\n"
263 " check all records from index 1 by default."},
264 {"llog_cancel", jt_llog_cancel, 0,
265 "cancel one record in log.\n"
266 "usage: llog_cancel <catalog id|catalog name> <log id> <index>"},
267 {"llog_remove", jt_llog_remove, 0,
268 "remove one log from catalog, erase it from disk.\n"
269 "usage: llog_remove <catalog id|catalog name> <log id>"},
270 /* network operations */
271 {"add_interface", jt_ptl_add_interface, 0, "add interface entry\n"
272 "usage: add_interface ip [netmask]"},
273 {"del_interface", jt_ptl_del_interface, 0, "del interface entry\n"
274 "usage: del_interface [ip]"},
275 {"add_route", jt_ptl_add_route, 0,
276 "add an entry to the portals routing table\n"
277 "usage: add_route <gateway> <target> [<target>]"},
278 {"del_route", jt_ptl_del_route, 0,
279 "delete route via gateway to targets from the portals routing table\n"
280 "usage: del_route <gateway> [<target>] [<target>]"},
281 {"set_route", jt_ptl_notify_router, 0,
282 "enable/disable routes via gateway in the portals routing table\n"
283 "usage: set_route <gateway> <up/down> [<time>]"},
288 int lctl_main(int argc, char **argv)
294 ptl_initialize(argc, argv);
295 if (obd_initialize(argc, argv) < 0)
297 if (dbg_initialize(argc, argv) < 0)
300 Parser_init("lctl > ", cmdlist);
303 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
305 rc = Parser_commands();
308 obd_finalize(argc, argv);
312 #ifndef LIBLUSTRE_TEST
313 int main (int argc, char **argv)
315 return (lctl_main (argc, argv));