Whamcloud - gitweb
LU-7768 fld: Do not retry fld request
[fs/lustre-release.git] / lustre / utils / lctl.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2012, 2014, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/utils/lctl.c
37  *
38  * Author: Peter J. Braam <braam@clusterfs.com>
39  * Author: Phil Schwan <phil@clusterfs.com>
40  * Author: Robert Read <rread@clusterfs.com>
41  */
42
43 #include <errno.h>
44 #include <limits.h>
45 #include <stdlib.h>
46 #include <stdio.h>
47 #include <string.h>
48 #include <libcfs/util/parser.h>
49 #include <lnet/lnetctl.h>
50 #include "obdctl.h"
51 #include <lustre/lustre_idl.h>
52
53 static int jt_noop(int argc, char **argv) {
54         return 0;
55 }
56
57 static int jt_opt_ignore_errors(int argc, char **argv) {
58         Parser_ignore_errors(1);
59         return 0;
60 }
61
62 command_t cmdlist[] = {
63         /* Metacommands */
64         {"===== metacommands =======", jt_noop, 0, "metacommands"},
65         {"--device", jt_opt_device, 0,
66          "run <command> after connecting to device <devno>\n"
67          "--device <devno> <command [args ...]>"},
68         {"--ignore_errors", jt_opt_ignore_errors, 0,
69          "ignore errors that occur during script processing\n"
70          "--ignore_errors"},
71         {"ignore_errors", jt_opt_ignore_errors, 0,
72          "ignore errors that occur during script processing\n"
73          "ignore_errors"},
74
75         /* User interface commands */
76         {"======== control =========", jt_noop, 0, "control commands"},
77         {"help", Parser_help, 0, "help"},
78         {"lustre_build_version", jt_get_version, 0,
79          "print the build version of lustre\n"
80          "usage: lustre_build_version"},
81         {"exit", Parser_quit, 0, "quit"},
82         {"quit", Parser_quit, 0, "quit"},
83         {"--version", Parser_version, 0,
84          "output build version of the utility and exit"},
85
86         /* Network configuration commands */
87         {"===== network config =====", jt_noop, 0, "network config"},
88         {"--net", jt_opt_net, 0, "run <command> after selecting network <net>\n"
89          "usage: --net <tcp/o2ib/...> <command>"},
90         {"network", jt_ptl_network, 0, "configure LNET"
91          "usage: network up|down"},
92         {"net", jt_ptl_network, 0, "configure LNET"
93          "usage: net up|down"},
94         {"list_nids", jt_ptl_list_nids, 0, "list local NIDs"
95          "usage: list_nids [all]"},
96         {"which_nid", jt_ptl_which_nid, 0, "choose a NID"
97          "usage: which_nid NID [NID...]"},
98         {"replace_nids", jt_replace_nids, 0,
99          "replace primary NIDs for a device\n"
100          "usage: replace_nids <device> <nid1>[,nid2,nid3]"},
101         {"interface_list", jt_ptl_print_interfaces, 0,
102          "print network interface entries\n"
103          "usage: interface_list"},
104         {"peer_list", jt_ptl_print_peers, 0, "print peer LNet NIDs\n"
105          "usage: peer_list"},
106         {"conn_list", jt_ptl_print_connections, 0,
107          "print all the remote LNet connections\n"
108          "usage: conn_list"},
109         {"route_list", jt_ptl_print_routes, 0,
110          "print the LNet routing table, same as show_route\n"
111          "usage: route_list"},
112         {"show_route", jt_ptl_print_routes, 0,
113          "print the LNet routing table, same as route_list\n"
114          "usage: show_route"},
115         {"ping", jt_ptl_ping, 0, "Check LNET connectivity\n"
116          "usage: ping nid [timeout] [pid]"},
117         {"net_drop_add", jt_ptl_drop_add, 0, "Add LNet drop rule\n"
118          "usage: net_drop_add <-s | --source NID>\n"
119          "                    <-d | --dest NID>\n"
120          "                    <<-r | --rate DROP_RATE> |\n"
121          "                     <-i | --interval SECONDS>>\n"
122          "                    [<-p | --portal> PORTAL...]\n"
123          "                    [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"},
124         {"net_drop_del", jt_ptl_drop_del, 0, "remove LNet drop rule\n"
125          "usage: net_drop_del <[-a | --all] |\n"
126          "                    <-s | --source NID>\n"
127          "                    <-d | --dest NID>>\n"},
128         {"net_drop_reset", jt_ptl_drop_reset, 0, "reset drop rule stats\n"
129          "usage: net_drop_reset"},
130         {"net_drop_list", jt_ptl_drop_list, 0, "list LNet drop rules\n"
131          "usage: net_drop_list"},
132         {"net_delay_add", jt_ptl_delay_add, 0, "Add LNet delay rule\n"
133          "usage: net_delay_add <-s | --source NID>\n"
134          "                     <-d | --dest NID>\n"
135          "                     <<-r | --rate DROP_RATE> |\n"
136          "                      <-i | --interval SECONDS>>\n"
137          "                     <-l | --latency SECONDS>\n"
138          "                     [<-p | --portal> PORTAL...]\n"
139          "                     [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"},
140         {"net_delay_del", jt_ptl_delay_del, 0, "remove LNet delay rule\n"
141          "usage: net_delay_del <[-a | --all] |\n"
142          "                     <-s | --source NID>\n"
143          "                     <-d | --dest NID>>\n"},
144         {"net_delay_reset", jt_ptl_delay_reset, 0, "reset delay rule stats\n"
145          "usage: net_delay_reset"},
146         {"net_delay_list", jt_ptl_delay_list, 0, "list LNet delay rules\n"
147          "usage: net_delay_list"},
148
149         /* Device selection commands */
150         {"==== obd device selection ====", jt_noop, 0, "device selection"},
151         {"device", jt_obd_device, 0,
152          "set current device to <name|devno>\n"
153          "usage: device <%name|$name|devno>"},
154         {"device_list", jt_obd_list, 0, "show all devices\n"
155          "usage: device_list"},
156         {"dl", jt_obd_list, 0, "show all devices\n"
157          "usage: dl [-t]"},
158
159         /* Device operations */
160         {"==== obd device operations ====", jt_noop, 0, "device operations"},
161         {"activate", jt_obd_activate, 0, "activate an import\n"},
162         {"deactivate", jt_obd_deactivate, 0, "deactivate an import. "
163          "This command should be used on failed OSC devices in an MDT LOV.\n"},
164         {"abort_recovery", jt_obd_abort_recovery, 0,
165          "abort recovery on a restarting MDT or OST device\n"},
166         {"set_timeout", jt_lcfg_set_timeout, 0,
167          "usage: conf_param obd_timeout=<secs>\n"},
168 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
169         {"conf_param", jt_lcfg_mgsparam, 0,"set a permanent config parameter.\n"
170          "This command must be run on the MGS node\n"
171          "usage: conf_param [-d] <target.keyword=val>\n"
172          "  -d  Remove the permanent setting."},
173 #endif
174         {"local_param", jt_lcfg_param, 0, "set a temporary, local param\n"
175          "usage: local_param <target.keyword=val>\n"},
176         {"get_param", jt_lcfg_getparam, 0, "get the Lustre or LNET parameter\n"
177          "usage: get_param [-F|n|-N|-R] <param_path1 param_path2 ...>\n"
178          "Get the value of Lustre or LNET parameter from the specified path.\n"
179          "The path can contain shell-style filename patterns.\n"
180          "  -F  When -N specified, add '/', '@' or '=' for directories,\n"
181          "      symlinks and writeable files, respectively.\n"
182          "  -n  Print only the value and not parameter name.\n"
183          "  -N  Print only matched parameter names and not the values.\n"
184          "      (Especially useful when using patterns.)\n"
185          "  -R  Get parameters recursively from the specified entry.\n"},
186         {"set_param", jt_lcfg_setparam, 0, "set the Lustre or LNET parameter\n"
187          "usage: set_param [-n] [-P] [-d]"
188          "<param_path1=value1 param_path2=value2 ...>\n"
189          "Set the value of the Lustre or LNET parameter at the specified path.\n"
190          "  -n  Disable printing of the key name when printing values.\n"
191          "  -P  Set the parameter permanently, filesystem-wide.\n"
192          "  -d  Remove the permanent setting (only with -P option).\n"},
193         {"list_param", jt_lcfg_listparam, 0,
194          "list the Lustre or LNET parameter name\n"
195          "usage: list_param [-F|-R|-D] <param_path1 param_path2 ...>\n"
196          "List the name of Lustre or LNET parameter from the specified path.\n"
197          "  -F  Add '/', '@' or '=' for dirs, symlinks and writeable files,\n"
198                 "respectively.\n"
199          "  -D  Only list directories.\n"
200          "  -R  Recursively list all parameters under the specified path.\n"},
201
202         /* Debug commands */
203         {"==== debugging control ====", jt_noop, 0, "debug"},
204         {"debug_daemon", jt_dbg_debug_daemon, 0,
205          "debug daemon control and dump to a file\n"
206          "usage: debug_daemon {start file [#MB]|stop}"},
207         {"debug_kernel", jt_dbg_debug_kernel, 0,
208          "get debug buffer and dump to a file, same as dk\n"
209          "usage: debug_kernel [file] [raw]"},
210         {"dk", jt_dbg_debug_kernel, 0,
211          "get debug buffer and dump to a file, same as debug_kernel\n"
212          "usage: dk [file] [raw]"},
213         {"debug_file", jt_dbg_debug_file, 0,
214          "convert a binary debug file dumped by the kernel to ASCII text\n"
215          "usage: debug_file <input> [output]"},
216         {"df", jt_dbg_debug_file, 0,
217          "read debug buffer from input and dump to output, same as debug_file\n"
218          "usage: df <input> [output]"},
219         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
220          "usage: clear"},
221         {"mark", jt_dbg_mark_debug_buf, 0,
222          "insert marker text in kernel debug buffer\n"
223          "usage: mark <text>"},
224         {"filter", jt_dbg_filter, 0, "filter message type\n"
225          "usage: filter <subsystem id/debug mask>"},
226         {"show", jt_dbg_show, 0, "Show specific type of messages\n"
227          "usage: show <subsystem id/debug mask>"},
228         {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
229          "usage: debug_list <subs/types>"},
230         {"modules", jt_dbg_modules, 0,
231          "provide gdb-friendly module information\n"
232          "usage: modules <path>"},
233
234         /* virtual block operations */
235         {"==== virtual block device ====", jt_noop, 0, "virtual block device"},
236         {"blockdev_attach", jt_blockdev_attach, 0,
237          "attach a lustre regular file to a virtual block device\n"
238          "usage: blockdev_attach <file_name> <device_name>"},
239         {"blockdev_detach", jt_blockdev_detach, 0,
240          "detach a lustre regular file from a virtual block device\n"
241          "usage: blockdev_detach <device_name>"},
242         {"blockdev_info", jt_blockdev_info, 0,
243          "get the device info of an attached file\n"
244          "usage: blockdev_info <device_name>"},
245
246         /* Pool commands */
247         {"===  Pools ==", jt_noop, 0, "pool management"},
248         {"pool_new", jt_pool_cmd, 0,
249          "add a new pool\n"
250          "usage: pool_new <fsname>.<poolname>"},
251         {"pool_add", jt_pool_cmd, 0,
252          "add the named OSTs to the pool\n"
253          "usage: pool_add <fsname>.<poolname> <ostname indexed list>"},
254         {"pool_remove", jt_pool_cmd, 0,
255          "remove the named OST from the pool\n"
256          "usage: pool_remove <fsname>.<poolname> <ostname indexed list>"},
257         {"pool_destroy", jt_pool_cmd, 0,
258          "destroy a pool\n"
259          "usage: pool_destroy <fsname>.<poolname>"},
260         {"pool_list", jt_pool_cmd, 0,
261          "list pools and pools members\n"
262          "usage: pool_list  <fsname>[.<poolname>] | <pathname>"},
263
264         /* Nodemap commands */
265         {"=== Nodemap ===", jt_noop, 0, "nodemap management"},
266         {"nodemap_activate", jt_nodemap_activate, 0,
267          "activate nodemap idmapping functions\n"
268          "usage: nodemap_activate"},
269         {"nodemap_add", jt_nodemap_add, 0,
270          "add a new nodemap\n"
271          "usage: nodemap_add <nodemap_name>"},
272         {"nodemap_del", jt_nodemap_del, 0,
273          "remove a nodemap\n"
274          "usage: nodemap_del <nodemap_name>"},
275         {"nodemap_add_range", jt_nodemap_add_range, 0,
276          "add a range to a nodemap\n"
277          "usage: nodemap_add_range <nid_range>"},
278         {"nodemap_del_range", jt_nodemap_del_range, 0,
279          "add a range to a nodemap\n"
280          "usage: nodemap_del_range <nid_range>"},
281         {"nodemap_modify", jt_nodemap_modify, 0,
282          "modify a nodemap parameters"
283          "usage: nodemap_modify nodemap_name param value"},
284         {"nodemap_add_idmap", jt_nodemap_add_idmap, 0,
285          "add a UID or GID mapping to a nodemap"},
286         {"nodemap_del_idmap", jt_nodemap_del_idmap, 0,
287          "delete a UID or GID mapping from a nodemap"},
288         {"nodemap_test_nid", jt_nodemap_test_nid, 0,
289          "usage: nodemap_test_nid <nid>"},
290         {"nodemap_test_id", jt_nodemap_test_id, 0,
291          "Usage: nodemap_test_id --nid <nid> --idtype [uid|gid] --id <id>"},
292         {"nodemap_info", jt_nodemap_info, 0,
293          "Usage: nodemap_info [list|nodemap_name|all]"},
294
295         /* Changelog commands */
296         {"===  Changelogs ==", jt_noop, 0, "changelog user management"},
297         {"changelog_register", jt_changelog_register, 0,
298          "register a new persistent changelog user, returns id\n"
299          "usage:\tdevice <mdtname>\n\tchangelog_register [-n]"},
300         {"changelog_deregister", jt_changelog_deregister, 0,
301          "deregister an existing changelog user\n"
302          "usage:\tdevice <mdtname>\n\tchangelog_deregister <id>"},
303
304         /* Device configuration commands */
305         {"== device setup (these are not normally used post 1.4) ==",
306                 jt_noop, 0, "device config"},
307         {"attach", jt_lcfg_attach, 0,
308          "set the type, name, and uuid of the current device\n"
309          "usage: attach type name uuid"},
310         {"detach", jt_obd_detach, 0,
311          "remove driver (and name and uuid) from current device\n"
312          "usage: detach"},
313         {"setup", jt_lcfg_setup, 0,
314          "type specific device configuration information\n"
315          "usage: setup <args...>"},
316         {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
317          "usage: cleanup [force | failover]"},
318
319         /* Test only commands */
320         {"==== testing (DANGEROUS) ====", jt_noop, 0, "testing (DANGEROUS)"},
321         {"--threads", jt_opt_threads, 0,
322          "run <threads> separate instances of <command> on device <devno>\n"
323          "--threads <threads> <verbose> <devno> <command [args ...]>"},
324         {"lookup", jt_obd_mdc_lookup, 0, "report file mode info\n"
325          "usage: lookup <directory> <file>"},
326         {"readonly", jt_obd_set_readonly, 0,
327          "disable writes to the underlying device\n"},
328         {"notransno", jt_obd_no_transno, 0,
329          "disable sending of committed-transno updates\n"},
330         {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a NID\n"
331          "usage: add_uuid <uuid> <nid>"},
332         {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
333          "usage: del_uuid <uuid>"},
334         {"add_peer", jt_ptl_add_peer, 0, "add an peer entry\n"
335          "usage: add_peer <nid> <host> <port>"},
336         {"del_peer", jt_ptl_del_peer, 0, "remove an peer entry\n"
337          "usage: del_peer [<nid>] [<ipaddr|pid>]"},
338         {"add_conn ", jt_lcfg_add_conn, 0,
339          "usage: add_conn <conn_uuid> [priority]\n"},
340         {"del_conn ", jt_lcfg_del_conn, 0,
341          "usage: del_conn <conn_uuid>"},
342         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote NID\n"
343          "usage: disconnect [<nid>]"},
344         {"push", jt_ptl_push_connection, 0, "flush connection to a remote NID\n"
345          "usage: push [<nid>]"},
346         {"mynid", jt_ptl_mynid, 0, "inform the LND of the local NID. "
347          "The NID defaults to hostname for TCP networks.\n"
348          "usage: mynid [<nid>]"},
349         {"fail", jt_ptl_fail_nid, 0, "fail/restore network communications\n"
350          "Omitting the count means indefinitely, 0 means restore, "
351          "otherwise fail 'count' messages.\n"
352          "usage: fail nid|_all_ [count]"},
353
354         /*Test commands for echo client*/
355         {"test_create", jt_obd_test_create, 0,
356          "create files on MDT by echo client\n"
357          "usage: test_create [-d parent_basedir] <-D parent_count> "
358          "[-b child_base_id] <-c stripe_count> <-n count> <-t time>\n"},
359         {"test_mkdir", jt_obd_test_mkdir, 0,
360          "mkdir on MDT by echo client\n"
361          "usage: test_mkdir [-d parent_basedir] <-D parent_count>"
362          "[-b child_base_id] [-n count] <-t time>\n"},
363         {"test_destroy", jt_obd_test_destroy, 0,
364          "Destroy files on MDT by echo client\n"
365          "usage: test_destroy [-d parent_basedir] <-D parent_count>"
366          "[-b child_base_id] [-n count] <-t time>\n"},
367         {"test_rmdir", jt_obd_test_rmdir, 0,
368          "rmdir on MDT by echo client\n"
369          "usage: test_rmdir [-d parent_basedir] <-D parent_count>"
370          "[-b child_base_id] [-n count] <-t time>\n"},
371         {"test_lookup", jt_obd_test_lookup, 0,
372          "lookup files on MDT by echo client\n"
373          "usage: test_lookup [-d parent_basedir] <-D parent_count>"
374          "[-b child_base_id] [-n count] <-t time>\n"},
375         {"test_setxattr", jt_obd_test_setxattr, 0,
376          "Set EA for files/directory on MDT by echo client\n"
377          "usage: test_setxattr [-d parent_baseid] <-D parent_count>"
378          "[-b child_base_id] [-n count] <-t time>\n"},
379         {"test_md_getattr", jt_obd_test_md_getattr, 0,
380          "getattr files on MDT by echo client\n"
381          "usage: test_md_getattr [-d parent_basedir] <-D parent_count>"
382          "[-b child_base_id] [-n count] <-t time>\n"},
383         {"getattr", jt_obd_getattr, 0,
384          "get attribute for OST object <objid>\n"
385          "usage: getattr <objid>"},
386         {"setattr", jt_obd_setattr, 0,
387          "set mode attribute for OST object <objid>\n"
388          "usage: setattr <objid> <mode>"},
389         {"create", jt_obd_create, 0,
390          "create <num> OST objects (with <mode>)\n"
391          "usage: create [num [mode [verbose [lsm data]]]]"},
392         {"destroy", jt_obd_destroy, 0,
393          "destroy OST object <objid> [num [verbose]]\n"
394          "usage: destroy <num> objects, starting at objid <objid>"},
395         {"test_getattr", jt_obd_test_getattr, 0,
396          "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
397          "usage: test_getattr <num> [verbose [[t]objid]]"},
398         {"test_setattr", jt_obd_test_setattr, 0,
399          "do <num> setattrs (on OST object <objid> (objid+1 on each thread))\n"
400          "usage: test_setattr <num> [verbose [[t]objid]]"},
401         {"test_brw", jt_obd_test_brw, 0,
402          "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
403          "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
404         {"getobjversion", jt_get_obj_version, 0,
405          "get the version of an object on servers\n"
406          "usage: getobjversion <fid>\n"
407          "       getobjversion -i <id> -g <group>"},
408
409         /* LFSCK commands */
410         {"==== LFSCK ====", jt_noop, 0, "LFSCK"},
411         {"lfsck_start", jt_lfsck_start, 0, "start LFSCK\n"
412          "usage: lfsck_start <-M | --device [MDT,OST]_device>\n"
413          "                   [-A | --all] [-c | --create_ostobj [on | off]]\n"
414          "                   [-C | --create_mdtobj [on | off]]\n"
415          "                   [-e | --error {continue | abort}] [-h | --help]\n"
416          "                   [-n | --dryrun [on | off]] [-o | --orphan]\n"
417          "                   [-r | --reset] [-s | --speed speed_limit]\n"
418          "                   [-t | --type lfsck_type[,lfsck_type...]]\n"
419          "                   [-w | --window_size size]"},
420         {"lfsck_stop", jt_lfsck_stop, 0, "stop lfsck(s)\n"
421          "usage: lfsck_stop <-M | --device [MDT,OST]_device>\n"
422          "                  [-A | --all] [-h | --help]"},
423         {"lfsck_query", jt_lfsck_query, 0, "check lfsck(s) status\n"
424          "usage: lfsck_query <-M | --device MDT_device> [-h | --help]\n"
425          "                   [-t | --type lfsck_type[,lfsck_type...]]\n"
426          "                   [-w | --wait]"},
427
428         {"==== obsolete (DANGEROUS) ====", jt_noop, 0, "obsolete (DANGEROUS)"},
429         /* some test scripts still use these */
430         {"cfg_device", jt_obd_device, 0,
431          "set current device to <name>\n"
432          "usage: device <name>"},
433         {"recover", jt_obd_recover, 0,
434          "try to restore a lost connection immediately\n"
435          "usage: recover [MDC/OSC device]"},
436         /* saving for sanity 44a */
437         {"lov_getconfig", jt_obd_lov_getconfig, 0,
438          "read lov configuration from an mds device\n"
439          "usage: lov_getconfig <mountpoint>"},
440         /* Llog operations */
441         {"llog_catlist", jt_llog_catlist, 0,
442          "list all catalog logs on current device.\n"
443          "usage: llog_catlist"},
444         {"llog_info", jt_llog_info, 0,
445          "print log header information.\n"
446          "usage: llog_info <$logname|#oid#ogr#ogen>\n"
447          "       oid, ogr and ogen are hexadecimal."},
448         {"llog_print", jt_llog_print, 0,
449          "print log content information.\n"
450          "usage: llog_print <$logname|#oid#ogr#ogen> [from] [to]\n"
451          "       oid, ogr and ogen are hexadecimal.\n"
452          "       print all records from index 1 by default."},
453         {"llog_check", jt_llog_check, 0,
454          "print log content information.\n"
455          "usage: llog_check <$logname|#oid#ogr#ogen> [from] [to]\n"
456          "       oid, ogr and ogen are hexadecimal.\n"
457          "       check all records from index 1 by default."},
458          {"llog_cancel", jt_llog_cancel, 0,
459          "cancel one record in log.\n"
460          "This command supports both positional and optional arguments\n"
461          "usage (positional args): "
462          "llog_cancel <catalog id|catalog name> [log id] <index>\n"
463          "usage (optional args): "
464          "llog_cancel --catalog <catalog id|catalog name> --log_id <log_id> "
465          "--log_idx <index>"},
466         {"llog_remove", jt_llog_remove, 0,
467          "remove one log from catalog or plain log, erase it from disk.\n"
468          "usage: llog_remove <catalog id|catalog name> <log id>"},
469         /* network operations */
470         {"add_interface", jt_ptl_add_interface, 0, "add interface entry\n"
471          "usage: add_interface ip [netmask]"},
472         {"del_interface", jt_ptl_del_interface, 0, "del interface entry\n"
473          "usage: del_interface [ip]"},
474         {"add_route", jt_ptl_add_route, 0,
475          "add an entry to the LNet routing table\n"
476          "usage: add_route <gateway> [<hops> [<priority>]]"},
477         {"del_route", jt_ptl_del_route, 0,
478          "delete route via gateway to targets from the LNet routing table\n"
479          "usage: del_route <gateway> [<target>] [<target>]"},
480         {"set_route", jt_ptl_notify_router, 0,
481          "enable/disable routes via gateway in the LNet routing table\n"
482          "usage: set_route <gateway> <up/down> [<time>]"},
483
484         { 0, 0, 0, NULL }
485 };
486
487 int lctl_main(int argc, char **argv)
488 {
489         int rc;
490
491         setlinebuf(stdout);
492
493         if (ptl_initialize(argc, argv) < 0)
494                 exit(1);
495         if (obd_initialize(argc, argv) < 0)
496                 exit(2);
497         if (dbg_initialize(argc, argv) < 0)
498                 exit(3);
499
500         Parser_init("lctl > ", cmdlist);
501
502         if (argc > 1) {
503                 rc = Parser_execarg(argc - 1, argv + 1, cmdlist);
504         } else {
505                 rc = Parser_commands();
506         }
507
508         obd_finalize(argc, argv);
509         return rc < 0 ? -rc : rc;
510 }
511
512 int main(int argc, char **argv)
513 {
514         return lctl_main(argc, argv);
515 }