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