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