X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Futils%2Flctl.c;h=8ff3dcc27ce65b120078e9ea442a7e1eae1ab621;hp=5b59cce8a1fcd7a4dbaffedb5733dd6d7272548c;hb=4527a65cc1a46740c8edee7557a3cdd7ce035d87;hpb=d8b0dffb5c369fc94fccdeeb689e6405836d0cd2 diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 5b59cce..8ff3dcc 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -4,7 +4,8 @@ * Copyright (C) 2002 Cluster File Systems, Inc. * Author: Peter J. Braam * Author: Phil Schwan - * Author: Robert Read + * Author: Robert Read + * * This file is part of Lustre, http://www.lustre.org. * * Lustre is free software; you can redistribute it and/or @@ -23,41 +24,16 @@ */ -#include -#include -#include -#include + #include -#include #include +#include +#include #include -#include -#include -#define printk printf - - -#include -#include -#include - -#include -#include -#include -#include -#include #include -#include -#include /* needed for PAGE_SIZE - rread*/ - -#include "lctl.h" - -#define __KERNEL__ -#include -#undef __KERNEL__ - -int thread; - -command_t cmdlist[]; +#include +#include "obdctl.h" +#include "parser.h" static int jt_quit(int argc, char **argv) { Parser_quit(argc, argv); @@ -68,131 +44,373 @@ static int jt_noop(int argc, char **argv) { return 0; } +static int jt_opt_ignore_errors(int argc, char **argv) { + Parser_ignore_errors(1); + return 0; +} + +/* + * XXX Should not belong to here + */ +static int flush_cred_ioctl(char *mp) +{ + int fd, rc; + + fd = open(mp, O_RDONLY); + if (fd == -1) { + fprintf(stderr, "flush_cred_ioctl: error open %s: %s\n", + mp, strerror(errno)); + return -1; + } + + rc = ioctl(fd, LL_IOC_FLUSH_CRED); + if (rc == -1) { + fprintf(stderr, "flush_cred_ioctl: error ioctl %s: %s\n", + mp, strerror(errno)); + } + + close(fd); + return rc; +} + +static int jt_flush_cred(int argc, char **argv) +{ + FILE *proc; + char procline[PATH_MAX], *line; + int i, rc = 0; + + /* no args means search all lustre mountpoints */ + if (argc < 2) { + proc = fopen("/proc/mounts", "r"); + if (!proc) { + fprintf(stderr, "%s: can't open /proc/mounts\n", + jt_cmdname(argv[0])); + return -1; + } + + while ((line = fgets(procline, PATH_MAX, proc)) != NULL) { + char dev[PATH_MAX]; + char mp[PATH_MAX]; + char fs[PATH_MAX]; + + if (sscanf(line, "%s %s %s", dev, mp, fs) != 3) { + fprintf(stderr, "%s: unexpected format in " + "/proc/mounts\n", + jt_cmdname(argv[0])); + return -1; + } + + if (strcmp(fs, "lustre") && + strcmp(fs, "lustre_lite")) + continue; + + if (flush_cred_ioctl(mp)) + rc = -1; + } + } else { + /* follow the exact flush sequence as supplied */ + for (i = 1; i < argc; i++) { + if (flush_cred_ioctl(argv[i])) + rc = -1; + } + } + + return rc; +} + command_t cmdlist[] = { /* Metacommands */ - {"--device", jt_opt_device, 0, "--device "}, + {"--device", jt_opt_device, 0, + "run after connecting to device \n" + "--device "}, {"--threads", jt_opt_threads, 0, - "--threads "}, + "run separate instances of on device \n" + "--threads "}, + {"--ignore_errors", jt_opt_ignore_errors, 0, + "ignore errors that occur during script processing\n" + "--ignore_errors"}, + {"ignore_errors", jt_opt_ignore_errors, 0, + "ignore errors that occur during script processing\n" + "ignore_errors"}, + {"dump", jt_ioc_dump, 0, "usage: dump file, save ioctl buffer to file"}, /* Network configuration commands */ {"==== network config ====", jt_noop, 0, "network config"}, - {"network", jt_net_network, 0, "commands that follow apply to net\n" - "usage: network "}, - {"connect", jt_net_connect, 0, "connect to a remote nid\n" - "usage: connect [[ ] | ]"}, - {"disconnect", jt_net_disconnect, 0, "disconnect from a remote nid\n" - "usage: disconnect "}, - {"mynid", jt_net_mynid, 0, "inform the socknal of the local nid. " + {"--net", jt_opt_net, 0, "run after setting network to \n" + "usage: --net "}, + {"network", jt_ptl_network, 0, "commands that follow apply to net\n" + "usage: network "}, + {"interface_list", jt_ptl_print_interfaces, 0, "print interface entries\n" + "usage: interface_list"}, + {"add_interface", jt_ptl_add_interface, 0, "add interface entry\n" + "usage: add_interface ip [netmask]"}, + {"del_interface", jt_ptl_del_interface, 0, "del interface entry\n" + "usage: del_interface [ip]"}, + {"peer_list", jt_ptl_print_peers, 0, "print peer entries\n" + "usage: peer_list"}, + {"add_peer", jt_ptl_add_peer, 0, "add an peer entry\n" + "usage: add_peer "}, + {"del_peer", jt_ptl_del_peer, 0, "remove an peer entry\n" + "usage: del_peer [] [] [ks]"}, + {"conn_list", jt_ptl_print_connections, 0, "print all the connected remote nid\n" + "usage: conn_list"}, + {"connect", jt_ptl_connect, 0, "connect to a remote nid\n" + "usage: connect [iIOC]"}, + {"disconnect", jt_ptl_disconnect, 0, "disconnect from a remote nid\n" + "usage: disconnect []"}, + {"active_tx", jt_ptl_print_active_txs, 0, "print active transmits\n" + "usage: active_tx"}, + {"mynid", jt_ptl_mynid, 0, "inform the socknal of the local nid. " "The nid defaults to hostname for tcp networks and is automatically " "setup for elan/myrinet networks.\n" - "usage: mynid [nid]"}, - {"add_uuid", jt_net_add_uuid, 0, "associate a uuid with a nid\n" - "usage: add_uuid "}, - {"del_uuid", jt_net_del_uuid, 0, "delete a uuid association\n" + "usage: mynid []"}, + {"shownid", jt_ptl_shownid, 0, "print the local NID\n" + "usage: shownid"}, + {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n" + "usage: add_uuid "}, + {"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n" + "usage: close_uuid "}, + {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n" "usage: del_uuid "}, - {"add_route", jt_net_add_route, 0, - "add an entry to the routing table\n" - "usage: add_route [target]"}, - {"del_route", jt_net_del_route, 0, - "delete an entry from the routing table\n" - "usage: del_route "}, - {"route_list", jt_net_route_list, 0, "print the routing table\n" + {"add_route", jt_ptl_add_route, 0, + "add an entry to the portals routing table\n" + "usage: add_route []"}, + {"del_route", jt_ptl_del_route, 0, + "delete route via gateway to targets from the portals routing table\n" + "usage: del_route [] []"}, + {"set_route", jt_ptl_notify_router, 0, + "enable/disable routes via gateway in the portals routing table\n" + "usage: set_route [