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