Whamcloud - gitweb
New tag 2.15.63
[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.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2012, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * lustre/utils/lctl.c
32  *
33  * Author: Peter J. Braam <braam@clusterfs.com>
34  * Author: Phil Schwan <phil@clusterfs.com>
35  * Author: Robert Read <rread@clusterfs.com>
36  */
37
38 #include <errno.h>
39 #include <limits.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <string.h>
43 #include <libcfs/util/parser.h>
44 #include <linux/lnet/lnetctl.h>
45 #include "obdctl.h"
46 #include <linux/lustre/lustre_ver.h>
47 #include <lustre/lustreapi.h>
48 #include "lctl_thread.h"
49
50 static int jt_pcc(int argc, char **argv);
51
52 /**
53  * command_t pccdev_cmdlist - lctl pcc commands.
54  */
55 command_t pccdev_cmdlist[] = {
56         { .pc_name = "add", .pc_func = jt_pcc_add,
57           .pc_help = "Add a PCC backend to a client.\n"
58                 "usage: lctl pcc add <mntpath> <pccpath> [--param|-p <param>]\n"
59                 "\tmntpath: Lustre mount point.\n"
60                 "\tpccpath: Path of the PCC backend.\n"
61                 "\tparam:   Setting parameters for PCC backend.\n" },
62         { .pc_name = "del", .pc_func = jt_pcc_del,
63           .pc_help = "Delete the specified PCC backend on a client.\n"
64                 "usage: clt pcc del <mntpath> <pccpath>\n" },
65         { .pc_name = "clear", .pc_func = jt_pcc_clear,
66           .pc_help = "Remove all PCC backend on a client.\n"
67                 "usage: lctl pcc clear <mntpath>\n" },
68         { .pc_name = "list", .pc_func = jt_pcc_list,
69           .pc_help = "List all PCC backends on a client.\n"
70                 "usage: lctl pcc list <mntpath>\n" },
71         { .pc_help = NULL }
72 };
73
74 command_t cmdlist[] = {
75         /* Metacommands */
76         {"===== metacommands =======", NULL, 0, "metacommands"},
77         {"--device", jt_opt_device, 0,
78          "run <command> after connecting to device <devno>\n"
79          "--device <devno> <command [args ...]>"},
80
81         /* User interface commands */
82         {"======== control =========", NULL, 0, "control commands"},
83         {"lustre_build_version", jt_get_version, 0,
84          "print version of Lustre modules\n"
85          "usage: lustre_build_version"},
86
87         /* Network configuration commands */
88         {"===== network config =====", NULL, 0, "network config"},
89         {"--net", jt_opt_net, 0, "run <command> after selecting network <net>\n"
90          "usage: --net <tcp/o2ib/...> <command>"},
91         {"network", jt_ptl_network, 0, "configure LNET\n"
92          "usage: network up|down"},
93         {"net", jt_ptl_network, 0, "configure LNET\n"
94          "usage: net up|down"},
95         {"list_nids", jt_ptl_list_nids, 0, "list local NIDs\n"
96          "usage: list_nids [all]"},
97         {"which_nid", jt_ptl_which_nid, 0, "choose a NID\n"
98          "usage: which_nid NID [NID...]"},
99         {"replace_nids", jt_replace_nids, 0,
100          "replace primary NIDs for device (clients/servers must be unmounted)\n"
101          "usage: replace_nids <DEVICE> <NID1>[,NID2,NID3:NID4,NID5:NID6]"},
102         {"interface_list", jt_ptl_print_interfaces, 0,
103          "print network interface entries\n"
104          "usage: interface_list"},
105         {"peer_list", jt_ptl_print_peers, 0, "print peer LNet NIDs\n"
106          "usage: peer_list"},
107         {"conn_list", jt_ptl_print_connections, 0,
108          "print all the remote LNet connections\n"
109          "usage: conn_list"},
110         {"route_list", jt_ptl_print_routes, 0,
111          "print the LNet routing table, same as 'show_route'\n"
112          "usage: route_list"},
113         {"show_route", jt_ptl_print_routes, 0,
114          "print the LNet routing table, same as 'route_list'\n"
115          "usage: show_route"},
116         {"ping", jt_ptl_ping, 0, "Check LNET connectivity\n"
117          "usage: ping nid [timeout [pid]]"},
118         {"net_drop_add", jt_ptl_drop_add, 0, "Add LNet drop rule\n"
119          "usage: net_drop_add <-s | --source NID>\n"
120          "                    <-d | --dest NID>\n"
121          "                    <<-r | --rate DROP_RATE> |\n"
122          "                    <-i | --interval SECONDS>>\n"
123          "                    [<-p | --portal> PORTAL...]\n"
124          "                    [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"
125          "                    [< -e | --health_error]\n"},
126         {"net_drop_del", jt_ptl_drop_del, 0, "remove LNet drop rule\n"
127          "usage: net_drop_del <[-a | --all] |\n"
128          "                    <-s | --source NID>\n"
129          "                    <-d | --dest NID>>\n"},
130         {"net_drop_reset", jt_ptl_drop_reset, 0, "reset drop rule stats\n"
131          "usage: net_drop_reset"},
132         {"net_drop_list", jt_ptl_drop_list, 0, "list LNet drop rules\n"
133          "usage: net_drop_list"},
134         {"net_delay_add", jt_ptl_delay_add, 0, "Add LNet delay rule\n"
135          "usage: net_delay_add <-s | --source NID>\n"
136          "                     <-d | --dest NID>\n"
137          "                     <<-r | --rate DROP_RATE> |\n"
138          "                      <-i | --interval SECONDS>>\n"
139          "                     <-l | --latency SECONDS>\n"
140          "                     [<-p | --portal> PORTAL...]\n"
141          "                     [<-m | --message> <PUT|ACK|GET|REPLY>...]\n"},
142         {"net_delay_del", jt_ptl_delay_del, 0, "remove LNet delay rule\n"
143          "usage: net_delay_del <[-a | --all] |\n"
144          "                     <-s | --source NID>\n"
145          "                     <-d | --dest NID>>\n"},
146         {"net_delay_reset", jt_ptl_delay_reset, 0, "reset delay rule stats\n"
147          "usage: net_delay_reset"},
148         {"net_delay_list", jt_ptl_delay_list, 0, "list LNet delay rules\n"
149          "usage: net_delay_list"},
150
151         /* Device selection commands */
152         {"==== obd device selection ====", NULL, 0, "device selection"},
153         {"device", jt_obd_device, 0,
154          "set current device to <name|devno>\n"
155          "usage: device <%name|$name|devno>"},
156         {"cfg_device", jt_obd_device, 0,
157          "set current device to <name>, same as 'device'\n"
158          "usage: cfg_device <name>"},
159         {"device_list", jt_device_list, 0, "show all devices\n"
160          "usage: device_list [--target|-t] [--yaml|-y]"},
161         {"dl", jt_device_list, 0, "show all devices, same as 'device_list'\n"
162          "usage: dl [--target|-t] [--yaml|-y]"},
163
164         /* Device operations */
165         {"==== obd device operations ====", NULL, 0, "device operations"},
166         {"activate", jt_obd_activate, 0, "activate an import\n"},
167         {"deactivate", jt_obd_deactivate, 0, "deactivate an import. "
168          "This command should be used on failed OSC devices in an MDT LOV.\n"},
169         {"abort_recovery", jt_obd_abort_recovery, 0,
170          "abort recovery on a restarting MDT or OST device\n"},
171         {"abort_recovery_mdt", jt_obd_abort_recovery_mdt, 0,
172          "abort recovery between MDTs\n"},
173         {"recover", jt_obd_recover, 0,
174          "try to restore a lost connection immediately\n"
175          "usage: recover [MDC/OSC device]"},
176         {"set_timeout", jt_lcfg_set_timeout, 0,
177          "usage: conf_param obd_timeout=<secs>\n"},
178 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
179         {"conf_param", jt_lcfg_confparam, 0,
180          "set a permanent config parameter.\n"
181          "This command must be run on the MGS node\n"
182          "usage: conf_param [-d] <target.keyword=val>\n"
183          "  -d  Delete the permanent setting from the configuration."},
184 #endif
185         {"local_param", jt_lcfg_param, 0, "set a temporary, local param\n"
186          "usage: local_param <target.keyword=val>\n"},
187         {"get_param", jt_lcfg_getparam, 0, "get the Lustre or LNET parameter\n"
188          "usage: get_param [-F|n|-N|-R] <param_path1 param_path2 ...>\n"
189          "Get the value of Lustre or LNET parameter from the specified path.\n"
190          "The path can contain shell-style filename patterns.\n"
191          "  -F  When -N specified, add '/', '@' or '=' for directories,\n"
192          "      symlinks and writeable files, respectively.\n"
193          "  -H  Prefix each output line with the parameter name.\n"
194          "  -n  Print only the value and not parameter name.\n"
195          "  -N  Print only matched parameter names and not the values.\n"
196          "      (Especially useful when using patterns.)\n"
197          "  -R  Get parameters recursively from the specified entry.\n"},
198         {"set_param", jt_lcfg_setparam, 0, "set the Lustre or LNET parameter\n"
199          "usage: set_param [-n] [-P] [-d] [-F] "
200 #ifdef HAVE_LIBPTHREAD
201          "[-t[THREAD_COUNT]] "
202 #endif
203          "PARAM1=VALUE1 [PARAM2=VALUE2 ...]\n"
204          "Set the value of the Lustre or LNET parameter at the specified path.\n"
205          "  -n  Disable printing of the key name when printing values.\n"
206          "  -P  Set the parameter permanently, filesystem-wide.\n"
207          "  -d  Remove the permanent setting (only with -P option).\n"
208          "  -F  Read permanent configuration from a YAML file.\n"
209 #ifdef HAVE_LIBPTHREAD
210          "  -t  Set parameters in parallel, max THREAD_COUNT threads\n"
211          "    (default " STRINGIFY(LCFG_THREADS_DEF) ").\n"
212 #endif
213         },
214         {"apply_yaml", jt_lcfg_applyyaml, 0, "set/config the Lustre or LNET "
215          "parameters using configuration from a YAML file.\n"
216          "usage: apply_yaml file\n"},
217         {"list_param", jt_lcfg_listparam, 0,
218          "list the Lustre or LNET parameter name\n"
219          "usage: list_param [-F|-R|-D] <param_path1 param_path2 ...>\n"
220          "List the name of Lustre or LNET parameter from the specified path.\n"
221          "  -F  Add '/', '@' or '=' for dirs, symlinks and writeable files,\n"
222                 "respectively.\n"
223          "  -D  Only list directories.\n"
224          "  -R  Recursively list all parameters under the specified path.\n"},
225         {"del_ost", jt_del_ost, 0, "permanently delete OST records\n"
226          "usage: del_ost [--dryrun] --target <$fsname-OSTxxxx>\n"
227          "Cancel the config records for a specific OST to forget about it.\n"},
228
229         /* Debug commands */
230         {"==== debugging control ====", NULL, 0, "debug"},
231         {"debug_daemon", jt_dbg_debug_daemon, 0,
232          "debug daemon control and dump to a file\n"
233          "usage: debug_daemon {start file [#MB]|stop}"},
234         {"debug_kernel", jt_dbg_debug_kernel, 0,
235          "get debug buffer and dump to a file, same as 'dk'\n"
236          "usage: debug_kernel [file] [raw]"},
237         {"dk", jt_dbg_debug_kernel, 0,
238          "get debug buffer and dump to a file, same as 'debug_kernel'\n"
239          "usage: dk [file] [raw]"},
240         {"debug_file", jt_dbg_debug_file, 0,
241          "convert a binary debug file dumped by the kernel to ASCII text\n"
242          "usage: debug_file <input> [output]"},
243         {"df", jt_dbg_debug_file, 0,
244          "read debug log from input convert to ASCII, same as 'debug_file'\n"
245          "usage: df <input> [output]"},
246         {"clear", jt_dbg_clear_debug_buf, 0, "clear kernel debug buffer\n"
247          "usage: clear"},
248         {"mark", jt_dbg_mark_debug_buf, 0,
249          "insert marker text in kernel debug buffer\n"
250          "usage: mark <text>"},
251         {"filter", jt_dbg_filter, 0, "filter message type\n"
252          "usage: filter <subsystem id/debug mask>"},
253         {"show", jt_dbg_show, 0, "Show specific type of messages\n"
254          "usage: show <subsystem id/debug mask>"},
255         {"debug_list", jt_dbg_list, 0, "list subsystem and debug types\n"
256          "usage: debug_list <subs/types>"},
257         {"modules", jt_dbg_modules, 0,
258          "provide gdb-friendly module information\n"
259          "usage: modules <path>"},
260
261         /* Pool commands */
262         {"===  Pools ==", NULL, 0, "pool management"},
263         {"pool_new", jt_pool_cmd, 0,
264          "add a new pool\n"
265          "usage: pool_new [-n|--nowait] <fsname>.<poolname>"},
266         {"pool_add", jt_pool_cmd, 0,
267          "add the named OSTs to the pool\n"
268          "usage: pool_add [-n|--nowait] <fsname>.<poolname> <ostname indexed list>"},
269         {"pool_remove", jt_pool_cmd, 0,
270          "remove the named OST from the pool\n"
271          "usage: pool_remove [-n|--nowait] <fsname>.<poolname> <ostname indexed list>"},
272         {"pool_destroy", jt_pool_cmd, 0,
273          "destroy a pool\n"
274          "usage: pool_destroy [-n|--nowait] <fsname>.<poolname>"},
275         {"pool_list", jt_pool_cmd, 0,
276          "list pools and pools members\n"
277          "usage: pool_list  <fsname>[.<poolname>] | <pathname>"},
278
279 #ifdef HAVE_SERVER_SUPPORT
280         /* Barrier commands */
281         {"===  Barrier ==", NULL, 0, "barrier management"},
282         {"barrier_freeze", jt_barrier_freeze, 0,
283          "freeze write barrier on MDTs\n"
284          "usage: barrier_freeze <fsname> [timeout (in seconds)]"},
285         {"barrier_thaw", jt_barrier_thaw, 0,
286          "thaw write barrier on MDTs\n"
287          "usage: barrier_thaw <fsname>"},
288         {"barrier_stat", jt_barrier_stat, 0,
289          "query write barrier status on MDTs\n"
290          "usage: barrier_stat [--state|-s] [--timeout|-t] <fsname>"},
291         {"barrier_rescan", jt_barrier_rescan, 0,
292          "rescan the system to filter out inactive MDT(s) for barrier\n"
293          "usage: barrier_rescan <fsname> [timeout (in seconds)]"},
294
295         /* Snapshot commands */
296         {"===  Snapshot ==", NULL, 0, "Snapshot management"},
297         {"snapshot_create", jt_snapshot_create, 0,
298          "create the snapshot\n"
299          "usage: snapshot_create [-b | --barrier [on | off]]\n"
300          "                       [-c | --comment comment]\n"
301          "                       <-F | --fsname fsname>\n"
302          "                       [-h | --help] <-n | --name ssname>\n"
303          "                       [-r | --rsh remote_shell]\n"
304          "                       [-t | --timeout timeout]"},
305         {"snapshot_destroy", jt_snapshot_destroy, 0,
306          "destroy the snapshot\n"
307          "usage: snapshot_destroy [-f | --force]\n"
308          "                        <-F | --fsname fsname> [-h | --help]\n"
309          "                        <-n | --name ssname>\n"
310          "                        [-r | --rsh remote_shell]"},
311         {"snapshot_modify", jt_snapshot_modify, 0,
312          "modify the snapshot\n"
313          "usage: snapshot_modify [-c | --comment comment]\n"
314          "                       <-F | --fsname fsname> [-h | --help]\n"
315          "                       <-n | --name ssname> [-N | --new new_ssname]\n"
316          "                       [-r | --rsh remote_shell]"},
317         {"snapshot_list", jt_snapshot_list, 0,
318          "query the snapshot(s)\n"
319          "usage: snapshot_list [-d | --detail]\n"
320          "                     <-F | --fsname fsname> [-h | --help]\n"
321          "                     [-n | --name ssname] [-r | --rsh remote_shell]"},
322         {"snapshot_mount", jt_snapshot_mount, 0,
323          "mount the snapshot\n"
324          "usage: snapshot_mount <-F | --fsname fsname> [-h | --help]\n"
325          "                      <-n | --name ssname>\n"
326          "                      [-r | --rsh remote_shell]"},
327         {"snapshot_umount", jt_snapshot_umount, 0,
328          "umount the snapshot\n"
329          "usage: snapshot_umount <-F | --fsname fsname> [-h | --help]\n"
330          "                       <-n | --name ssname>\n"
331          "                       [-r | --rsh remote_shell]"},
332 #endif /* HAVE_SERVER_SUPPORT */
333         /* Nodemap commands */
334         {"=== Nodemap ===", NULL, 0, "nodemap management"},
335         {"nodemap_activate", jt_nodemap_activate, 0,
336          "activate nodemap idmapping functions\n"
337          "usage: nodemap_activate {0|1}"},
338         {"nodemap_add", jt_nodemap_add, 0,
339          "add a new nodemap\n"
340          "usage: nodemap_add <nodemap_name>"},
341         {"nodemap_del", jt_nodemap_del, 0,
342          "remove a nodemap\n"
343          "usage: nodemap_del <nodemap_name>"},
344         {"nodemap_add_range", jt_nodemap_add_range, 0,
345          "add a range to a nodemap\n"
346          "usage: nodemap_add_range <nid_range>"},
347         {"nodemap_del_range", jt_nodemap_del_range, 0,
348          "add a range to a nodemap\n"
349          "usage: nodemap_del_range <nid_range>"},
350         {"nodemap_modify", jt_nodemap_modify, 0,
351          "modify a nodemap parameters\n"
352          "usage: nodemap_modify nodemap_name param value"},
353         {"nodemap_add_idmap", jt_nodemap_add_idmap, 0,
354          "add a UID or GID mapping to a nodemap"},
355         {"nodemap_del_idmap", jt_nodemap_del_idmap, 0,
356          "delete a UID or GID mapping from a nodemap"},
357         {"nodemap_set_fileset", jt_nodemap_set_fileset, 0,
358          "set a fileset on a nodemap\n"
359          "usage: nodemap_set_fileset <fileset>"},
360         {"nodemap_set_sepol", jt_nodemap_set_sepol, 0,
361          "set SELinux policy info on a nodemap\n"
362          "usage: nodemap_set_sepol <SELinux policy info>"},
363         {"nodemap_test_nid", jt_nodemap_test_nid, 0,
364          "usage: nodemap_test_nid <nid>"},
365         {"nodemap_test_id", jt_nodemap_test_id, 0,
366          "Usage: nodemap_test_id --nid <nid> --idtype [uid|gid] --id <id>"},
367         {"nodemap_info", jt_nodemap_info, 0,
368          "Usage: nodemap_info [list|nodemap_name|all]"},
369
370         /* Changelog commands */
371         {"===  Changelogs ==", NULL, 0, "changelog user management"},
372         {"changelog_register", jt_changelog_register, 0,
373          "register a new persistent changelog user, returns id\n"
374          "usage: --device <mdtname> changelog_register [--help|-h]\n"
375          "                                             [--mask|-m <[+|-]mask1[<,|+|->mask2...]>]\n"
376          "                                             [--nameonly|-n]\n"
377          "                                             [--user|-u <username>]"},
378         {"changelog_deregister", jt_changelog_deregister, 0,
379          "deregister an existing changelog user\n"
380          "usage: --device <mdtname> changelog_deregister [<id>|cl<id>...]\n"
381          "                                               [--help|-h]\n"
382          "                                               [--user|-u <username>]\n"},
383
384         /* Persistent Client Cache (PCC) commands */
385         {"=== Persistent Client Cache ===", NULL, 0, "PCC user management"},
386         {"pcc", jt_pcc, pccdev_cmdlist,
387          "lctl commands used to interact with PCC features:\n"
388          "lctl pcc add    - add a PCC backend to a client\n"
389          "lctl pcc del    - delete a PCC backend on a client\n"
390          "lctl pcc clear  - remove all PCC backends on a client\n"
391          "lctl pcc list   - list all PCC backends on a client\n"},
392
393         /* Device configuration commands */
394         {"== device setup (these are not normally used post 1.4) ==",
395                 NULL, 0, "device config"},
396         {"attach", jt_lcfg_attach, 0,
397          "set the type, name, and uuid of the current device\n"
398          "usage: attach type name uuid"},
399         {"detach", jt_obd_detach, 0,
400          "remove driver (and name and uuid) from current device\n"
401          "usage: detach"},
402         {"setup", jt_lcfg_setup, 0,
403          "type specific device configuration information\n"
404          "usage: setup <args...>"},
405         {"cleanup", jt_obd_cleanup, 0, "cleanup previously setup device\n"
406          "usage: cleanup [force | failover]"},
407
408 #ifdef HAVE_SERVER_SUPPORT
409         /* LFSCK commands */
410         {"==== LFSCK ====", NULL, 0, "LFSCK"},
411         {"lfsck_start", jt_lfsck_start, 0, "start LFSCK\n"
412          "usage: lfsck_start [--device|-M [MDT,OST]_device]\n"
413          "                   [--all|-A] [--create-ostobj|-c [on | off]]\n"
414          "                   [--create-mdtobj|-C [on | off]]\n"
415          "                   [--delay-create-ostobj|-d [on | off]]\n"
416          "                   [--error|-e {continue | abort}] [--help|-h]\n"
417          "                   [--dryrun|-n [on | off]] [--orphan|-o]\n"
418          "                   [--reset|-r] [--speed|-s speed_limit]\n"
419          "                   [--type|-t lfsck_type[,lfsck_type...]]\n"
420          "                   [--window-size|-w size]"},
421         {"lfsck_stop", jt_lfsck_stop, 0, "stop lfsck(s)\n"
422          "usage: lfsck_stop [--device|-M [MDT,OST]_device]\n"
423          "                  [--all|-A] [--help|-h]"},
424         {"lfsck_query", jt_lfsck_query, 0, "check lfsck(s) status\n"
425          "usage: lfsck_query [--device|-M MDT_device] [--help|-h]\n"
426          "                   [--type|-t lfsck_type[,lfsck_type...]]\n"
427          "                   [--wait|-w]"},
428
429         /* Llog operations */
430         {"==== LLOG ====", NULL, 0, "LLOG"},
431         {"llog_catlist", jt_llog_catlist, 0,
432          "list all catalog files on current device. If current device is not\n"
433          "set, MGS device is used by default.\n"
434          "usage: llog_catlist"},
435         {"llog_info", jt_llog_info, 0,
436          "print log header information.\n"
437          "usage: llog_info {LOGNAME|FID}\n"},
438         {"llog_print", jt_llog_print, 0,
439          "print all effective log records by default, or within given range.\n"
440          "With --raw option skipped records are printed as well.\n"
441          "usage: llog_print {LOGNAME|FID} [--start INDEX] [--end INDEX]\n"
442          "                  [--raw]\n"},
443         {"llog_cancel", jt_llog_cancel, 0,
444          "cancel one record in specified log.\n"
445          "usage:llog_cancel {LOGNAME|FID} --log_idx INDEX\n"},
446         {"llog_check", jt_llog_check, 0,
447          "verify that log content is valid.\n"
448          "usage: llog_check {LOGNAME|FID} [--start INDEX] [--end INDEX]\n"
449          "       check all records from index 1 by default."},
450         {"llog_remove", jt_llog_remove, 0,
451          "remove one log from catalog or plain log, erase it from disk.\n"
452          "usage: llog_remove {LOGNAME|FID} [--log_id ID]"},
453         {"lcfg_clear", jt_lcfg_clear, 0,
454          "drop unused config llog records for a device or filesystem.\n"
455          "clients and servers must be unmounted during this operation.\n"
456          "usage: clear_conf {FSNAME|DEVNAME}"},
457         {"clear_conf", jt_lcfg_clear, 0, "alias for 'lcfg_clear'\n"},
458         {"lcfg_fork", jt_lcfg_fork, 0,
459          "copy configuration logs for named filesystem with given name\n"
460          "usage: fork_lcfg FSNAME NEWNAME"},
461         {"fork_lcfg", jt_lcfg_fork, 0, "alias for 'lcfg_fork'\n"},
462         {"lcfg_erase", jt_lcfg_erase, 0,
463          "permanently erase configuration logs for the named filesystem\n"
464          "usage: erase_lcfg FSNAME"},
465         {"erase_lcfg", jt_lcfg_erase, 0, "alias for 'lcfg_erase'\n"},
466 #endif /* HAVE_SERVER_SUPPORT */
467
468         {"==== obsolete (DANGEROUS) ====", NULL, 0, "obsolete (DANGEROUS)"},
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         /* Test only commands */
485         {"==== testing (DANGEROUS) ====", NULL, 0, "testing (DANGEROUS)"},
486         {"--threads", jt_opt_threads, 0,
487          "run <threads> separate instances of <command> on device <devno>\n"
488          "--threads <threads> <verbose> <devno> <command [args ...]>"},
489         {"lookup", jt_obd_mdc_lookup, 0, "report file mode info\n"
490          "usage: lookup <directory> <file>"},
491         {"readonly", jt_obd_set_readonly, 0,
492          "disable writes to the underlying device\n"},
493 #ifdef HAVE_SERVER_SUPPORT
494         {"notransno", jt_obd_no_transno, 0,
495          "disable sending of committed-transno updates\n"},
496 #endif
497         {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a NID\n"
498          "usage: add_uuid <uuid> <nid>"},
499         {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
500          "usage: del_uuid <uuid>"},
501         {"add_peer", jt_ptl_add_peer, 0, "add an peer entry\n"
502          "usage: add_peer <nid> <host> <port>"},
503         {"del_peer", jt_ptl_del_peer, 0, "remove an peer entry\n"
504          "usage: del_peer [<nid>] [<ipaddr|pid>]"},
505         {"add_conn ", jt_lcfg_add_conn, 0,
506          "usage: add_conn <conn_uuid> [priority]\n"},
507         {"del_conn ", jt_lcfg_del_conn, 0,
508          "usage: del_conn <conn_uuid>"},
509         {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote NID\n"
510          "usage: disconnect [<nid>]"},
511         {"push", jt_ptl_push_connection, 0, "flush connection to a remote NID\n"
512          "usage: push [<nid>]"},
513         {"mynid", jt_ptl_mynid, 0, "inform the LND of the local NID. "
514          "The NID defaults to hostname for TCP networks.\n"
515          "usage: mynid [<nid>]"},
516         {"fail", jt_ptl_fail_nid, 0, "fail/restore network communications\n"
517          "Omitting the count means indefinitely, 0 means restore, "
518          "otherwise fail 'count' messages.\n"
519          "usage: fail nid|_all_ [count]"},
520
521         /* Test commands for echo client */
522         {"test_create", jt_obd_test_create, 0,
523          "create files on MDT by echo client\n"
524          "usage: test_create [-d parent_basedir] <-D parent_count> "
525          "[-b child_base_id] <-c stripe_count> <-n count> <-t time>\n"},
526         {"test_mkdir", jt_obd_test_mkdir, 0,
527          "mkdir on MDT by echo client\n"
528          "usage: test_mkdir [-d parent_basedir] <-D parent_count>"
529          "[-b child_base_id] [-n count] <-t time>\n"},
530         {"test_destroy", jt_obd_test_destroy, 0,
531          "Destroy files on MDT by echo client\n"
532          "usage: test_destroy [-d parent_basedir] <-D parent_count>"
533          "[-b child_base_id] [-n count] <-t time>\n"},
534         {"test_rmdir", jt_obd_test_rmdir, 0,
535          "rmdir on MDT by echo client\n"
536          "usage: test_rmdir [-d parent_basedir] <-D parent_count>"
537          "[-b child_base_id] [-n count] <-t time>\n"},
538         {"test_lookup", jt_obd_test_lookup, 0,
539          "lookup files on MDT by echo client\n"
540          "usage: test_lookup [-d parent_basedir] <-D parent_count>"
541          "[-b child_base_id] [-n count] <-t time>\n"},
542         {"test_setxattr", jt_obd_test_setxattr, 0,
543          "Set EA for files/directory on MDT by echo client\n"
544          "usage: test_setxattr [-d parent_baseid] <-D parent_count>"
545          "[-b child_base_id] [-n count] <-t time>\n"},
546         {"test_md_getattr", jt_obd_test_md_getattr, 0,
547          "getattr files on MDT by echo client\n"
548          "usage: test_md_getattr [-d parent_basedir] <-D parent_count>"
549          "[-b child_base_id] [-n count] <-t time>\n"},
550         {"getattr", jt_obd_getattr, 0,
551          "get attribute for OST object <objid>\n"
552          "usage: getattr <objid>"},
553         {"setattr", jt_obd_setattr, 0,
554          "set mode attribute for OST object <objid>\n"
555          "usage: setattr <objid> <mode>"},
556         {"create", jt_obd_create, 0,
557          "create <num> OST objects (with <mode>)\n"
558          "usage: create [num [mode [verbose [lsm data]]]]"},
559         {"destroy", jt_obd_destroy, 0,
560          "destroy OST object <objid> [num [verbose]]\n"
561          "usage: destroy <num> objects, starting at objid <objid>"},
562         {"test_getattr", jt_obd_test_getattr, 0,
563          "do <num> getattrs (on OST object <objid> (objid+1 on each thread))\n"
564          "usage: test_getattr <num> [verbose [[t]objid]]"},
565         {"test_setattr", jt_obd_test_setattr, 0,
566          "do <num> setattrs (on OST object <objid> (objid+1 on each thread))\n"
567          "usage: test_setattr <num> [verbose [[t]objid]]"},
568         {"test_brw", jt_obd_test_brw, 0,
569          "do <num> bulk read/writes (<npages> per I/O, on OST object <objid>)\n"
570          "usage: test_brw [t]<num> [write [verbose [npages [[t]objid]]]]"},
571         {"getobjversion", jt_get_obj_version, 0,
572          "get the version of an object on servers\n"
573          "usage: getobjversion <fid>\n"
574          "       getobjversion -i <id> -g <group>"},
575         { 0, 0, 0, NULL }
576 };
577
578 /**
579  * jt_pcc() - Parse and execute lctl pcc commands.
580  * @argc: The count of lctl pcc command line arguments.
581  * @argv: Array of strings for lctl pcc command line arguments.
582  *
583  * This function parses lfs pcc commands and performs the
584  * corresponding functions specified in pccdev_cmdlist[].
585  *
586  * Return: 0 on success or an error code on failure.
587  */
588 static int jt_pcc(int argc, char **argv)
589 {
590         char cmd[PATH_MAX];
591         int rc = 0;
592
593         setlinebuf(stdout);
594
595         snprintf(cmd, sizeof(cmd), "%s %s", program_invocation_short_name,
596                  argv[0]);
597         program_invocation_short_name = cmd;
598         rc = cfs_parser(argc, argv, pccdev_cmdlist);
599
600         return rc < 0 ? -rc : rc;
601 }
602
603 static int lctl_main(int argc, char **argv)
604 {
605         int rc;
606
607         setlinebuf(stdout);
608
609         if (ptl_initialize(argc, argv) < 0)
610                 exit(1);
611         if (obd_initialize(argc, argv) < 0)
612                 exit(2);
613         if (dbg_initialize(argc, argv) < 0)
614                 exit(3);
615
616         llapi_set_command_name(argv[1]);
617         rc = cfs_parser(argc, argv, cmdlist);
618         llapi_clear_command_name();
619         obd_finalize(argc, argv);
620
621         return rc < 0 ? -rc : rc;
622 }
623
624 int main(int argc, char **argv)
625 {
626         return lctl_main(argc, argv);
627 }