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 {"del_uuid", jt_ptl_del_uuid, 0, "delete a uuid association\n"
66 "usage: del_uuid <uuid>"},
67 {"add_route", jt_ptl_add_route, 0,
68 "add an entry to the routing table\n"
69 "usage: add_route <gateway> <target> [target]"},
70 {"del_route", jt_ptl_del_route, 0,
71 "delete an entry from the routing table\n"
72 "usage: del_route <target>"},
73 {"route_list", jt_ptl_print_routes, 0, "print the routing table\n"
75 {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
76 "if size is omited the current size is reported.\n"
77 "usage: recv_mem [size]"},
78 {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
79 "if size is omited the current size is reported.\n"
80 "usage: send_mem [size]"},
81 {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omiting the "
82 "argument will cause the current nagle setting to be reported.\n"
83 "usage: nagle [on/off]"},
85 /* Device selection commands */
86 {"=== device selection ===", jt_noop, 0, "device selection"},
87 {"newdev", jt_obd_newdev, 0, "create a new device\n"
90 {"uuid2dev", jt_obd_uuid2dev, 0,
91 "find device attached with <uuid> and make it the current device\n"
92 "usage: uuid2dev <uuid>"},
94 {"name2dev", jt_obd_name2dev, 0,
95 "find device attached with <name> and make it the current device\n"
96 "usage: name2dev <name>"},
97 {"device", jt_obd_device, 0, "set current device to <devno>\n"
98 "usage: device <devno>"},
99 {"device_list", jt_obd_list, 0, "show all devices\n"
100 "usage: device_list"},
102 /* Device configuration commands */
103 {"==== device config =====", jt_noop, 0, "device config"},
104 {"attach", jt_obd_attach, 0,
105 "set the type of the current device (with <name> and <uuid>)\n"
106 "usage: attach type [name [uuid]]"},
107 {"setup", jt_obd_setup, 0,
108 "type specific device configuration information\n"
109 "usage: setup <args...>"},
110 {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
112 {"detach", jt_obd_detach, 0,
113 "remove driver (and name and uuid) from current device\n"
115 {"lovconfig", jt_obd_lov_config, 0,
116 "write lov configuration to an mds device\n"
117 "usage: lovconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
119 /* Device operations */
120 {"=== device operations ==", jt_noop, 0, "device operations"},
121 {"probe", jt_obd_connect, 0,
122 "build a connection handle to a device. This command is used to "
123 "suspend configuration until lctl has ensured that the mds and osc "
124 "services are available. This is to avoid mount failures in a "
125 "rebooting cluster.\n"
126 "usage: probe [timeout]"},
127 {"close", jt_obd_disconnect, 0,
128 "close the connection handle\n"
130 {"getattr", jt_obd_getattr, 0,
131 "get attribute for OST object <objid>\n"
132 "usage: getattr <objid>"},
133 {"setattr", jt_obd_setattr, 0,
134 "set mode attribute for OST object <objid>\n"
135 "usage: setattr <objid> <mode>"},
136 {"create", jt_obd_create, 0,
137 "create <num> OST objects (with <mode>)\n"
138 "usage: create [num [mode [verbose]]]"},
139 {"destroy", jt_obd_destroy, 0,
140 "destroy OST object <objid>\n"
141 "usage: destroy <objid>"},
142 {"test_getattr", jt_obd_test_getattr, 0,
143 "do <num> getattrs (on OST object <objid>)\n"
144 "usage: test_getattr <num> [verbose [objid]]"},
145 {"test_brw", jt_obd_test_brw, 0,
146 "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
147 "usage: test_brw <num> [write [verbose [npages [objid]]]]"},
148 {"test_ldlm", jt_obd_test_ldlm, 0,
149 "perform lock manager test\n"
151 {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
152 "start lock manager stress test\n"
153 "usage: %s [numthreads [refheld [numres [numext]]]]"},
154 {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
155 "stop lock manager stress test (no args)\n"},
156 {"dump_ldlm", jt_obd_dump_ldlm, 0,
157 "dump all lock manager state (no args)"},
160 {"newconn", jt_newconn, 0, "newconn [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);