#include <libcfs/libcfs.h>
#include <libcfs/libcfs_crypto.h>
+#include <libcfs/linux/linux-fs.h>
#include <lnet/lib-lnet.h>
#include "tracefile.h"
err = -EINVAL;
else
err = notifier_to_errno(err);
- if (!err)
- if (copy_to_user(uparam, hdr, hdr->ioc_len))
- err = -EFAULT;
+ if (copy_to_user(uparam, hdr, hdr->ioc_len) && !err)
+ err = -EFAULT;
break;
}
out:
return &lnet_debugfs_file_operations_rw;
}
-void lnet_insert_debugfs(struct ctl_table *table,
- const struct lnet_debugfs_symlink_def *symlinks)
+void lnet_insert_debugfs(struct ctl_table *table)
{
if (!lnet_debugfs_root)
lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
debugfs_create_file(table->procname, table->mode,
lnet_debugfs_root, table,
lnet_debugfs_fops_select(table->mode));
+}
+EXPORT_SYMBOL_GPL(lnet_insert_debugfs);
+static void lnet_insert_debugfs_links(
+ const struct lnet_debugfs_symlink_def *symlinks)
+{
for (; symlinks && symlinks->name; symlinks++)
debugfs_create_symlink(symlinks->name, lnet_debugfs_root,
symlinks->target);
}
-EXPORT_SYMBOL_GPL(lnet_insert_debugfs);
-static void lnet_remove_debugfs(void)
+#ifndef HAVE_D_HASH_AND_LOOKUP
+/**
+ * d_hash_and_lookup - hash the qstr then search for a dentry
+ * @dir: Directory to search in
+ * @name: qstr of name we wish to find
+ *
+ * On lookup failure NULL is returned; on bad name - ERR_PTR(-error)
+ */
+struct dentry *d_hash_and_lookup(struct dentry *dir, struct qstr *name)
{
- debugfs_remove_recursive(lnet_debugfs_root);
+ /*
+ * Check for a fs-specific hash function. Note that we must
+ * calculate the standard hash first, as the d_op->d_hash()
+ * routine may choose to leave the hash value unchanged.
+ */
+ name->hash = full_name_hash(name->name, name->len);
+ if (dir->d_op && dir->d_op->d_hash) {
+ int err = dir->d_op->d_hash(dir, name);
+ if (unlikely(err < 0))
+ return ERR_PTR(err);
+ }
+ return d_lookup(dir, name);
+}
+#endif
- lnet_debugfs_root = NULL;
+void lnet_remove_debugfs(struct ctl_table *table)
+{
+ for (; table && table->procname; table++) {
+ struct qstr dname = QSTR_INIT(table->procname,
+ strlen(table->procname));
+ struct dentry *dentry;
+
+ dentry = d_hash_and_lookup(lnet_debugfs_root, &dname);
+ debugfs_remove(dentry);
+ }
}
+EXPORT_SYMBOL_GPL(lnet_remove_debugfs);
static int __init libcfs_init(void)
{
int rc;
+#ifndef HAVE_WAIT_VAR_EVENT
+ wait_bit_init();
+#endif
rc = libcfs_debug_init(5 * 1024 * 1024);
if (rc < 0) {
printk(KERN_ERR "LustreError: libcfs_debug_init: %d\n", rc);
goto cleanup_wi;
}
- lnet_insert_debugfs(lnet_table, lnet_debugfs_symlinks);
+ lnet_insert_debugfs(lnet_table);
+ if (!IS_ERR_OR_NULL(lnet_debugfs_root))
+ lnet_insert_debugfs_links(lnet_debugfs_symlinks);
CDEBUG (D_OTHER, "portals setup OK\n");
return 0;
{
int rc;
- lnet_remove_debugfs();
+ /* Remove everthing */
+ debugfs_remove_recursive(lnet_debugfs_root);
+ lnet_debugfs_root = NULL;
CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
atomic_read(&libcfs_kmemory));