Whamcloud - gitweb
- comment out the noisy get/put LDLM_DEBUGs; I'll remove them when I'm sure
[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, "--device <devno> <command [args ...]>"},
45         {"--threads", jt_opt_threads, 0,
46                 "--threads <threads> <devno> <command [args ...]>"},
47
48         /* Network configuration commands */
49         {"==== network config ====", jt_noop, 0, "network config"},
50         {"network", jt_ptl_setup, 0, "commands that follow apply to net\n"
51          "usage: network <tcp/elan/myrinet>"},       
52         {"connect", jt_ptl_connect, 0, "connect to a remote nid\n"
53          "usage: connect [[<hostname> <port>] | <elan id>]"},
54         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n"
55          "usage: disconnect <nid>"},
56         {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. "
57          "The nid defaults to hostname for tcp networks and is automatically "
58          "setup for elan/myrinet networks.\n"
59          "usage: mynid [nid]"},
60         {"add_uuid", jt_ptl_add_uuid, 0, "associate a uuid with a nid\n"
61          "usage: add_uuid <uuid> <nid>"},
62         {"del_uuid", jt_ptl_del_uuid, 0, "delete a uuid association\n"
63          "usage: del_uuid <uuid>"},
64         {"add_route", jt_ptl_add_route, 0,
65          "add an entry to the routing table\n"
66          "usage: add_route <gateway> <target> [target]"},
67         {"del_route", jt_ptl_del_route, 0,
68          "delete an entry from the routing table\n"
69          "usage: del_route <target>"},
70         {"route_list", jt_ptl_print_routes, 0, "print the routing table\n"
71          "usage: route_list"},
72         {"recv_mem", jt_ptl_rxmem, 0, "set socket receive buffer size, "
73          "if size is omited the current size is reported.\n"
74          "usage: recv_mem [size]"},
75         {"send_mem", jt_ptl_txmem, 0, "set socket send buffer size, "
76          "if size is omited the current size is reported.\n"
77          "usage: send_mem [size]"},
78         {"nagle", jt_ptl_nagle, 0, "enable/disable nagle, omiting the "
79          "argument will cause the current nagle setting to be reported.\n" 
80          "usage: nagle [on/off]"},       
81                 
82         /* Device selection commands */
83         {"=== device selection ===", jt_noop, 0, "device selection"},
84         {"newdev", jt_obd_newdev, 0, "create a new device\n"
85          "usage: newdev"},
86 #if 0
87         {"uuid2dev", jt_obd_uuid2dev, 0,
88          "find a uuid and make it the current device\n"
89          "usage: uuid2dev <uuid>"},
90 #endif
91         {"name2dev", jt_obd_name2dev, 0,
92          "find a name and make it the current device\n"
93          "usage: name2dev <name>"},
94         {"device", jt_obd_device, 0, "set current device to devno\n"
95          "usage: device <devno>"},
96         {"device_list", jt_obd_list, 0, "show all devices\n"
97          "usage: device_list"},
98          
99         /* Device configuration commands */
100         {"==== device config =====", jt_noop, 0, "device config"},
101         {"attach", jt_obd_attach, 0, "name and type the device\n"
102          "usage: attach type [name [uuid]]"},
103         {"setup", jt_obd_setup, 0,
104          "type specific device configuration information\n"
105          "usage: setup <args...>"},
106         {"cleanup", jt_obd_cleanup, 0, "cleanup setup\n"
107          "usage: cleanup"},
108         {"detach", jt_obd_detach, 0, "un-name a device\n"
109          "usage: detach"},
110         {"lovconfig", jt_obd_lov_config, 0,
111          "write lov configuration to an mds device\n"
112          "usage: lovconfig lov-uuid stripe-count stripe-size offset pattern UUID1 [UUID2 ...]"},
113
114         /* Device operations */
115         {"=== device operations ==", jt_noop, 0, "device operations"},
116         {"probe", jt_obd_connect, 0,
117          "build a connection handle to a device.  This command is used too "
118          "suspend configuration until lctl has ensured that the mds and osc "
119          "services are available.  This is to avoid mount failures in a "
120          "rebooting cluster.\n"
121          "usage: probe [<timeout]"},
122         {"close", jt_obd_disconnect, 0, "close the connection handle\n"
123          "usage: close"},
124         {"getattr", jt_obd_getattr, 0, "get attribute for id\n"
125          "usage: getattr <id>"},
126         {"setattr", jt_obd_setattr, 0, "set attribute for id\n"
127          "usage: setattr <id> <mode>"},
128         {"test_getattr", jt_obd_test_getattr, 0,
129          "perform count number of getattr's\n"
130          "usage: test_getattr <count> [verbose]"},
131         {"test_brw", jt_obd_test_brw, 0,
132          "perform count number of bulk read/writes\n"
133          "usage: test_brw <count> [write [verbose [pages [obdos]]]]"},
134         {"test_ldlm", jt_obd_test_ldlm, 0, "perform lock manager test\n"
135          "usage: test_ldlm"},
136         {"ldlm_regress_start", jt_obd_ldlm_regress_start, 0,
137          "start lock manager stress test (usage: ldlm_regress_start "
138          "[numthreads])\n"},
139         {"ldlm_regress_stop", jt_obd_ldlm_regress_stop, 0,
140          "stop lock manager stress test (no args)\n"},
141         {"dump_ldlm", jt_obd_dump_ldlm, 0,
142          "dump all lock manager state (no args)"},
143
144 #if 0
145         {"create", jt_create, 0, "create [count [mode [verbose]]]"},
146         {"destroy", jt_destroy, 0, "destroy <id>"},
147         {"newconn", jt_newconn, 0, "newconn [newuuid]"},
148 #endif
149         /* Debug commands */
150         {"======== debug =========", jt_noop, 0, "debug"},
151         {"debug_kernel", jt_dbg_debug_kernel, 0,
152          "get debug buffer and dump to a file"
153          "usage: debug_kernel [file] [raw]"},
154         {"debug_file", jt_dbg_debug_file, 0,
155          "read debug buffer from input and dump to output"
156          "usage: debug_file <input> [output] [raw]"},
157         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
158          "usage: clear"},
159         {"mark", jt_dbg_mark_debug_buf, 0,"insert marker text in kernel debug buffer\n"
160          "usage: mark <text>"},
161         {"filter", jt_dbg_filter, 0, "filter message type\n"
162          "usage: filter <subsystem id/debug mask>"},
163         {"show", jt_dbg_show, 0, "show message type\n"
164          "usage: show <subsystem id/debug mask>"},
165         {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
166          "usage: debug_list <subs/types>"},
167         {"modules", jt_dbg_modules, 0,
168          "provide gdb-friendly module information\n"
169          "usage: modules <path>"},
170         {"panic", jt_dbg_panic, 0, "force the kernel to panic\n"
171          "usage: panic"},
172          
173         /* User interface commands */
174         {"======= control ========", jt_noop, 0, "control commands"},
175         {"help", Parser_help, 0, "help"},
176         {"exit", jt_quit, 0, "quit"},
177         {"quit", jt_quit, 0, "quit"},
178         { 0, 0, 0, NULL }
179 };
180
181
182
183 int main(int argc, char **argv) 
184 {
185         int rc;
186
187         setlinebuf(stdout);
188
189         ptl_initialize(argc, argv);
190         if (obd_initialize(argc, argv) < 0)
191                 exit(2);
192         if (dbg_initialize(argc, argv) < 0)
193                 exit(3);
194         
195         if (argc > 1) {
196                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
197         } else {
198                 Parser_init("lctl > ", cmdlist);
199                 rc = Parser_commands();
200         }
201
202         obd_cleanup(argc, argv);
203         return rc;
204 }
205