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