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/ptlctl.h>
33 static int jt_quit(int argc, char **argv) {
34 Parser_quit(argc, argv);
38 static int jt_noop(int argc, char **argv) {
42 command_t cmdlist[] = {
44 {"--device", jt_opt_device, 0,
45 "run <command> after connecting to device <devno>\n"
46 "--device <devno> <command [args ...]>"},
47 {"--threads", jt_opt_threads, 0,
48 "run <threads> separate instances of <command> on device <devno>\n"
49 "--threads <threads> <devno> <command [args ...]>"},
51 /* Network configuration commands */
52 {"==== network config ====", jt_noop, 0, "network config"},
53 {"network", jt_ptl_network, 0, "commands that follow apply to net\n"
54 "usage: network <tcp/elan/myrinet>"},
55 {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
56 "usage: connect [[<hostname> <port>] | <elan id>]"},
57 {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
58 "usage: disconnect <nid>"},
59 {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
60 "The nid defaults to hostname for tcp networks and is automatically "
61 "setup for elan/myrinet networks.\n"
62 "usage: mynid [nid]"},
63 {"add_uuid", jt_ptl_add_uuid, 0, "associate a UUID with a nid\n"
64 "usage: add_uuid <uuid> <nid>"},
65 {"close_uuid", jt_ptl_close_uuid, 0, "disconnect a UUID\n"
66 "usage: close_uuid <uuid>)"},
67 {"del_uuid", jt_ptl_del_uuid, 0, "delete a UUID association\n"
68 "usage: del_uuid <uuid>"},
69 {"add_route", jt_ptl_add_route, 0,
70 "add an entry to the routing table\n"
71 "usage: add_route <gateway> <target> [target]"},
72 {"del_route", jt_ptl_del_route, 0,
73 "delete an entry from the routing table\n"
74 "usage: del_route <target>"},
75 {"route_list", jt_ptl_print_routes, 0, "print the routing table\n"
77 {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
78 "if size is omited the current size is reported.\n"
79 "usage: recv_mem [size]"},
80 {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
81 "if size is omited the current size is reported.\n"
82 "usage: send_mem [size]"},
83 {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omiting the "
84 "argument will cause the current nagle setting to be reported.\n"
85 "usage: nagle [on/off]"},
87 /* Device selection commands */
88 {"=== device selection ===", jt_noop, 0, "device selection"},
89 {"newdev", jt_obd_newdev, 0, "create a new device\n"
92 {"uuid2dev", jt_obd_uuid2dev, 0,
93 "find device attached with <uuid> and make it the current device\n"
94 "usage: uuid2dev <uuid>"},
96 {"name2dev", jt_obd_name2dev, 0,
97 "find device attached with <name> and make it the current device\n"
98 "usage: name2dev <name>"},
99 {"device", jt_obd_device, 0, "set current device to <devno>\n"
100 "usage: device <devno>"},
101 {"device_list", jt_obd_list, 0, "show all devices\n"
102 "usage: device_list"},
104 /* Device configuration commands */
105 {"==== device config =====", jt_noop, 0, "device config"},
106 {"attach", jt_obd_attach, 0,
107 "set the type of the current device (with <name> and <uuid>)\n"
108 "usage: attach type [name [uuid]]"},
109 {"setup", jt_obd_setup, 0,
110 "type specific device configuration information\n"
111 "usage: setup <args...>"},
112 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
114 {"detach", jt_obd_detach, 0,
115 "remove driver (and name and uuid) from current device\n"
117 {"lovconfig", jt_obd_lov_config, 0,
118 "write lov configuration to an mds device\n"
119 "usage: lovconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
121 /* Device operations */
122 {"=== device operations ==", jt_noop, 0, "device operations"},
123 {"probe", jt_obd_connect, 0,
124 "build a connection handle to a device. This command is used to "
125 "suspend configuration until lctl has ensured that the mds and osc "
126 "services are available. This is to avoid mount failures in a "
127 "rebooting cluster.\n"
128 "usage: probe [timeout]"},
129 {"close", jt_obd_disconnect, 0,
130 "close the connection handle\n"
132 {"getattr", jt_obd_getattr, 0,
133 "get attribute for OST object <objid>\n"
134 "usage: getattr <objid>"},
135 {"setattr", jt_obd_setattr, 0,
136 "set mode attribute for OST object <objid>\n"
137 "usage: setattr <objid> <mode>"},
138 {"create", jt_obd_create, 0,
139 "create <num> OST objects (with <mode>)\n"
140 "usage: create [num [mode [verbose]]]"},
141 {"destroy", jt_obd_destroy, 0,
142 "destroy OST object <objid>\n"
143 "usage: destroy <objid>"},
144 {"test_getattr", jt_obd_test_getattr, 0,
145 "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
146 "usage: test_getattr <num> [verbose [[t]objid]]"},
147 {"test_brw", jt_obd_test_brw, 0,
148 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
149 "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
150 {"test_ldlm", jt_obd_test_ldlm, 0,
151 "perform lock manager test\n"
153 {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
154 "start lock manager stress test\n"
155 "usage: %s [numthreads [refheld [numres [numext]]]]"},
156 {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
157 "stop lock manager stress test (no args)\n"},
158 {"dump_ldlm", jt_obd_dump_ldlm, 0,
159 "dump all lock manager state (no args)"},
160 {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
163 {"======== debug =========", jt_noop, 0, "debug"},
164 {"debug_kernel", jt_dbg_debug_kernel, 0,
165 "get debug buffer and dump to a file"
166 "usage: debug_kernel [file] [raw]"},
167 {"debug_file", jt_dbg_debug_file, 0,
168 "read debug buffer from input and dump to output"
169 "usage: debug_file <input> [output] [raw]"},
170 {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
172 {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
173 "usage: mark <text>"},
174 {"filter", jt_dbg_filter, 0, "filter message type\n"
175 "usage: filter <subsystem id/debug mask>"},
176 {"show", jt_dbg_show, 0, "show message type\n"
177 "usage: show <subsystem id/debug mask>"},
178 {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
179 "usage: debug_list <subs/types>"},
180 {"modules", jt_dbg_modules, 0,
181 "provide gdb-friendly module information\n"
182 "usage: modules <path>"},
183 {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
186 /* User interface commands */
187 {"======= control ========", jt_noop, 0, "control commands"},
188 {"help", Parser_help, 0, "help"},
189 {"exit", jt_quit, 0, "quit"},
190 {"quit", jt_quit, 0, "quit"},
196 int main(int argc, char **argv)
202 ptl_initialize(argc, argv);
203 if (obd_initialize(argc, argv) < 0)
205 if (dbg_initialize(argc, argv) < 0)
209 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
211 Parser_init("lctl > ", cmdlist);
212 rc = Parser_commands();
215 obd_cleanup(argc, argv);