Whamcloud - gitweb
James Newsome's last dlm regression patch. I haven't reviewed any of the
[fs/lustre-release.git] / lustre / utils / lctl.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
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> 
8  *
9  *   This file is part of Lustre, http://www.lustre.org.
10  *
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.
14  *
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.
19  *
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.
23  *
24  */
25
26
27 #include <stdlib.h>
28 #include <stdio.h>
29 #include <portals/ptlctl.h>
30 #include "obdctl.h"
31 #include "parser.h"
32
33 static int jt_quit(int argc, char **argv) {
34         Parser_quit(argc, argv);
35         return 0;
36 }
37
38 static int jt_noop(int argc, char **argv) {
39         return 0;
40 }
41
42 command_t cmdlist[] = {
43         /* Metacommands */
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 ...]>"},
50
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"
74          "usage: route_list"},
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]"},       
84                 
85         /* Device selection commands */
86         {"=== device selection ===", jt_noop, 0, "device selection"},
87         {"newdev", jt_obd_newdev, 0, "create a new device\n"
88          "usage: newdev"},
89 #if 0
90         {"uuid2dev", jt_obd_uuid2dev, 0,
91          "find device attached with <uuid> and make it the current device\n"
92          "usage: uuid2dev <uuid>"},
93 #endif
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"},
101          
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"
111          "usage: cleanup"},
112         {"detach", jt_obd_detach, 0,
113          "remove driver (and name and uuid) from current device\n"
114          "usage: detach"},
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 ...]"},
118
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.  k\n"
126          "usage: probe [<timeout]"},
127         {"close", jt_obd_disconnect, 0, "close the connection handle\n"
128          "usage: close"},
129         {"getattr", jt_obd_getattr, 0, "get attribute for OST object <objid>\n"
130          "usage: getattr <objid>"},
131         {"setattr", jt_obd_setattr, 0, "set attribute for OST object <objid>\n"
132          "usage: setattr <objid> <mode>"},
133         {"create", jt_obd_create, 0, "create <num> OST objects (with <mode>)\n"
134          "create [num [mode [verbose]]]"},
135         {"destroy", jt_obd_destroy, 0, "destroy OST object <objid>"},
136         {"test_getattr", jt_obd_test_getattr, 0, "perform <num> OST getattr's\n"
137          "usage: test_getattr <num> [verbose]"},
138         {"test_brw", jt_obd_test_brw, 0,
139          "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
140          "usage: test_brw <num> [write [verbose [npages [objid]]]]"},
141         {"test_ldlm", jt_obd_test_ldlm, 0, "perform lock manager test\n"
142          "usage: test_ldlm"},
143         {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
144          "start lock manager stress test (usage: %s [numthreads [refheld "
145          "[numres [numext]]]]\n"}, 
146         {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
147          "stop lock manager stress test (no args)\n"},
148         {"dump_ldlm", jt_obd_dump_ldlm, 0,
149          "dump all lock manager state (no args)"},
150
151 #if 0
152         {"newconn", jt_newconn, 0, "newconn [newuuid]"},
153 #endif
154         /* Debug commands */
155         {"======== debug =========", jt_noop, 0, "debug"},
156         {"debug_kernel", jt_dbg_debug_kernel, 0,
157          "get debug buffer and dump to a file"
158          "usage: debug_kernel [file] [raw]"},
159         {"debug_file", jt_dbg_debug_file, 0,
160          "read debug buffer from input and dump to output"
161          "usage: debug_file <input> [output] [raw]"},
162         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
163          "usage: clear"},
164         {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
165          "usage: mark <text>"},
166         {"filter", jt_dbg_filter, 0, "filter message type\n"
167          "usage: filter <subsystem id/debug mask>"},
168         {"show", jt_dbg_show, 0, "show message type\n"
169          "usage: show <subsystem id/debug mask>"},
170         {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
171          "usage: debug_list <subs/types>"},
172         {"modules", jt_dbg_modules, 0,
173          "provide gdb-friendly module information\n"
174          "usage: modules <path>"},
175         {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
176          "usage: panic"},
177          
178         /* User interface commands */
179         {"======= control ========", jt_noop, 0, "control commands"},
180         {"help", Parser_help, 0, "help"},
181         {"exit", jt_quit, 0, "quit"},
182         {"quit", jt_quit, 0, "quit"},
183         { 0, 0, 0, NULL }
184 };
185
186
187
188 int main(int argc, char **argv) 
189 {
190         int rc;
191
192         setlinebuf(stdout);
193
194         ptl_initialize(argc, argv);
195         if (obd_initialize(argc, argv) < 0)
196                 exit(2);
197         if (dbg_initialize(argc, argv) < 0)
198                 exit(3);
199         
200         if (argc > 1) {
201                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
202         } else {
203                 Parser_init("lctl > ", cmdlist);
204                 rc = Parser_commands();
205         }
206
207         obd_cleanup(argc, argv);
208         return rc;
209 }
210