static struct dentry *lnet_debugfs_root;
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 18, 53, 0)
+/* remove deprecated libcfs ioctl handling, since /dev/lnet has
+ * moved to lnet and there is no way to call these ioctls until
+ * after the lnet module is loaded. They are replaced by writing
+ * to "debug_marker", handled by libcfs_debug_marker() below.
+ */
int libcfs_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
{
switch (cmd) {
return 0;
}
EXPORT_SYMBOL(libcfs_ioctl);
+#endif
static int proc_dobitmasks(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
return rc;
}
+static int libcfs_debug_marker(struct ctl_table *table, int write,
+ void __user *buffer,
+ size_t *lenp, loff_t *ppos)
+{
+ size_t len = min(*lenp, 4000UL);
+ char *kbuf;
+
+ if (!*lenp || *ppos) {
+ *lenp = 0;
+ return 0;
+ }
+
+ if (!write)
+ return 0;
+
+ kbuf = strndup_user(buffer, len);
+ if (IS_ERR(kbuf))
+ return PTR_ERR(kbuf);
+
+ if (strcmp(kbuf, "clear") == 0)
+ libcfs_debug_clear_buffer();
+ else
+ libcfs_debug_mark_buffer(kbuf);
+
+ kfree(kbuf);
+ *ppos += len;
+
+ return *lenp > 4000 ? -EOVERFLOW : 0;
+}
+
int debugfs_doint(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
.extra2 = &max_watchdog_ratelimit,
},
{
+ .procname = "debug_marker",
+ .mode = 0200,
+ .proc_handler = &libcfs_debug_marker
+ },
+ {
.procname = "force_lbug",
.data = NULL,
.maxlen = 0,
#include <linux/miscdevice.h>
#include <lnet/lib-lnet.h>
#include <uapi/linux/lnet/lnet-dlc.h>
+#include <uapi/linux/lustre/lustre_ver.h>
static int config_on_load = 0;
module_param(config_on_load, int, 0444);
CDEBUG(D_IOCTL, "lnet ioctl cmd %u\n", cmd);
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 18, 53, 0)
err = libcfs_ioctl(cmd, data);
if (err == -EINVAL)
+#endif
err = lnet_ioctl(cmd, hdr);
if (err == -EINVAL) {
err = blocking_notifier_call_chain(&lnet_ioctl_list,
int jt_dbg_clear_debug_buf(int argc, char **argv)
{
- int rc;
struct libcfs_ioctl_data data;
+ glob_t path;
+ int fd, rc;
if (argc != 1) {
fprintf(stderr, "usage: %s\n", argv[0]);
return 0;
}
+ if (cfs_get_param_paths(&path, "debug_marker") != 0)
+ goto use_ioctl;
+
+ fd = open(path.gl_pathv[0], O_WRONLY);
+ if (fd < 0) {
+ cfs_free_param_data(&path);
+ goto use_ioctl;
+ }
+
+ rc = write(fd, "clear", strlen("clear") + 1);
+ cfs_free_param_data(&path);
+ close(fd);
+ return rc > 0 ? 0 : rc;
+
+use_ioctl:
memset(&data, 0, sizeof(data));
if (libcfs_ioctl_pack(&data, &buf, max) != 0) {
fprintf(stderr, "libcfs_ioctl_pack failed.\n");
int jt_dbg_mark_debug_buf(int argc, char **argv)
{
- static char scratch[MAX_MARK_SIZE] = "";
+ static char scratch[MAX_MARK_SIZE] = "";
struct libcfs_ioctl_data data;
- char *text;
- int rc;
-
- memset(&data, 0, sizeof(data));
+ glob_t path;
+ char *text;
+ int fd, rc;
if (argc > 1) {
int count, max_size = sizeof(scratch) - 1;
text = ctime(&now);
}
+ if (cfs_get_param_paths(&path, "debug_marker") != 0)
+ goto use_ioctl;
+
+ fd = open(path.gl_pathv[0], O_WRONLY);
+ if (fd < 0) {
+ cfs_free_param_data(&path);
+ goto use_ioctl;
+ }
+
+ rc = write(fd, text, strlen(text) + 1);
+ cfs_free_param_data(&path);
+ close(fd);
+ return rc > 0 ? 0 : rc;
+
+use_ioctl:
+ memset(&data, 0, sizeof(data));
data.ioc_inllen1 = strlen(text) + 1;
data.ioc_inlbuf1 = text;