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>"},
68 {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
69 "usage: connect [[<hostname> <port>] | <elan id>]"},
70 {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
71 "usage: disconnect <nid>"},
72 {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
73 "The nid defaults to hostname for tcp networks and is automatically "
74 "setup for elan/myrinet networks.\n"
75 "usage: mynid [nid]"},
76 {"add_uuid", jt_obd_add_uuid, 0, "associate a UUID with a nid\n"
77 "usage: add_uuid <uuid> <nid> <net_type>"},
78 {"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n"
79 "usage: close_uuid <uuid> <net-type>)"},
80 {"del_uuid", jt_obd_del_uuid, 0, "delete a UUID association\n"
81 "usage: del_uuid <uuid>"},
82 {"add_route", jt_ptl_add_route, 0,
83 "add an entry to the routing table\n"
84 "usage: add_route <gateway> <target> [target]"},
85 {"del_route", jt_ptl_del_route, 0,
86 "delete an entry from the routing table\n"
87 "usage: del_route <target>"},
88 {"route_list", jt_ptl_print_routes, 0, "print the routing table\n"
90 {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
91 "if size is omited the current size is reported.\n"
92 "usage: recv_mem [size]"},
93 {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
94 "if size is omited the current size is reported.\n"
95 "usage: send_mem [size]"},
96 {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omiting the "
97 "argument will cause the current nagle setting to be reported.\n"
98 "usage: nagle [on/off]"},
100 /* Device selection commands */
101 {"=== device selection ===", jt_noop, 0, "device selection"},
102 {"newdev", jt_obd_newdev, 0, "create a new device\n"
105 {"uuid2dev", jt_obd_uuid2dev, 0,
106 "find device attached with <uuid> and make it the current device\n"
107 "usage: uuid2dev <uuid>"},
109 {"name2dev", jt_obd_name2dev, 0,
110 "find device attached with <name> and make it the current device\n"
111 "usage: name2dev <name>"},
112 {"device", jt_obd_device, 0, "set current device to <devno>\n"
113 "usage: device <devno>"},
114 {"device_list", jt_obd_list, 0, "show all devices\n"
115 "usage: device_list"},
116 {"lustre_build_version", jt_get_version, 0,
117 "print the build version of lustre\n"
118 "usage: lustre_build_version"},
120 /* Device configuration commands */
121 {"==== device config =====", jt_noop, 0, "device config"},
122 {"attach", jt_obd_attach, 0,
123 "set the type of the current device (with <name> and <uuid>)\n"
124 "usage: attach type [name [uuid]]"},
125 {"setup", jt_obd_setup, 0,
126 "type specific device configuration information\n"
127 "usage: setup <args...>"},
128 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
129 "usage: cleanup [force]"},
130 {"detach", jt_obd_detach, 0,
131 "remove driver (and name and uuid) from current device\n"
133 {"lov_setconfig", jt_obd_lov_setconfig, 0,
134 "write lov configuration to an mds device\n"
135 "usage: lov_setconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
136 {"lov_getconfig", jt_obd_lov_getconfig, 0,
137 "read lov configuration from an mds device\n"
138 "usage: lov_getconfig lov-uuid"},
140 /* Device operations */
141 {"=== device operations ==", jt_noop, 0, "device operations"},
142 {"probe", jt_obd_connect, 0,
143 "build a connection handle to a device. This command is used to "
144 "suspend configuration until lctl has ensured that the mds and osc "
145 "services are available. This is to avoid mount failures in a "
146 "rebooting cluster.\n"
147 "usage: probe [timeout]"},
148 {"close", jt_obd_disconnect, 0,
149 "close the connection handle\n"
151 {"getattr", jt_obd_getattr, 0,
152 "get attribute for OST object <objid>\n"
153 "usage: getattr <objid>"},
154 {"setattr", jt_obd_setattr, 0,
155 "set mode attribute for OST object <objid>\n"
156 "usage: setattr <objid> <mode>"},
157 {"create", jt_obd_create, 0,
158 "create <num> OST objects (with <mode>)\n"
159 "usage: create [num [mode [verbose]]]"},
160 {"destroy", jt_obd_destroy, 0,
161 "destroy OST object <objid> [num [verbose]]\n"
162 "usage: destroy <num> objects, starting at objid <objid>"},
163 {"test_getattr", jt_obd_test_getattr, 0,
164 "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
165 "usage: test_getattr <num> [verbose [[t]objid]]"},
166 {"test_brw", jt_obd_test_brw, 0,
167 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
168 "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
169 {"get_stripe", jt_obd_get_stripe, 0,
170 "show stripe info for an echo client object\n"
171 "usage: get_stripe objid\n"},
172 {"set_stripe", jt_obd_set_stripe, 0,
173 "set stripe info for an echo client object\n"
174 "usage: set_stripe objid[=width!count[@offset][:id:id...]\n"},
175 {"unset_stripe", jt_obd_unset_stripe, 0,
176 "unset stripe info for an echo client object\n"
177 "usage: unset_stripe objid\n"},
178 {"test_ldlm", jt_obd_test_ldlm, 0,
179 "perform lock manager test\n"
181 {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
182 "start lock manager stress test\n"
183 "usage: ldlm_regress_start [numthreads [refheld [numres [numext]]]]"},
184 {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
185 "stop lock manager stress test (no args)\n"},
186 {"dump_ldlm", jt_obd_dump_ldlm, 0,
187 "dump all lock manager state (no args)"},
188 {"lov_set_osc_active", jt_obd_lov_set_osc_active, 0,
189 "(de)activate an OSC in a LOV\n"
190 "usage: lov_set_osc_active <OSC UUID> <1|0 (active|inactive)>"},
191 {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
192 {"failconn", jt_obd_failconn, 0, "failconn <uuid>"},
193 {"lookup", jt_obd_mdc_lookup, 0, "usage: lookup <directory> <file>"},
194 {"notransno", jt_obd_no_transno, 0,
195 "disable sending of committed-transno updates\n"
197 {"readonly", jt_obd_set_readonly, 0,
198 "disable writes to the underlying device\n"
202 {"======== debug =========", jt_noop, 0, "debug"},
203 {"debug_kernel", jt_dbg_debug_kernel, 0,
204 "get debug buffer and dump to a file"
205 "usage: debug_kernel [file] [raw]"},
206 {"debug_file", jt_dbg_debug_file, 0,
207 "read debug buffer from input and dump to output"
208 "usage: debug_file <input> [output] [raw]"},
209 {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
211 {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
212 "usage: mark <text>"},
213 {"filter", jt_dbg_filter, 0, "filter message type\n"
214 "usage: filter <subsystem id/debug mask>"},
215 {"show", jt_dbg_show, 0, "show message type\n"
216 "usage: show <subsystem id/debug mask>"},
217 {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
218 "usage: debug_list <subs/types>"},
219 {"modules", jt_dbg_modules, 0,
220 "provide gdb-friendly module information\n"
221 "usage: modules <path>"},
222 {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
225 /* User interface commands */
226 {"======= control ========", jt_noop, 0, "control commands"},
227 {"help", Parser_help, 0, "help"},
228 {"exit", jt_quit, 0, "quit"},
229 {"quit", jt_quit, 0, "quit"},
235 int main(int argc, char **argv)
241 ptl_initialize(argc, argv);
242 if (obd_initialize(argc, argv) < 0)
244 if (dbg_initialize(argc, argv) < 0)
248 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
250 Parser_init("lctl > ", cmdlist);
251 rc = Parser_commands();
254 obd_cleanup(argc, argv);