*
* You should have received a copy of the GNU General Public License
* version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
*
* GPL HEADER END
*/
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2015, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#include <linux/types.h>
#include <libcfs/util/ioctl.h>
-#include <libcfs/user-time.h>
+#include <libcfs/util/param.h>
#include <libcfs/libcfs_debug.h>
#include <lnet/lnetctl.h>
static const char *libcfs_debug_subsystems[] = LIBCFS_DEBUG_SUBSYS_NAMES;
static const char *libcfs_debug_masks[] = LIBCFS_DEBUG_MASKS_NAMES;
-#define DAEMON_CTL_NAME "/proc/sys/lnet/daemon_file"
-#define SUBSYS_DEBUG_CTL_NAME "/proc/sys/lnet/subsystem_debug"
-#define DEBUG_CTL_NAME "/proc/sys/lnet/debug"
-#define DUMP_KERNEL_CTL_NAME "/proc/sys/lnet/dump_kernel"
+#define DAEMON_CTL_NAME "daemon_file"
+#define SUBSYS_DEBUG_CTL_NAME "subsystem_debug"
+#define DEBUG_CTL_NAME "debug"
+#define DUMP_KERNEL_CTL_NAME "dump_kernel"
+/*
+ * Open the parameter file "debug" which controls the debugging
+ * flags used to determine what information ends up in the lustre
+ * logs collected by lctl dk or the debug daemon.
+ */
static int
dbg_open_ctlhandle(const char *str)
{
- int fd;
- fd = open(str, O_WRONLY);
- if (fd < 0) {
- fprintf(stderr, "open %s failed: %s\n", str,
- strerror(errno));
+ glob_t path;
+ int fd, rc;
+
+ rc = cfs_get_param_paths(&path, "%s", str);
+ if (rc != 0) {
+ fprintf(stderr, "invalid parameter '%s'\n", str);
return -1;
}
+
+ fd = open(path.gl_pathv[0], O_WRONLY);
+ if (fd < 0)
+ fprintf(stderr, "open '%s' failed: %s\n",
+ path.gl_pathv[0], strerror(errno));
+
+ cfs_free_param_data(&path);
return fd;
}
return 0;
}
-static int applymask(char* procpath, int value)
+static int applymask(char *param, int value)
{
int rc;
char buf[64];
int len = snprintf(buf, 64, "%d", value);
- int fd = dbg_open_ctlhandle(procpath);
- if (fd == -1) {
- fprintf(stderr, "Unable to open %s: %s\n",
- procpath, strerror(errno));
+ int fd = dbg_open_ctlhandle(param);
+ if (fd < 0)
return fd;
- }
+
rc = dbg_write_cmd(fd, buf, len+1);
if (rc != 0) {
fprintf(stderr, "Write to %s failed: %s\n",
- procpath, strerror(errno));
+ param, strerror(errno));
}
dbg_close_ctlhandle(fd);
{
applymask(SUBSYS_DEBUG_CTL_NAME, subs_mask);
applymask(DEBUG_CTL_NAME, debug_mask);
- printf("Applied subsystem_debug=%d, debug=%d to /proc/sys/lnet\n",
+ printf("Applied subsystem_debug=%d, debug=%d to lnet\n",
subs_mask, debug_mask);
}
}
strncpy(filename, argv[1], sizeof(filename));
} else {
- if (snprintf(filename, sizeof(filename), "%s"CFS_TIME_T".%u",
+ if (snprintf(filename, sizeof(filename), "%s%lu.%u",
LIBCFS_DEBUG_FILE_PATH_DEFAULT, time(NULL),
getpid())
>= sizeof(filename)) {
static struct mod_paths {
char *name, *path;
} mod_paths[] = {
- { "libcfs", "libcfs/libcfs" },
- { "lnet", "lnet/lnet" },
- { "ko2iblnd", "lnet/klnds/o2iblnd" },
- { "kgnilnd", "lnet/klnds/gnilnd"},
- { "ksocklnd", "lnet/klnds/socklnd" },
- { "obdclass", "lustre/obdclass" },
- { "llog_test", "lustre/obdclass" },
- { "ptlrpc_gss", "lustre/ptlrpc/gss" },
- { "ptlrpc", "lustre/ptlrpc" },
- { "gks", "lustre/sec/gks" },
- { "gkc", "lustre/sec/gks" },
- { "ost", "lustre/ost" },
- { "osc", "lustre/osc" },
- { "mds", "lustre/mds" },
- { "mdc", "lustre/mdc" },
- { "lustre", "lustre/llite" },
- { "llite_lloop", "lustre/llite" },
- { "ldiskfs", "ldiskfs" },
- { "obdecho", "lustre/obdecho" },
- { "ldlm", "lustre/ldlm" },
- { "obdfilter", "lustre/obdfilter" },
- { "lov", "lustre/lov" },
- { "lmv", "lustre/lmv" },
- { "lquota", "lustre/quota" },
- { "mgs", "lustre/mgs" },
- { "mgc", "lustre/mgc" },
- { "mdt", "lustre/mdt" },
- { "mdd", "lustre/mdd" },
- { "osd", "lustre/osd" },
- { "cmm", "lustre/cmm" },
- {"fid", "lustre/fid"},
- {"fld", "lustre/fld"},
- {"lod", "lustre/lod"},
- {"osp", "lustre/osp"},
- { "lfsck", "lustre/lfsck" },
- {NULL, NULL}
+ { .name = "libcfs", .path = "libcfs/libcfs" },
+ { .name = "lnet", .path = "lnet/lnet" },
+ { .name = "ko2iblnd", .path = "lnet/klnds/o2iblnd" },
+ { .name = "kgnilnd", .path = "lnet/klnds/gnilnd"},
+ { .name = "ksocklnd", .path = "lnet/klnds/socklnd" },
+ { .name = "obdclass", .path = "lustre/obdclass" },
+ { .name = "llog_test", .path = "lustre/obdclass" },
+ { .name = "ptlrpc_gss", .path = "lustre/ptlrpc/gss" },
+ { .name = "ptlrpc", .path = "lustre/ptlrpc" },
+ { .name = "gks", .path = "lustre/sec/gks" },
+ { .name = "gkc", .path = "lustre/sec/gks" },
+ { .name = "ost", .path = "lustre/ost" },
+ { .name = "osc", .path = "lustre/osc" },
+ { .name = "mds", .path = "lustre/mds" },
+ { .name = "mdc", .path = "lustre/mdc" },
+ { .name = "lustre", .path = "lustre/llite" },
+ { .name = "ldiskfs", .path = "ldiskfs" },
+ { .name = "obdecho", .path = "lustre/obdecho" },
+ { .name = "ldlm", .path = "lustre/ldlm" },
+ { .name = "obdfilter", .path = "lustre/obdfilter" },
+ { .name = "lov", .path = "lustre/lov" },
+ { .name = "lmv", .path = "lustre/lmv" },
+ { .name = "lquota", .path = "lustre/quota" },
+ { .name = "mgs", .path = "lustre/mgs" },
+ { .name = "mgc", .path = "lustre/mgc" },
+ { .name = "mdt", .path = "lustre/mdt" },
+ { .name = "mdd", .path = "lustre/mdd" },
+ { .name = "osd", .path = "lustre/osd" },
+ { .name = "cmm", .path = "lustre/cmm" },
+ { .name = "fid", .path = "lustre/fid"},
+ { .name = "fld", .path = "lustre/fld"},
+ { .name = "lod", .path = "lustre/lod"},
+ { .name = "osp", .path = "lustre/osp"},
+ { .name = "lfsck", .path = "lustre/lfsck" },
+ { .name = NULL }
};
int jt_dbg_modules(int argc, char **argv)
fclose(file);
return 0;
}
-
-int jt_dbg_panic(int argc, char **argv)
-{
- int rc;
- struct libcfs_ioctl_data data;
-
- if (argc != 1) {
- fprintf(stderr, "usage: %s\n", argv[0]);
- return 0;
- }
-
- memset(&data, 0, sizeof(data));
- if (libcfs_ioctl_pack(&data, &buf, max) != 0) {
- fprintf(stderr, "libcfs_ioctl_pack failed.\n");
- return -1;
- }
-
- rc = l_ioctl(LNET_DEV_ID, IOC_LIBCFS_PANIC, buf);
- if (rc) {
- fprintf(stderr, "IOC_LIBCFS_PANIC failed: %s\n",
- strerror(errno));
- return -1;
- }
- return 0;
-}