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/api-support.h>
30 #include <portals/ptlctl.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 {"--device", jt_opt_device, 0,
51 "run <command> after connecting to device <devno>\n"
52 "--device <devno> <command [args ...]>"},
53 {"--threads", jt_opt_threads, 0,
54 "run <threads> separate instances of <command> on device <devno>\n"
55 "--threads <threads> <verbose> <devno> <command [args ...]>"},
56 {"--ignore_errors", jt_opt_ignore_errors, 0,
57 "ignore errors that occur during script processing\n"
59 {"ignore_errors", jt_opt_ignore_errors, 0,
60 "ignore errors that occur during script processing\n"
62 {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"},
64 /* Network configuration commands */
65 {"==== network config ====", jt_noop, 0, "network config"},
66 {"--net", jt_opt_net, 0, "run <command> after setting network to <net>\n"
67 "usage: --net <tcp/elan/myrinet/scimac> <command>"},
68 {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
69 "usage: network <tcp/elan/myrinet/scimac>"},
70 {"autoconn_list", jt_ptl_print_autoconnects, 0, "print autoconnect entries\n"
71 "usage: print_autoconns"},
72 {"add_autoconn", jt_ptl_add_autoconnect, 0, "add an autoconnect entry\n"
73 "usage: add_autoconn <nid> <host> <port> [ixse]"},
74 {"del_autoconn", jt_ptl_del_autoconnect, 0, "remove an autoconnect entry\n"
75 "usage: del_autoconn [<nid>] [<host>] [ks]"},
76 {"conn_list", jt_ptl_print_connections, 0, "connect to a remote nid\n"
77 "usage: print_conns"},
78 {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
79 "usage: connect <host> <port> [ix]"},
80 {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
81 "usage: disconnect [<nid>]"},
82 {"active_tx", jt_ptl_print_active_txs, 0, "print active transmits (no args)\n"
84 {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
85 "The nid defaults to hostname for tcp networks and is automatically "
86 "setup for elan/myrinet/scimac networks.\n"
87 "usage: mynid [<nid>]"},
88 {"shownid", jt_ptl_shownid, 0, "print the local NID\n"
90 {"add_uuid", jt_obd_add_uuid, 0, "associate a UUID with a nid\n"
91 "usage: add_uuid <uuid> <nid> <net_type>"},
92 {"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n"
93 "usage: close_uuid <uuid> <net-type>)"},
94 {"del_uuid", jt_obd_del_uuid, 0, "delete a UUID association\n"
95 "usage: del_uuid <uuid>"},
96 {"add_route", jt_ptl_add_route, 0,
97 "add an entry to the portals routing table\n"
98 "usage: add_route <gateway> <target> [<target>]"},
99 {"del_route", jt_ptl_del_route, 0,
100 "delete the route via the given gateway to the given targets from the portals routing table\n"
101 "usage: del_route <gateway> [<target>] [<target>]"},
102 {"set_route", jt_ptl_notify_router, 0,
103 "enable/disable routes via the given gateway in the portals routing table\n"
104 "usage: set_gw <gateway> <up/down> [<time>]"},
105 {"route_list", jt_ptl_print_routes, 0, "print the portals routing table\n"
106 "usage: route_list"},
107 {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
108 "if size is omited the current size is reported.\n"
109 "usage: recv_mem [size]"},
110 {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
111 "if size is omited the current size is reported.\n"
112 "usage: send_mem [size]"},
113 {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omitting the "
114 "argument will cause the current nagle setting to be reported.\n"
115 "usage: nagle [on/off]"},
116 {"fail", jt_ptl_fail_nid, 0, "fail/restore communications.\n"
117 "Omitting the count means indefinitely, 0 means restore, "
118 "otherwise fail 'count' messages.\n"
119 "usage: fail nid|_all_ [count]"},
121 /* Device selection commands */
122 {"=== device selection ===", jt_noop, 0, "device selection"},
123 {"newdev", jt_obd_newdev, 0, "create a new device\n"
125 {"device", jt_obd_device, 0,
126 "set current device to <%name|$name|devno>\n"
127 "usage: device <%name|$name|devno>"},
128 {"device_list", jt_obd_list, 0, "show all devices\n"
129 "usage: device_list"},
130 {"lustre_build_version", jt_get_version, 0,
131 "print the build version of lustre\n"
132 "usage: lustre_build_version"},
134 /* Device configuration commands */
135 {"==== device config =====", jt_noop, 0, "device config"},
136 {"attach", jt_obd_attach, 0,
137 "set the type of the current device (with <name> and <uuid>)\n"
138 "usage: attach type [name [uuid]]"},
139 {"setup", jt_obd_setup, 0,
140 "type specific device configuration information\n"
141 "usage: setup <args...>"},
142 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
143 "usage: cleanup [force | failover]"},
144 {"detach", jt_obd_detach, 0,
145 "remove driver (and name and uuid) from current device\n"
147 {"lov_setconfig", jt_obd_lov_setconfig, 0,
148 "write lov configuration to an mds device\n"
149 "usage: lov_setconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
150 {"lov_getconfig", jt_obd_lov_getconfig, 0,
151 "read lov configuration from an mds device\n"
152 "usage: lov_getconfig lov-uuid"},
154 /* Device operations */
155 {"=== device operations ==", jt_noop, 0, "device operations"},
156 {"probe", jt_obd_connect, 0,
157 "build a connection handle to a device. This command is used to "
158 "suspend configuration until lctl has ensured that the mds and osc "
159 "services are available. This is to avoid mount failures in a "
160 "rebooting cluster.\n"
161 "usage: probe [timeout]"},
162 {"close", jt_obd_disconnect, 0,
163 "close the connection handle\n"
165 {"getattr", jt_obd_getattr, 0,
166 "get attribute for OST object <objid>\n"
167 "usage: getattr <objid>"},
168 {"setattr", jt_obd_setattr, 0,
169 "set mode attribute for OST object <objid>\n"
170 "usage: setattr <objid> <mode>"},
171 {"create", jt_obd_create, 0,
172 "create <num> OST objects (with <mode>)\n"
173 "usage: create [num [mode [verbose [lsm data]]]]"},
174 {"destroy", jt_obd_destroy, 0,
175 "destroy OST object <objid> [num [verbose]]\n"
176 "usage: destroy <num> objects, starting at objid <objid>"},
177 {"test_getattr", jt_obd_test_getattr, 0,
178 "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
179 "usage: test_getattr <num> [verbose [[t]objid]]"},
180 {"test_brw", jt_obd_test_brw, 0,
181 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
182 "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
183 {"get_stripe", jt_obd_get_stripe, 0,
184 "show stripe info for an echo client object\n"
185 "usage: get_stripe objid\n"},
186 {"set_stripe", jt_obd_set_stripe, 0,
187 "set stripe info for an echo client object\n"
188 "usage: set_stripe objid[=width!count[@offset][:id:id...]\n"},
189 {"unset_stripe", jt_obd_unset_stripe, 0,
190 "unset stripe info for an echo client object\n"
191 "usage: unset_stripe objid\n"},
192 {"test_ldlm", jt_obd_test_ldlm, 0,
193 "perform lock manager test\n"
195 {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
196 "start lock manager stress test\n"
197 "usage: ldlm_regress_start [numthreads [refheld [numres [numext]]]]"},
198 {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
199 "stop lock manager stress test (no args)\n"},
200 {"dump_ldlm", jt_obd_dump_ldlm, 0,
201 "dump all lock manager state (no args)"},
202 {"activate", jt_obd_activate, 0, "activate an import\n"},
203 {"deactivate", jt_obd_deactivate, 0, "deactivate an import\n"},
204 {"recover", jt_obd_recover, 0, "usage: recover [<connection UUID>]"},
205 {"lookup", jt_obd_mdc_lookup, 0, "usage: lookup <directory> <file>"},
206 {"notransno", jt_obd_no_transno, 0,
207 "disable sending of committed-transno updates\n"},
208 {"readonly", jt_obd_set_readonly, 0,
209 "disable writes to the underlying device\n"},
210 {"abort_recovery", jt_obd_abort_recovery, 0,
211 "abort recovery on MDS device\n"},
212 {"mount_option", jt_obd_mount_option, 0,
213 "dump mount options to file\n"},
216 {"======== debug =========", jt_noop, 0, "debug"},
217 {"debug_daemon", jt_dbg_debug_daemon, 0,
218 "debug daemon control and dump to a file"
219 "usage: debug_daemon [start file <#MB>|stop|pause|continue]"},
220 {"debug_kernel", jt_dbg_debug_kernel, 0,
221 "get debug buffer and dump to a file"
222 "usage: debug_kernel [file] [raw]"},
223 {"dk", jt_dbg_debug_kernel, 0,
224 "get debug buffer and dump to a file"
225 "usage: dk [file] [raw]"},
226 {"debug_file", jt_dbg_debug_file, 0,
227 "read debug buffer from input and dump to output"
228 "usage: debug_file <input> [output] [raw]"},
229 {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
231 {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
232 "usage: mark <text>"},
233 {"filter", jt_dbg_filter, 0, "filter message type\n"
234 "usage: filter <subsystem id/debug mask>"},
235 {"show", jt_dbg_show, 0, "show message type\n"
236 "usage: show <subsystem id/debug mask>"},
237 {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
238 "usage: debug_list <subs/types>"},
239 {"modules", jt_dbg_modules, 0,
240 "provide gdb-friendly module information\n"
241 "usage: modules <path>"},
242 {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
244 {"lwt", jt_ptl_lwt, 0,
245 "light-weight tracing\n"
249 /* User interface commands */
250 {"======= control ========", jt_noop, 0, "control commands"},
251 {"help", Parser_help, 0, "help"},
252 {"exit", jt_quit, 0, "quit"},
253 {"quit", jt_quit, 0, "quit"},
259 int main(int argc, char **argv)
265 ptl_initialize(argc, argv);
266 if (obd_initialize(argc, argv) < 0)
268 if (dbg_initialize(argc, argv) < 0)
271 Parser_init("lctl > ", cmdlist);
274 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
276 rc = Parser_commands();
279 obd_cleanup(argc, argv);